Commit f1085b25 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] reduce stack use in altroot handling

Massaged altroot handling to avoid on-stack struct nameidata instance (and
got it faster, actually).  We are in the middle of do_follow_link() recursion
here, so the stack footprint is critical.
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a4d2a829
...@@ -868,29 +868,31 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd) ...@@ -868,29 +868,31 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
return 0; /* something went wrong... */ return 0; /* something went wrong... */
if (!nd->dentry->d_inode || S_ISDIR(nd->dentry->d_inode->i_mode)) { if (!nd->dentry->d_inode || S_ISDIR(nd->dentry->d_inode->i_mode)) {
struct nameidata nd_root; struct dentry *old_dentry = nd->dentry;
struct vfsmount *old_mnt = nd->mnt;
struct qstr last = nd->last;
int last_type = nd->last_type;
/* /*
* NAME was not found in alternate root or it's a directory. Try to find * NAME was not found in alternate root or it's a directory. Try to find
* it in the normal root: * it in the normal root:
*/ */
nd_root.last_type = LAST_ROOT; nd->last_type = LAST_ROOT;
nd_root.flags = nd->flags;
nd_root.depth = 0;
memcpy(&nd_root.intent, &nd->intent, sizeof(nd_root.intent));
read_lock(&current->fs->lock); read_lock(&current->fs->lock);
nd_root.mnt = mntget(current->fs->rootmnt); nd->mnt = mntget(current->fs->rootmnt);
nd_root.dentry = dget(current->fs->root); nd->dentry = dget(current->fs->root);
read_unlock(&current->fs->lock); read_unlock(&current->fs->lock);
if (path_walk(name, &nd_root)) if (path_walk(name, nd) == 0) {
return 1; if (nd->dentry->d_inode) {
if (nd_root.dentry->d_inode) { dput(old_dentry);
mntput(old_mnt);
return 1;
}
path_release(nd); path_release(nd);
nd->dentry = nd_root.dentry;
nd->mnt = nd_root.mnt;
nd->last = nd_root.last;
return 1;
} }
path_release(&nd_root); nd->dentry = old_dentry;
nd->mnt = old_mnt;
nd->last = last;
nd->last_type = last_type;
} }
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment