Thread (25 messages) 25 messages, 6 authors, 2021-06-02

[PATCH RFCv2 1/3] fs: introduce helper d_path_fast()

flat view
STALE1972d SUPERSEDED

From: Jia He <hidden>
Date: 2021-05-28 11:40:23
Also in: linux-doc, linux-s390, linux-wireless, lkml
Subsystem: filesystems (vfs and infrastructure), the rest · Maintainers: Alexander Viro, Christian Brauner, Linus Torvalds

Status: Superseded by v4 (posted 2021-06-15). [go to v4]

Revision v2 (4 revisions archived).

Revisions (4)
  1. rfc
  2. v2 current [diff against previous]
  3. v3 [diff against previous]
  4. v4 [diff against previous]
This helper is similar to d_path except that it doesn't take any
seqlock/spinlock. It is typical for debugging purpose.

Signed-off-by: Jia He <redacted>
---
 fs/d_path.c            | 21 +++++++++++++++++++++
 include/linux/dcache.h |  1 +
 2 files changed, 22 insertions(+)
diff --git a/fs/d_path.c b/fs/d_path.c
index 23a53f7b5c71..f9df68d62786 100644
--- a/fs/d_path.c
+++ b/fs/d_path.c
@@ -263,6 +263,27 @@ char *d_path(const struct path *path, char *buf, int buflen)
 }
 EXPORT_SYMBOL(d_path);
 
+/**
+ * d_path_fast - fast return the full path of a dentry without taking
+ * any seqlock/spinlock. This helper is typical for debugging purpose
+ */
+char *d_path_fast(const struct path *path, char *buf, int buflen)
+{
+	struct path root;
+	struct mount *mnt = real_mount(path->mnt);
+	DECLARE_BUFFER(b, buf, buflen);
+
+	rcu_read_lock();
+	get_fs_root_rcu(current->fs, &root);
+
+	prepend(&b, "", 1);
+	__prepend_path(path->dentry, mnt, &root, &b);
+	rcu_read_unlock();
+
+	return extract_string(&b);
+}
+EXPORT_SYMBOL(d_path_fast);
+
 /*
  * Helper function for dentry_operations.d_dname() members
  */
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 9e23d33bb6f1..c4483fc887a5 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -301,6 +301,7 @@ char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
 extern char *__d_path(const struct path *, const struct path *, char *, int);
 extern char *d_absolute_path(const struct path *, char *, int);
 extern char *d_path(const struct path *, char *, int);
+extern char *d_path_fast(const struct path *, char *, int);
 extern char *dentry_path_raw(const struct dentry *, char *, int);
 extern char *dentry_path(const struct dentry *, char *, int);
 
-- 
2.17.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help