linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Hugh Dickins <hughd@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nick Piggin <npiggin@kernel.dk>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] vfs: fix race in rcu lookup of pruned dentry
Date: Mon, 18 Jul 2011 01:25:24 +0100	[thread overview]
Message-ID: <20110718002524.GU11013@ZenIV.linux.org.uk> (raw)
In-Reply-To: <alpine.LSU.2.00.1107171641130.1274@sister.anvils>

On Sun, Jul 17, 2011 at 04:47:45PM -0700, Hugh Dickins wrote:
> On Sun, 17 Jul 2011, Linus Torvalds wrote:
> > On Sun, Jul 17, 2011 at 4:16 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> > >
> > > OR
> > >
> > > ?- keep part of the patch from Hugh, treating negative in RCU mode as
> > > "need to unlazy".
> > 
> > No, urgh, that's horrible.
> > 
> > Not being able to do an RCU lookup of negative dentries would be
> > really sad. There are some loads where a negative dentry is the
> > *common* case.
> 
> Yes, that worried me too.

Grr...  What do you think we need to do when we find a negative dentry in
RCU lookup?  We can
	* check its ->d_seq, to see if it's valid
	* somehow (e.g. with what Linus suggested) try to walk further and
leave staleness checks for dentries we would encounter later in the walk.

If it's in the end of pathname, there is no choice at all - we need to
check ->d_seq of this one.  Right?  And we do exactly that.  If we see
that it's for real, fine we got ourselves a reference to negative dentry
and can go ahead.  If it's something like stat(2), we'll just do dput()
and bugger off.  Refcounts of everything on the path to it are unaffected,
no global locks played with...

If it's in the middle of pathname, we could try to delay the check.  And
what would it buy us?  If that dentry was stale, we'd just walk a bit
deeper.  And found a stale one at some later point.  And restarted pathname
resolution in non-lazy mode from the very beginning.  If it wasn't stale
(i.e. real negative dentry), we *do* want -ENOENT and we'll get it as soon
as unlazy_walk() will check ->d_seq and we plod through the rest of
do_lookup() to check in walk_component().  We won't redo d_lookup(), lock
i_mutex, etc.

  reply	other threads:[~2011-07-18  0:25 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-17 21:03 [PATCH] vfs: fix race in rcu lookup of pruned dentry Hugh Dickins
2011-07-17 22:00 ` Linus Torvalds
2011-07-17 22:59   ` Linus Torvalds
2011-07-17 23:26     ` Al Viro
2011-07-17 23:16   ` Al Viro
2011-07-17 23:38     ` Linus Torvalds
2011-07-17 23:47       ` Hugh Dickins
2011-07-18  0:25         ` Al Viro [this message]
2011-07-18  1:13           ` Hugh Dickins
2011-07-18  2:08             ` Al Viro
2011-07-18  6:31               ` Linus Torvalds
2011-07-18 14:41                 ` Hugh Dickins
2011-07-18 18:11                 ` Linus Torvalds
2011-07-18 18:20                   ` Al Viro
2011-07-18 19:08                     ` Linus Torvalds
2011-07-18 19:20                       ` Al Viro
2011-07-18 19:23                         ` Al Viro
2011-07-18 19:34                         ` Linus Torvalds
2011-07-18 19:04                   ` Hugh Dickins
2011-07-18 19:33                     ` Linus Torvalds
2011-07-18 19:47                       ` Al Viro
2011-07-18 20:24                         ` Linus Torvalds
2011-07-18 21:19                           ` Hugh Dickins
2011-07-18 21:42                             ` Linus Torvalds
2011-07-18 22:43                               ` Hugh Dickins
2011-07-18 23:17                                 ` Al Viro
2011-07-18 23:21                                   ` Al Viro
2011-07-18 23:27                                     ` Linus Torvalds
2011-07-18 23:40                                       ` Al Viro
2011-07-19  2:07                                         ` Hugh Dickins
2011-07-19  2:14                                           ` Linus Torvalds
2011-07-19  2:17                                             ` Linus Torvalds
2011-07-19  2:23                                               ` Al Viro
2011-07-19  2:37                                                 ` Chris Ball
2011-07-19  4:41                                                 ` Nicolas Pitre
2011-07-19  2:21                                           ` Al Viro
2011-07-19 23:45                               ` Al Viro
2011-07-19 23:52                                 ` Al Viro
2011-07-19 23:55                                   ` Al Viro
2011-07-20  0:47                                     ` NeilBrown
2011-07-20  1:40                                       ` Al Viro
2011-07-20  4:52                                         ` Linus Torvalds
2011-07-19 23:56                                 ` Linus Torvalds
2011-07-20  0:04                                   ` Al Viro
2011-07-17 23:53       ` Al Viro
2011-07-17 23:31   ` Hugh Dickins
2011-07-17 23:52     ` Linus Torvalds

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=20110718002524.GU11013@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@kernel.dk \
    --cc=torvalds@linux-foundation.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).