From: Lachlan McIlroy <lachlan@sgi.com>
To: Christoph Hellwig <hch@infradead.org>,
Lachlan McIlroy <lachlan@sgi.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: assertion failure with latest xfs
Date: Wed, 29 Oct 2008 11:43:31 +1100 [thread overview]
Message-ID: <4907B1B3.4020008@sgi.com> (raw)
In-Reply-To: <20081023222126.GA18495@disturbed>
Dave Chinner wrote:
> On Thu, Oct 23, 2008 at 01:31:49PM -0400, Christoph Hellwig wrote:
>> On Thu, Oct 23, 2008 at 07:08:15PM +1000, Lachlan McIlroy wrote:
>>> Just encountered this after pulling in the latest changes. We are trying to
>>> initialise an inode that should have an i_count of 1 but instead it is 2. I
>>> was running XFSQA test 167 when it happened.
>> I think the assert is incorrect. The inode has been added to the radix
>> tree in xfs_iget_cache_miss, and starting from that point an igrab can
>> kick in from the sync code and bump the refcount.
>
> Actually, it was put there for a reason. The generic code doesn't
> allow new inodes to be found in the cache until the I_LOCK flag is
> cleared. This is done by calling wait_on_inode() after a successful
> lookup (which waits on I_LOCK) and unlock_new_inode() clears the
> I_LOCK|I_NEW bits and wakes anyone who was waiting on that inode via
> wake_up_inode(). So the assert was put there to catch potential
> races in lookup where a second process does a successful igrab()
> before the inode is fully initialised.
>
> I think the race is in dealing with cache hits and recycling a
> XFS_IRECLAIMABLE inode. We set the XFS_INEW flag there under
> the radix tree read lock, which means we can have parallel lookups
> on the same inode that goes:
>
> thread 1 thread 2
> test XFS_INEW
> -> not set
> test XFS_IRECLAIMABLE
> -> set
> test XFS_INEW
> -> not set
> set XFS_INEW
> clear XFS_IRECLAIMABLE
> test XFS_IRECLAIMABLE
> -> not set
> xfs_setup_inode()
> -> i_state = I_NEW|I_LOCK
> igrab(inode)
> -> I_CLEAR not set
> -> refcount = 2
> -> inode_add_to_lists
> -> assert(refcount == 1)
> .....
> -> clear XFS_INEW
> -> unlock_new_inode()
> -> clear I_NEW|I_LOCK
>
> I thought I'd handled this race with the ordering of setting/clearing
> XFS_INEW/XFS_IRECLAIMABLE. Clearly not. I'll add a comment to this
> ordering because it is key to actually detecting the race condition
> so we can handle it.
>
> Hmmmm - there's also another bug in xfs_iget_cache_hit() - we don't
> drop the reference we got if we found an unlinked inode after the
> igrab() (the ENOENT case). I'll fix that as well.
>
> Patch below that I'm currently running through xfsqa.
I gave this patch a go and it still asserted at the same place running
the same test.
next prev parent reply other threads:[~2008-10-29 0:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-23 9:08 assertion failure with latest xfs Lachlan McIlroy
2008-10-23 17:31 ` Christoph Hellwig
2008-10-23 22:21 ` Dave Chinner
2008-10-29 0:43 ` Lachlan McIlroy [this message]
2008-10-29 3:29 ` Dave Chinner
2008-10-30 2:29 ` Lachlan McIlroy
2008-10-30 5:38 ` Dave Chinner
2008-10-31 1:09 ` Dave Chinner
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=4907B1B3.4020008@sgi.com \
--to=lachlan@sgi.com \
--cc=hch@infradead.org \
--cc=xfs@oss.sgi.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.