This is trying to make sure the write_tag and index_tag are identical at all times. It's really not clear this is safe because the prepare_update_index() call just below can rewrite index_tag to be based on state->obj_tag (if set).
Now, I think it is safe because it looks like obj_tag is only set by looking at previous write_tags, and they might even be used only in different kinds of transactions (?), but I'm having difficulty tracing it out. What are the relevant invariants here?