[PATCH 5/5] afs: use d_duplicate()
NeilBrown
neilb at ownmail.net
Fri Sep 25 19:57:24 PDT 2026
From: NeilBrown <neil at brown.name>
To prepare for d_alloc_parallel() being permitted without a directory
lock, use d_duplicate() when duplicating a dentry in order to perform a
silly-rename. This creates on in-lookup dentry which will contine to block
concurrent lookups after the original dentry is silly-renamed, and until
the final rename happens.
As the resulting dentry is in-lookup, we need to call d_lookup_done()
before d_put().
Signed-off-by: NeilBrown <neil at brown.name>
---
fs/afs/dir.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index b8773adc4e3e..dfd1930e2282 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -2075,7 +2075,10 @@ static void afs_rename_put(struct afs_operation *op)
store_release_wake_up(&op->dentry->d_flags,
op->dentry->d_flags &~ DCACHE_BLOCKED);
spin_unlock(&op->dentry->d_lock);
- dput(op->rename.tmp);
+ if (op->rename.tmp) {
+ d_lookup_done(op->rename.tmp);
+ dput(op->rename.tmp);
+ }
}
static const struct afs_operation_ops afs_rename_operation = {
@@ -2213,8 +2216,7 @@ static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
if (d_count(new_dentry) > 2) {
spin_unlock(&new_dentry->d_lock);
/* copy the target dentry's name */
- op->rename.tmp = d_alloc(new_dentry->d_parent,
- &new_dentry->d_name);
+ op->rename.tmp = d_duplicate(new_dentry);
if (!op->rename.tmp) {
afs_op_nomem(op);
goto error;
--
2.50.0.107.gf914562f5916.dirty
More information about the linux-afs
mailing list