linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: ext4 development <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] fix ext4_free_inode vs. ext4_claim_inode race
Date: Wed, 04 Mar 2009 22:21:59 -0600	[thread overview]
Message-ID: <49AF5367.5040006@redhat.com> (raw)
In-Reply-To: <20090305040340.GC17949@skywalker>

Aneesh Kumar K.V wrote:
> On Wed, Mar 04, 2009 at 05:11:28PM -0600, Eric Sandeen wrote:
>> Eric Sandeen wrote:
>>
>> Index: linux-2.6/fs/ext4/ialloc.c
>> ===================================================================
>> --- linux-2.6.orig/fs/ext4/ialloc.c
>> +++ linux-2.6/fs/ext4/ialloc.c
>> @@ -609,26 +609,33 @@ static int ext4_claim_inode(struct super
>>  			struct buffer_head *inode_bitmap_bh,
>>  			unsigned long ino, ext4_group_t group, int mode)
>>  {
>> -	int free = 0, retval = 0, count;
>> +	int free = 0, bitset, count;
>>  	struct ext4_sb_info *sbi = EXT4_SB(sb);
>>  	struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL);
>>
>> -	spin_lock(sb_bgl_lock(sbi, group));
>> -	if (ext4_set_bit(ino, inode_bitmap_bh->b_data)) {
>> -		/* not a free inode */
>> -		retval = 1;
>> -		goto err_ret;
>> +	/* if uninit, protect against ext4_read_inode_bitmap initialization */
>> +	bitset = -1;
>> +	if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
>> +		spin_lock(sb_bgl_lock(sbi, group));
>> +		if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT))
>> +			bitset = ext4_set_bit(ino, inode_bitmap_bh->b_data);
>> +		spin_unlock(sb_bgl_lock(sbi, group));
>>  	}
> 
> 
> That won't work. We need set the bit and clear the  INODE_UNINIT flag
> by holding the spin_lock. In ext4_read_inode_bitmap we check the
> INODE_UNINIT flag and re-init the inode bitmap. So we may end up 
> re-initing the bitmap if we don't clear the INODE_UNINIT flag holding
> the spin lock

Yeah, I guess maybe that's the same old race we had to start with isn't it.

Remind me again why we don't just clear UNINIT when we read in the
bitmap in and ... init it?

-Eric

      reply	other threads:[~2009-03-05  4:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-04  4:38 [PATCH] fix ext4_free_inode vs. ext4_claim_inode race Eric Sandeen
2009-03-04 19:06 ` Aneesh Kumar K.V
2009-03-05  0:06   ` Theodore Tso
2009-03-04 23:11 ` Eric Sandeen
2009-03-05  4:03   ` Aneesh Kumar K.V
2009-03-05  4:21     ` Eric Sandeen [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=49AF5367.5040006@redhat.com \
    --to=sandeen@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).