[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210528113951.6225-2-justin.he@arm.com>
Date: Fri, 28 May 2021 19:39:49 +0800
From: Jia He <justin.he@....com>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Jonathan Corbet <corbet@....net>,
Alexander Viro <viro@...iv.linux.org.uk>,
Luca Coelho <luciano.coelho@...el.com>,
Kalle Valo <kvalo@...eaurora.org>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>
Cc: Christian Borntraeger <borntraeger@...ibm.com>,
Johannes Berg <johannes.berg@...el.com>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
linux-s390@...r.kernel.org, Jia He <justin.he@....com>
Subject: [PATCH RFCv2 1/3] fs: introduce helper d_path_fast()
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 <justin.he@....com>
---
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
Powered by blists - more mailing lists