From b4b559ac0526f5c09682735c1da78d297a4b79a7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 27 Jan 2026 15:19:06 -0500 Subject: [PATCH 1/6] tracefs: use d_splice_alias() in ->lookup() instances d_add() is not wrong there (inodes are freshly allocated), but d_splice_alias() is more idiomatic. Signed-off-by: Al Viro --- fs/tracefs/event_inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 26b6453de30e..39c7a34531e8 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -389,8 +389,7 @@ static struct dentry *lookup_file(struct eventfs_inode *parent_ei, // Files have their parent's ei as their fsdata dentry->d_fsdata = get_ei(parent_ei); - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); }; /** @@ -420,8 +419,7 @@ static struct dentry *lookup_dir_entry(struct dentry *dentry, dentry->d_fsdata = get_ei(ei); - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } static inline struct eventfs_inode *init_ei(struct eventfs_inode *ei, const char *name) From 0c23a964a0f9ce92f65e04c77b86437fbaeb229a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 8 May 2026 17:58:35 -0400 Subject: [PATCH 2/6] configfs_lookup(): switch to d_splice_alias() more idiomatic Signed-off-by: Al Viro --- fs/configfs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 362b6ff9b908..cd65a69765ea 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -501,8 +501,7 @@ static struct dentry * configfs_lookup(struct inode *dir, } spin_unlock(&configfs_dirent_lock); done: - d_add(dentry, inode); - return NULL; + return d_splice_alias(inode, dentry); } /* From 79b0c7204b04e6786b12fcdc3fd1c22cbabe5734 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 9 May 2026 12:28:48 -0400 Subject: [PATCH 3/6] ecryptfs: use d_splice_alias() for ->lookup() return value Signed-off-by: Al Viro --- fs/ecryptfs/inode.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 546c1fe692c0..7aaf1913f9c6 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -350,11 +350,9 @@ static struct dentry *ecryptfs_lookup_interpose(struct dentry *dentry, */ lower_inode = READ_ONCE(lower_dentry->d_inode); - if (!lower_inode) { - /* We want to add because we couldn't find in lower */ - d_add(dentry, NULL); - return NULL; - } + if (!lower_inode) /* We want to add because we couldn't find in lower */ + return d_splice_alias(NULL, dentry); + inode = __ecryptfs_get_inode(lower_inode, dentry->d_sb); if (IS_ERR(inode)) { printk(KERN_ERR "%s: Error interposing; rc = [%ld]\n", From a6247aad26d687d9b42a924fbed874a3e3e4d00d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 9 May 2026 12:29:41 -0400 Subject: [PATCH 4/6] simple_lookup(): use d_splice_alias() for ->lookup() return value Signed-off-by: Al Viro --- fs/libfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 1bbea5e7bae3..d6205ea61afa 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -78,8 +78,7 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) return NULL; - d_add(dentry, NULL); - return NULL; + return d_splice_alias(NULL, dentry); } EXPORT_SYMBOL(simple_lookup); From 02975a536d4b1bb304c6c7e35ce0c861566c7af8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 9 May 2026 12:30:19 -0400 Subject: [PATCH 5/6] ntfs: use d_splice_alias() for ->lookup() return value Reviewed-by: Namjae Jeon Signed-off-by: Al Viro --- fs/ntfs/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c index c4f82846c58c..3e21753b9f88 100644 --- a/fs/ntfs/namei.c +++ b/fs/ntfs/namei.c @@ -230,9 +230,8 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, if (MREF_ERR(mref) == -ENOENT) { ntfs_debug("Entry was not found, adding negative dentry."); /* The dcache will handle negative entries. */ - d_add(dent, NULL); ntfs_debug("Done."); - return NULL; + return d_splice_alias(NULL, dent); } ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() failed with error code %i.", -MREF_ERR(mref)); From 2555ac7a450bf11f8e461ce6cd0f62613734a796 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 9 May 2026 12:31:57 -0400 Subject: [PATCH 6/6] gfs2: use d_splice_alias() for ->lookup() return value Reviewed-by: Andreas Gruenbacher Signed-off-by: Al Viro --- fs/gfs2/inode.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index e9bf4879c07f..6a3581e3ba93 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -987,12 +987,8 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry, int error; inode = gfs2_lookupi(dir, &dentry->d_name, 0); - if (inode == NULL) { - d_add(dentry, NULL); - return NULL; - } - if (IS_ERR(inode)) - return ERR_CAST(inode); + if (inode == NULL || IS_ERR(inode)) + return d_splice_alias(inode, dentry); gl = GFS2_I(inode)->i_gl; error = gfs2_glock_nq_init(gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);