[PATCH v4 6/8] afs: use d_duplicate()
From: NeilBrown
Date: Sun Nov 29 2026 - 16:34:22 EST
From: NeilBrown <neil@xxxxxxxxxx>
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@xxxxxxxxxx>
---
fs/afs/dir.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index aa0d83f7ecf1..b40e02143224 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -2069,7 +2069,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 = {
@@ -2199,10 +2202,10 @@ static int afs_rename(const 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);
- if (!op->rename.tmp) {
+ op->rename.tmp = d_duplicate(new_dentry);
+ if (IS_ERR(op->rename.tmp)) {
afs_op_nomem(op);
+ op->rename.tmp = NULL;
goto error;
}
--
2.50.0.107.gf914562f5916.dirty