diff options
| author | NeilBrown <neil@brown.name> | 2026-10-21 19:56:57 +1100 |
|---|---|---|
| committer | Miklos Szeredi <mszeredi@mszeredi-thinkpadt14gen6.rmthu.csb> | 2026-11-02 12:41:16 +0100 |
| commit | aa0c00a516faac6683c7fb0a4f1032f471f910f7 (patch) | |
| tree | 9baf7cb81b90daefc77b6e2c5a982f33a383a56a | |
| parent | 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 (diff) | |
fuse: Use d_alloc_trylock() in fuse_direntplus_link()
fuse uses the results of readdir to prime the dcache. Using
d_alloc_parallel() can block if there is a concurrent lookup. Blocking
in that case is pointless as the lookup will add info to the dcache and
there is no value in the readdir waiting to see if it should add the
info too.
Also this call to d_alloc_parallel() is made while the parent
directory is locked. A proposed change to locking will lock the parent
later, after d_alloc_parallel(). This means it won't be safe to wait in
d_alloc_parallel() while holding the directory lock.
So change to use d_alloc_trylock(), which doesn't require full_name_hash
and d_lookup to be called first.
If d_alloc_trylock() fails with -EWOULDBLOCK or for any other reason,
the consequence is only that fuse_force_forget() is called, which is
required to keep the lookup count on the node consistent between client
and server. It does not cause the readdir to fail.
Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
| -rw-r--r-- | fs/fuse/readdir.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index 1f6cf565477f..295cbd645653 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -11,6 +11,7 @@ #include <linux/pagemap.h> #include <linux/highmem.h> #include <linux/vmalloc.h> +#include <linux/namei.h> static bool fuse_use_readdirplus(struct inode *dir, struct dir_context *ctx) { @@ -195,14 +196,11 @@ static int fuse_direntplus_link(struct file *file, fc = get_fuse_conn(dir); epoch = atomic_read(&fc->epoch); - name.hash = full_name_hash(parent, name.name, name.len); - dentry = d_lookup(parent, &name); - if (!dentry) { retry: - dentry = d_alloc_parallel(parent, &name); - if (IS_ERR(dentry)) - return PTR_ERR(dentry); - } + dentry = d_alloc_trylock(parent, &name); + if (IS_ERR(dentry)) + return PTR_ERR(dentry); + if (!d_in_lookup(dentry)) { struct fuse_inode *fi; inode = d_inode(dentry); |
