From: Al Viro <viro@ZenIV.linux.org.uk>
To: "J. R. Okajima" <hooanon05g@gmail.com>
Cc: linux-fsdevel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: Q. hlist_bl_add_head_rcu() in d_alloc_parallel()
Date: Mon, 20 Jun 2016 15:51:25 +0100 [thread overview]
Message-ID: <20160620145125.GL14480@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20160620053530.GI14480@ZenIV.linux.org.uk>
On Mon, Jun 20, 2016 at 06:35:30AM +0100, Al Viro wrote:
> On Mon, Jun 20, 2016 at 01:34:14PM +0900, J. R. Okajima wrote:
> >
> > Al Viro:
> > > How would processB get past d_wait_lookup()? It would have to have
> >
> > By the first d_unhashed() test in the loop, processB doesn't reach
> > d_wait_lookup().
>
> Huh? What first d_unhashed()... <stares>
>
> That check is definitely bogus and I'm completely at loss as to WTF is it
> doing there. Thanks for catching that; this kind of idiotic braino can
> escape notice when rereading the code again and again, unfortunately ;-/
>
> Fixed, will push to Linus tonight or tomorrow.
FWIW, I understand how it got there; it was a garbage from cut'n'paste from
lockless primary hash lookups (cut'n'paste was for the sake of "compare
the name" logics). It was absolutely wrong - dentry is never added to
the primary hash until it has been removed from in-lookup one. And we are
walking the in-lookup hash chain with its bitlock held, so there's no
chance of that.
In effect that junk prevented d_alloc_parallel() from *ever* spotting
in-lookup matches. What's more, removing it has instantly uncovered
another bug in the match-handling code - dget() done under the chain
bitlock, which nests inside ->d_lock. Trivially fixed, of course (we
just hold rcu_read_lock() through the in-lookup hash search and instead
of dget() while holding the chain bitlock do lockref_get_not_dead()
after dropping the bitlock), but... *ouch*
It's going through the local tests right now; seems to be OK so far; I'll
send a pull request once it's through those. But this demonstrates why RTFS
(and by somebody other than the author of TFS being R) is really, _really_
important. I have read through that loop many times and kept missing that
turdlet ;-/
Al, wearing a brown paperbag ;-/
next prev parent reply other threads:[~2016-06-20 14:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 20:50 Q. hlist_bl_add_head_rcu() in d_alloc_parallel() J. R. Okajima
2016-06-17 22:16 ` Al Viro
2016-06-17 22:56 ` Al Viro
2016-06-19 5:24 ` J. R. Okajima
2016-06-19 16:55 ` Al Viro
2016-06-20 4:34 ` J. R. Okajima
2016-06-20 5:35 ` Al Viro
2016-06-20 14:51 ` Al Viro [this message]
2016-06-20 17:14 ` [git pull] vfs fixes Al Viro
2016-06-23 1:19 ` Q. hlist_bl_add_head_rcu() in d_alloc_parallel() J. R. Okajima
2016-06-23 2:58 ` Al Viro
2016-06-24 5:57 ` Linus Torvalds
2016-06-25 22:54 ` Al Viro
2016-06-26 1:25 ` Linus Torvalds
2016-06-29 8:17 ` Al Viro
2016-06-29 9:22 ` Hekuang
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=20160620145125.GL14480@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=hooanon05g@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--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).