d_alloc_parallel(): set DCACHE_PAR_LOOKUP earlier
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 24 Feb 2025 15:36:46 +0000 (10:36 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 11 Jun 2025 17:40:01 +0000 (13:40 -0400)
commite95db51c81f54dd12ea465b5127e4786f62a1095
tree247d876551861bcbd9f8fd9d2f607b4ff9f7bd85
parent691fb82ca6ccdcdb9e60e754b55659271d5280e7
d_alloc_parallel(): set DCACHE_PAR_LOOKUP earlier

Do that before new dentry is visible anywhere.  It does create
a new possible state for dentries present in ->d_children/->d_sib -
DCACHE_PAR_LOOKUP present, negative, unhashed, not in in-lookup
hash chains, refcount positive.  Those are going to be skipped
by all tree-walkers (both d_walk() callbacks in fs/dcache.c and
explicit loops over children/sibling lists elsewhere) and
dput() is fine with those.

NOTE: dropping the final reference to a "normal" in-lookup dentry
(in in-lookup hash) is a bug - somebody must've forgotten to
call d_lookup_done() on it and bad things will happen.  With those
it's OK; if/when we get around to making __dentry_kill() complain
about such breakage, remember that predicate to check should
*not* be just d_in_lookup(victim) but rather a combination of that
with !hlist_bl_unhashed(&victim->d_u.d_in_lookup_hash).  Might
be worth considering later...

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c