Commit cbae4d12 authored by Al Viro's avatar Al Viro

fold handle_mounts() into step_into()

The following is true:
	* calls of handle_mounts() and step_into() are always
paired in sequences like
	err = handle_mounts(nd, dentry, &path, &inode, &seq);
	if (unlikely(err < 0))
		return err;
	err = step_into(nd, &path, flags, inode, seq);
	* in all such sequences path is uninitialized before and
unused after this pair of calls
	* in all such sequences inode and seq are unused afterwards.

So the call of handle_mounts() can be shifted inside step_into(),
turning 'path' into a local variable in the combined function.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent aca2903e
...@@ -1835,29 +1835,33 @@ enum {WALK_FOLLOW = 1, WALK_MORE = 2, WALK_NOFOLLOW = 4}; ...@@ -1835,29 +1835,33 @@ enum {WALK_FOLLOW = 1, WALK_MORE = 2, WALK_NOFOLLOW = 4};
* so we keep a cache of "no, this doesn't need follow_link" * so we keep a cache of "no, this doesn't need follow_link"
* for the common case. * for the common case.
*/ */
static inline int step_into(struct nameidata *nd, struct path *path, static int step_into(struct nameidata *nd, int flags,
int flags, struct inode *inode, unsigned seq) struct dentry *dentry, struct inode *inode, unsigned seq)
{ {
if (likely(!d_is_symlink(path->dentry)) || struct path path;
int err = handle_mounts(nd, dentry, &path, &inode, &seq);
if (err < 0)
return err;
if (likely(!d_is_symlink(path.dentry)) ||
!((flags & WALK_FOLLOW) || (nd->flags & LOOKUP_FOLLOW)) || !((flags & WALK_FOLLOW) || (nd->flags & LOOKUP_FOLLOW)) ||
(flags & WALK_NOFOLLOW)) { (flags & WALK_NOFOLLOW)) {
/* not a symlink or should not follow */ /* not a symlink or should not follow */
path_to_nameidata(path, nd); path_to_nameidata(&path, nd);
nd->inode = inode; nd->inode = inode;
nd->seq = seq; nd->seq = seq;
return 0; return 0;
} }
/* make sure that d_is_symlink above matches inode */ /* make sure that d_is_symlink above matches inode */
if (nd->flags & LOOKUP_RCU) { if (nd->flags & LOOKUP_RCU) {
if (read_seqcount_retry(&path->dentry->d_seq, seq)) if (read_seqcount_retry(&path.dentry->d_seq, seq))
return -ECHILD; return -ECHILD;
} }
return pick_link(nd, path, inode, seq); return pick_link(nd, &path, inode, seq);
} }
static int walk_component(struct nameidata *nd, int flags) static int walk_component(struct nameidata *nd, int flags)
{ {
struct path path;
struct dentry *dentry; struct dentry *dentry;
struct inode *inode; struct inode *inode;
unsigned seq; unsigned seq;
...@@ -1883,11 +1887,7 @@ static int walk_component(struct nameidata *nd, int flags) ...@@ -1883,11 +1887,7 @@ static int walk_component(struct nameidata *nd, int flags)
} }
if (!(flags & WALK_MORE) && nd->depth) if (!(flags & WALK_MORE) && nd->depth)
put_link(nd); put_link(nd);
return step_into(nd, flags, dentry, inode, seq);
err = handle_mounts(nd, dentry, &path, &inode, &seq);
if (unlikely(err < 0))
return err;
return step_into(nd, &path, flags, inode, seq);
} }
/* /*
...@@ -2354,17 +2354,10 @@ static inline int lookup_last(struct nameidata *nd) ...@@ -2354,17 +2354,10 @@ static inline int lookup_last(struct nameidata *nd)
static int handle_lookup_down(struct nameidata *nd) static int handle_lookup_down(struct nameidata *nd)
{ {
struct path path;
struct inode *inode = nd->inode;
unsigned seq = nd->seq;
int err;
if (!(nd->flags & LOOKUP_RCU)) if (!(nd->flags & LOOKUP_RCU))
dget(nd->path.dentry); dget(nd->path.dentry);
err = handle_mounts(nd, nd->path.dentry, &path, &inode, &seq); return step_into(nd, WALK_NOFOLLOW,
if (unlikely(err < 0)) nd->path.dentry, nd->inode, nd->seq);
return err;
return step_into(nd, &path, WALK_NOFOLLOW, inode, seq);
} }
/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
...@@ -3281,7 +3274,6 @@ static int do_last(struct nameidata *nd, ...@@ -3281,7 +3274,6 @@ static int do_last(struct nameidata *nd,
int acc_mode = op->acc_mode; int acc_mode = op->acc_mode;
unsigned seq; unsigned seq;
struct inode *inode; struct inode *inode;
struct path path;
struct dentry *dentry; struct dentry *dentry;
int error; int error;
...@@ -3384,10 +3376,7 @@ static int do_last(struct nameidata *nd, ...@@ -3384,10 +3376,7 @@ static int do_last(struct nameidata *nd,
finish_lookup: finish_lookup:
if (nd->depth) if (nd->depth)
put_link(nd); put_link(nd);
error = handle_mounts(nd, dentry, &path, &inode, &seq); error = step_into(nd, 0, dentry, inode, seq);
if (unlikely(error < 0))
return error;
error = step_into(nd, &path, 0, inode, seq);
if (unlikely(error)) if (unlikely(error))
return error; return error;
......
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