namei: change calling conventions for lookup_{fast,slow} and follow_managed()

Have lookup_fast() return 1 on success and 0 on "need to fall back";
lookup_slow() and follow_managed() return positive (1) on success.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2016-03-05 22:04:59 -05:00
parent 5d0f49c136
commit e9742b5332

View File

@ -1220,8 +1220,8 @@ static int follow_managed(struct path *path, struct nameidata *nd)
if (need_mntput && path->mnt == mnt) if (need_mntput && path->mnt == mnt)
mntput(path->mnt); mntput(path->mnt);
if (ret == -EISDIR) if (ret == -EISDIR || !ret)
ret = 0; ret = 1;
if (need_mntput) if (need_mntput)
nd->flags |= LOOKUP_JUMPED; nd->flags |= LOOKUP_JUMPED;
if (unlikely(ret < 0)) if (unlikely(ret < 0))
@ -1533,7 +1533,7 @@ static int lookup_fast(struct nameidata *nd,
if (unlikely(!dentry)) { if (unlikely(!dentry)) {
if (unlazy_walk(nd, NULL, 0)) if (unlazy_walk(nd, NULL, 0))
return -ECHILD; return -ECHILD;
return 1; return 0;
} }
/* /*
@ -1573,22 +1573,20 @@ static int lookup_fast(struct nameidata *nd,
path->mnt = mnt; path->mnt = mnt;
path->dentry = dentry; path->dentry = dentry;
if (likely(__follow_mount_rcu(nd, path, inode, seqp))) if (likely(__follow_mount_rcu(nd, path, inode, seqp)))
return 0; return 1;
if (unlazy_walk(nd, dentry, seq)) if (unlazy_walk(nd, dentry, seq))
return -ECHILD; return -ECHILD;
} }
} else { } else {
dentry = __d_lookup(parent, &nd->last); dentry = __d_lookup(parent, &nd->last);
if (unlikely(!dentry)) if (unlikely(!dentry))
return 1; return 0;
if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE))
status = d_revalidate(dentry, nd->flags); status = d_revalidate(dentry, nd->flags);
} }
if (unlikely(status <= 0)) { if (unlikely(status <= 0)) {
if (!status) { if (!status)
d_invalidate(dentry); d_invalidate(dentry);
status = 1;
}
dput(dentry); dput(dentry);
return status; return status;
} }
@ -1600,7 +1598,7 @@ static int lookup_fast(struct nameidata *nd,
path->mnt = mnt; path->mnt = mnt;
path->dentry = dentry; path->dentry = dentry;
err = follow_managed(path, nd); err = follow_managed(path, nd);
if (likely(!err)) if (likely(err > 0))
*inode = d_backing_inode(path->dentry); *inode = d_backing_inode(path->dentry);
return err; return err;
} }
@ -1724,7 +1722,7 @@ static int walk_component(struct nameidata *nd, int flags)
return err; return err;
} }
err = lookup_fast(nd, &path, &inode, &seq); err = lookup_fast(nd, &path, &inode, &seq);
if (unlikely(err)) { if (unlikely(err <= 0)) {
if (err < 0) if (err < 0)
return err; return err;
@ -3101,7 +3099,7 @@ static int do_last(struct nameidata *nd,
nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
/* we _can_ be in RCU mode here */ /* we _can_ be in RCU mode here */
error = lookup_fast(nd, &path, &inode, &seq); error = lookup_fast(nd, &path, &inode, &seq);
if (likely(!error)) if (likely(error > 0))
goto finish_lookup; goto finish_lookup;
if (error < 0) if (error < 0)