All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ted Ts'o <tytso@mit.edu>
To: Eric Sandeen <sandeen@redhat.com>
Cc: ext4 development <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH, RFC] ext4: fix race in xattr block allocation path
Date: Sat, 29 Oct 2011 10:12:45 -0400	[thread overview]
Message-ID: <20111029141245.GI19536@thunk.org> (raw)
In-Reply-To: <4EA5E702.8030303@redhat.com>

On Mon, Oct 24, 2011 at 05:30:26PM -0500, Eric Sandeen wrote:
> Ceph users reported that when using Ceph on ext4, the filesystem
> would often become corrupted, containing inodes with incorrect
> i_blocks counters.
> 
> ...
>
> In other words, the sync/flush thread pops in and sets
> i_delalloc_reserved_flag on the inode, which makes the xattr thread
> think that it's in a delalloc path in ext4_new_meta_blocks(),
> and add the block for a second time, after already having added
> it once in the !i_delalloc_reserved_flag case in ext4_mb_new_blocks
> 
> I think this can be as simple as taking i_data_sem before we
> go down the new metablock path, so that we won't be testing
> i_delalloc_reserved_flag in a race with xt4_get_blocks setting it.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Thanks, applied for now.

> 
> This seems like slight abuse of i_data_sem though, since we are
> not modifying i_data[] in the inode on the xattr path.  But nothing
> else protects readers of i_delalloc_reserved_flag in other
> threads.  Thoughts?

Agreed, we really should be depending on the
EXT4_GET_BLOCK_DELALLOC_RESERVE and EXT4_MB_DELALLOC_RESERVED flags.
I can't remember what caused us to plumb in the i_state flag, but
that's clearly a hack which is biting us hard.

I'll take this patch for now since it fixes a real problem, but we
should figure out a better way of fixing this, hopefully that results
in the i_state flag going away.

						- Ted

      reply	other threads:[~2011-10-29 18:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24 22:30 [PATCH, RFC] ext4: fix race in xattr block allocation path Eric Sandeen
2011-10-29 14:12 ` Ted Ts'o [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111029141245.GI19536@thunk.org \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.