* Re: [PATCH v4 2/7] VFS: use wait_var_event for waiting in d_alloc_parallel()
[not found] ` <20260430020137.3305302-3-neilb@ownmail.net>
@ 2026-05-11 18:01 ` Jeff Layton
0 siblings, 0 replies; only message in thread
From: Jeff Layton @ 2026-05-11 18:01 UTC (permalink / raw)
To: NeilBrown, Linus Torvalds, Al Viro, Christian Brauner, Jan Kara,
Amir Goldstein
Cc: linux-fsdevel, linux-kernel
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>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-11 18:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260430020137.3305302-1-neilb@ownmail.net>
[not found] ` <20260430020137.3305302-3-neilb@ownmail.net>
2026-05-11 18:01 ` [PATCH v4 2/7] VFS: use wait_var_event for waiting in d_alloc_parallel() Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox