summaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorMateusz Guzik <mjguzik@gmail.com>2024-06-27 18:11:52 +0200
committerChristian Brauner <brauner@kernel.org>2024-06-27 18:34:21 +0200
commitf378ec4eec8b7e607dbc0112913fd3d5d84eb1b8 (patch)
tree45570ee52d656a075d9b8b1ee2b2379f58e49648 /fs/dcache.c
parent0ef625bba6fb2bc0c8ed2aab9524fdf423f67dd5 (diff)
downloadlinux-f378ec4eec8b7e607dbc0112913fd3d5d84eb1b8.tar.gz
linux-f378ec4eec8b7e607dbc0112913fd3d5d84eb1b8.tar.bz2
linux-f378ec4eec8b7e607dbc0112913fd3d5d84eb1b8.zip
vfs: rename parent_ino to d_parent_ino and make it use RCU
The routine is used by procfs through dir_emit_dots. The combined RCU and lock fallback implementation is too big for an inline. Given that the routine takes a dentry argument fs/dcache.c seems like the place to put it in. Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Link: https://lore.kernel.org/r/20240627161152.802567-1-mjguzik@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 58b89c9e9b0c..68e843e78337 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3099,6 +3099,34 @@ void d_tmpfile(struct file *file, struct inode *inode)
}
EXPORT_SYMBOL(d_tmpfile);
+/*
+ * Obtain inode number of the parent dentry.
+ */
+ino_t d_parent_ino(struct dentry *dentry)
+{
+ struct dentry *parent;
+ struct inode *iparent;
+ unsigned seq;
+ ino_t ret;
+
+ scoped_guard(rcu) {
+ seq = raw_seqcount_begin(&dentry->d_seq);
+ parent = READ_ONCE(dentry->d_parent);
+ iparent = d_inode_rcu(parent);
+ if (likely(iparent)) {
+ ret = iparent->i_ino;
+ if (!read_seqcount_retry(&dentry->d_seq, seq))
+ return ret;
+ }
+ }
+
+ spin_lock(&dentry->d_lock);
+ ret = dentry->d_parent->d_inode->i_ino;
+ spin_unlock(&dentry->d_lock);
+ return ret;
+}
+EXPORT_SYMBOL(d_parent_ino);
+
static __initdata unsigned long dhash_entries;
static int __init set_dhash_entries(char *str)
{