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@xxxxxxx> --- 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