mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-10 15:19:51 +00:00
kernfs: make kernfs_walk_ns() use kernfs_pr_cont_buf[]
kernfs_walk_ns() uses a static path_buf[PATH_MAX] to separate out path components. Keeping around the 4k buffer just for kernfs_walk_ns() is wasteful. This patch makes it piggyback on kernfs_pr_cont_buf[] instead. This requires kernfs_walk_ns() to hold kernfs_rename_lock. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
388f7b1d6e
commit
e56ed358af
@ -691,15 +691,22 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
|
|||||||
const unsigned char *path,
|
const unsigned char *path,
|
||||||
const void *ns)
|
const void *ns)
|
||||||
{
|
{
|
||||||
static char path_buf[PATH_MAX]; /* protected by kernfs_mutex */
|
size_t len;
|
||||||
size_t len = strlcpy(path_buf, path, PATH_MAX);
|
char *p, *name;
|
||||||
char *p = path_buf;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
lockdep_assert_held(&kernfs_mutex);
|
lockdep_assert_held(&kernfs_mutex);
|
||||||
|
|
||||||
if (len >= PATH_MAX)
|
/* grab kernfs_rename_lock to piggy back on kernfs_pr_cont_buf */
|
||||||
|
spin_lock_irq(&kernfs_rename_lock);
|
||||||
|
|
||||||
|
len = strlcpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));
|
||||||
|
|
||||||
|
if (len >= sizeof(kernfs_pr_cont_buf)) {
|
||||||
|
spin_unlock_irq(&kernfs_rename_lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = kernfs_pr_cont_buf;
|
||||||
|
|
||||||
while ((name = strsep(&p, "/")) && parent) {
|
while ((name = strsep(&p, "/")) && parent) {
|
||||||
if (*name == '\0')
|
if (*name == '\0')
|
||||||
@ -707,6 +714,8 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
|
|||||||
parent = kernfs_find_ns(parent, name, ns);
|
parent = kernfs_find_ns(parent, name, ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spin_unlock_irq(&kernfs_rename_lock);
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user