Skip to content

Commit

Permalink
fs: introduce helper d_path_fast()
Browse files Browse the repository at this point in the history
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@arm.com>
  • Loading branch information
justin-he authored and intel-lab-lkp committed May 28, 2021
1 parent dd86005 commit b51dc22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions fs/d_path.c
Expand Up @@ -291,6 +291,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
*/
Expand Down
1 change: 1 addition & 0 deletions include/linux/dcache.h
Expand Up @@ -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);

Expand Down

0 comments on commit b51dc22

Please sign in to comment.