Skip to content

Commit e9742b5

Browse files
author
Al Viro
committed
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>
1 parent 5d0f49c commit e9742b5

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

fs/namei.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,8 @@ static int follow_managed(struct path *path, struct nameidata *nd)
12201220

12211221
if (need_mntput && path->mnt == mnt)
12221222
mntput(path->mnt);
1223-
if (ret == -EISDIR)
1224-
ret = 0;
1223+
if (ret == -EISDIR || !ret)
1224+
ret = 1;
12251225
if (need_mntput)
12261226
nd->flags |= LOOKUP_JUMPED;
12271227
if (unlikely(ret < 0))
@@ -1533,7 +1533,7 @@ static int lookup_fast(struct nameidata *nd,
15331533
if (unlikely(!dentry)) {
15341534
if (unlazy_walk(nd, NULL, 0))
15351535
return -ECHILD;
1536-
return 1;
1536+
return 0;
15371537
}
15381538

15391539
/*
@@ -1573,22 +1573,20 @@ static int lookup_fast(struct nameidata *nd,
15731573
path->mnt = mnt;
15741574
path->dentry = dentry;
15751575
if (likely(__follow_mount_rcu(nd, path, inode, seqp)))
1576-
return 0;
1576+
return 1;
15771577
if (unlazy_walk(nd, dentry, seq))
15781578
return -ECHILD;
15791579
}
15801580
} else {
15811581
dentry = __d_lookup(parent, &nd->last);
15821582
if (unlikely(!dentry))
1583-
return 1;
1583+
return 0;
15841584
if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE))
15851585
status = d_revalidate(dentry, nd->flags);
15861586
}
15871587
if (unlikely(status <= 0)) {
1588-
if (!status) {
1588+
if (!status)
15891589
d_invalidate(dentry);
1590-
status = 1;
1591-
}
15921590
dput(dentry);
15931591
return status;
15941592
}
@@ -1600,7 +1598,7 @@ static int lookup_fast(struct nameidata *nd,
16001598
path->mnt = mnt;
16011599
path->dentry = dentry;
16021600
err = follow_managed(path, nd);
1603-
if (likely(!err))
1601+
if (likely(err > 0))
16041602
*inode = d_backing_inode(path->dentry);
16051603
return err;
16061604
}
@@ -1724,7 +1722,7 @@ static int walk_component(struct nameidata *nd, int flags)
17241722
return err;
17251723
}
17261724
err = lookup_fast(nd, &path, &inode, &seq);
1727-
if (unlikely(err)) {
1725+
if (unlikely(err <= 0)) {
17281726
if (err < 0)
17291727
return err;
17301728

@@ -3101,7 +3099,7 @@ static int do_last(struct nameidata *nd,
31013099
nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
31023100
/* we _can_ be in RCU mode here */
31033101
error = lookup_fast(nd, &path, &inode, &seq);
3104-
if (likely(!error))
3102+
if (likely(error > 0))
31053103
goto finish_lookup;
31063104

31073105
if (error < 0)

0 commit comments

Comments
 (0)