From: Dave Chinner <david@fromorbit.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>,
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: The bug of iput() removal from flusher thread?
Date: Wed, 21 Nov 2012 19:22:19 +1100 [thread overview]
Message-ID: <20121121082219.GQ2591@dastard> (raw)
In-Reply-To: <20121121000533.a0ab9eea.akpm@linux-foundation.org>
On Wed, Nov 21, 2012 at 12:05:33AM -0800, Andrew Morton wrote:
> On Wed, 21 Nov 2012 02:48:51 +0100 Jan Kara <jack@suse.cz> wrote:
>
> > +/*
> > + * Add inode to LRU if needed (inode is unused and clean).
> > + *
> > + * Needs inode->i_lock held.
> > + */
> > +void inode_add_lru(struct inode *inode)
> > +{
> > + if (!(inode->i_state & (I_DIRTY | I_FREEING | I_SYNC)) &&
> > + !atomic_read(&inode->i_count) && inode->i_sb->s_flags & MS_ACTIVE)
> > + inode_lru_list_add(inode);
> > +}
>
> Is i_lock sufficient to stabilise i_count?
>
> <looks at the code a bit>
>
> Is evict_inodes() wrong to test i_count outside i_lock?
>
> invalidate_inodes() looks better.
>
> can_unuse() must be called under i_lock, and is. Apparently this
> requirement was sufficiently obvious to not meed documenting.
It is documented. can_unuse looks at i_state and i_count, and both
are documented as requiring the i_lock at the top of the file in
the locking rules section. Also, see __iget(), also mentioned in
the locking rules....
> prune_icache_sb() gets it right.
>
> iput() gets it right.
>
> So to answer my own question: yes, it is sufficient. But a) the
> comment for inode.i_lock is out of date
If you means the one in fs.h, then yeah, it's way out of date....
>
> and b) evict_inodes() looks
> fishy.
As I understand it, evict_inodes() is special - it's only called
from generic_shutdown_super() after the MS_ACTIVE flag has been
removed from the filesytem, the dcache has been pruned and all the
inodes cleaned. So there should be no new references to the inodes
occurring, and hence we don't need to hold the lock to serialise
against new references being taken....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2012-11-21 8:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-17 8:42 The bug of iput() removal from flusher thread? OGAWA Hirofumi
2012-11-19 8:56 ` OGAWA Hirofumi
2012-11-19 14:51 ` Jan Kara
2012-11-19 19:41 ` Jan Kara
2012-11-19 20:51 ` OGAWA Hirofumi
2012-11-19 21:24 ` Jan Kara
2012-11-19 21:53 ` OGAWA Hirofumi
2012-11-21 1:11 ` Jan Kara
2012-11-21 1:48 ` Jan Kara
2012-11-21 2:44 ` Dave Chinner
2012-11-21 17:08 ` Jan Kara
2012-11-21 8:05 ` Andrew Morton
2012-11-21 8:22 ` Dave Chinner [this message]
2012-11-20 22:37 ` Dave Chinner
2012-11-21 1:30 ` Jan Kara
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=20121121082219.GQ2591@dastard \
--to=david@fromorbit.com \
--cc=akpm@linux-foundation.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).