summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-06-15 01:51:00 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2026-06-15 01:51:00 +0300
commit8ab34af09f292ca9620dad8df253fec766729b29 (patch)
tree86e19444f0633efc34c2131ded68ed1db87d9bff
parente8a56d6fc828bb569fa2dd33c3e6eb16a165b097 (diff)
parent2555ac7a450bf11f8e461ce6cd0f62613734a796 (diff)
downloadlinux-8ab34af09f292ca9620dad8df253fec766729b29.tar.xz
Merge tag 'pull-d_add' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull dentry d_add() cleanups from Al Viro: "This converts a bunch of unidiomatic uses of d_add() in ->lookup() instances to equivalent uses of d_splice_alias(), which is the normal mechanism for ->lookup()" * tag 'pull-d_add' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: gfs2: use d_splice_alias() for ->lookup() return value ntfs: use d_splice_alias() for ->lookup() return value simple_lookup(): use d_splice_alias() for ->lookup() return value ecryptfs: use d_splice_alias() for ->lookup() return value configfs_lookup(): switch to d_splice_alias() tracefs: use d_splice_alias() in ->lookup() instances
-rw-r--r--fs/configfs/dir.c3
-rw-r--r--fs/ecryptfs/inode.c8
-rw-r--r--fs/gfs2/inode.c8
-rw-r--r--fs/libfs.c3
-rw-r--r--fs/ntfs/namei.c3
-rw-r--r--fs/tracefs/event_inode.c6
6 files changed, 10 insertions, 21 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);
}
/*
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",
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index e9895dea0da4..8a77794bbd4a 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -994,12 +994,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);
diff --git a/fs/libfs.c b/fs/libfs.c
index 124139645f7f..5a0d276379d1 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);
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));
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)