[PATCH v3 12/19] shmem: use d_duplicate()

NeilBrown
2026-04-27T04:07:37Z

To prepare for d_alloc_parallel() being permitted without a directory
lock, use d_duplicate() when duplicating a dentry in order to create a
whiteout.

Signed-off-by: NeilBrown <neil@brown.name>
---
mm/shmem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 3b5dc21b323c..8b0d2340dee7 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4006,11 +4006,12 @@ static int shmem_whiteout(struct mnt_idmap *idmap,
struct dentry *whiteout;
int error;

- whiteout = d_alloc(old_dentry->d_parent, &old_dentry->d_name);
+ whiteout = d_duplicate(old_dentry);
if (!whiteout)
return -ENOMEM;
error = shmem_mknod(idmap, old_dir, whiteout,
S_IFCHR | WHITEOUT_MODE, WHITEOUT_DEV);
+ d_lookup_done(whiteout);
dput(whiteout);
return error;
}
--
2.50.0.107.gf914562f5916.dirty