From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neil@brown.name>,
Linus Torvalds <torvalds@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Amir Goldstein <amir73il@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/7] VFS: use wait_var_event for waiting in d_alloc_parallel()
Date: Mon, 11 May 2026 14:01:31 -0400 [thread overview]
Message-ID: <769926ac94c1565c392bc55e84cb0eb8d3c3c6f5.camel@kernel.org> (raw)
In-Reply-To: <20260430020137.3305302-3-neilb@ownmail.net>
On Thu, 2026-04-30 at 11:56 +1000, NeilBrown wrote:
> From: NeilBrown <neil@brown.name>
>
> d_alloc_parallel() currently requires a wait_queue_head to be passed in.
> This must have a life time which extends until the lookup is completed.
>
> This makes it awkward to use and particularly make it hard to use in
> lookup_one_qstr_excl() which I hope to do in the future.
>
> This patch changes d_alloc_parallel() to use wake_up_var_locked() to
> wake up waiters, and wait_var_event_spinlock() to wait. dentry->d_lock
> is used for synchronisation as it is already held and the relevant
> times.
>
> In most cases there will be no waiters so the wake_up_var_locked() call
> (which can walk an arbitrarily long list) would be a complete waste. To
> optimise this a new ->d_flags flag is added: DCACHE_LOOKUP_WAITER. This
> is set whenever any thread prepares to wait for the dentry, and if it
> isn't set when DCACHE_PAR_LOOKUP is cleared, no wakeup is sent.
> DCACHE_LOOKUP_WAITER is cleared after the wakeup is set.
>
> __d_lookup_unhash() no longer returns a wq. Callers check
> DCACHE_LOOKUP_WAITER to check if a wakeup is needed, and
> wake_up_var_locked() can find the wq.
>
> __d_lookup_unhash() no longer needs to re-init ->d_lru. That was
> previously shared (in a union) with ->d_wait but ->d_wait is now gone
> so it no longer corrupts ->d_lru.
>
> Wakeup is move out of end_dir_add() as it is conceptually a separate action.
>
> Co-developed-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: NeilBrown <neil@brown.name>
> ---
> Documentation/filesystems/porting.rst | 6 ++
> fs/afs/dir_silly.c | 4 +-
> fs/dcache.c | 83 +++++++++++++++------------
> fs/fuse/readdir.c | 3 +-
> fs/namei.c | 6 +-
> fs/nfs/dir.c | 6 +-
> fs/nfs/unlink.c | 3 +-
> fs/proc/base.c | 3 +-
> fs/proc/proc_sysctl.c | 3 +-
> fs/smb/client/readdir.c | 3 +-
> include/linux/dcache.h | 11 ++--
> include/linux/nfs_xdr.h | 1 -
> 12 files changed, 67 insertions(+), 65 deletions(-)
>
>
[...]
>
> @@ -2979,7 +2987,7 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
> if (unlikely(d_in_lookup(target))) {
> dir = target->d_parent->d_inode;
> n = start_dir_add(dir);
> - d_wait = __d_lookup_unhash(target);
> + __d_lookup_unhash(target);
> }
In the old code, d_wait was associated with the target...
>
> write_seqcount_begin(&dentry->d_seq);
> @@ -3018,9 +3026,10 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
> write_seqcount_end(&target->d_seq);
> write_seqcount_end(&dentry->d_seq);
>
> - if (dir)
> - end_dir_add(dir, n, d_wait);
> -
> + if (dir) {
> + end_dir_add(dir, n);
> + __d_wake_in_lookup_waiters(dentry);
> + }
...but here you are waking based on "dentry". Should that be:
__d_wake_in_lookup_waiters(target)
?
--
Jeff Layton <jlayton@kernel.org>
parent reply other threads:[~2026-05-11 18:01 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20260430020137.3305302-3-neilb@ownmail.net>]
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=769926ac94c1565c392bc55e84cb0eb8d3c3c6f5.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil@brown.name \
--cc=torvalds@linux-foundation.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