Re: "data=writeback" and TRIM don't get along

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Sandeen
Date: Wednesday, April 7, 2010 - 9:10 pm

Nebojsa Trpkovic wrote:

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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
"data=writeback" and TRIM don't get along, Nebojsa Trpkovic, (Wed Apr 7, 5:50 pm)
Re: "data=writeback" and TRIM don't get along, Nebojsa Trpkovic, (Wed Apr 7, 6:37 pm)
Re: "data=writeback" and TRIM don't get along, Eric Sandeen, (Wed Apr 7, 9:10 pm)
Re: "data=writeback" and TRIM don't get along, Dmitry Monakhov, (Thu Apr 8, 12:17 am)
Re: "data=writeback" and TRIM don't get along, Nebojsa Trpkovic, (Thu Apr 8, 4:47 am)
Re: "data=writeback" and TRIM don't get along, Nebojsa Trpkovic, (Thu Apr 8, 4:48 am)
Re: "data=writeback" and TRIM don't get along, Nebojsa Trpkovic, (Thu Apr 8, 9:21 am)