Ok, thanks, perfect test & explanation.
Well the good news is, at least it's nothing like discarding
the wrong block. :)
Long explanation:
in ext4_free_blocks():
/*
* We need to make sure we don't reuse the freed block until
* after the transaction is committed, which we can do by
* treating the block as metadata, below. We make an
* exception if the inode is to be written in writeback mode
* since writeback mode has weak data consistency guarantees.
*/
if (!ext4_should_writeback_data(inode))
flags |= EXT4_FREE_BLOCKS_METADATA;
so here we don't set this flag for writeback mode.
Later in that function we do:
if ((flags & EXT4_FREE_BLOCKS_METADATA) && ext4_handle_valid(handle)) {
...
ext4_mb_free_metadata(handle, &e4b, new_entry);
ext4_mb_free_metadata adds to t_private_list:
/* Add the extent to transaction's private list */
spin_lock(&sbi->s_md_lock);
list_add(&new_entry->list, &handle->h_transaction->t_private_list);
spin_unlock(&sbi->s_md_lock);
Once we finally get to release_blocks_on_commit, only things on t_private_list
ultimately get discarded.
Anyway, at the root of this is right now the discard really only happens for
things flagged as metadata, which is a pretty funky thing to do.
(and indeed if you have a unique xattr block, you'll see it get discarded
even with data=writeback).
I'll have to think about the right way to do this... it seems pretty
convoluted to me right now.
-Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html