Skip to content

Commit acc9cb3

Browse files
author
Al Viro
committed
untangling do_lookup() - eliminate a loop.
d_lookup() *will* fail after successful d_invalidate(), if we are holding i_mutex all along. IOW, we don't need to jump back to l: - we know what path will be taken there and can do that (i.e. d_alloc_and_lookup()) directly. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 37c17e1 commit acc9cb3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/namei.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,6 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
11731173
BUG_ON(nd->inode != dir);
11741174

11751175
mutex_lock(&dir->i_mutex);
1176-
l:
11771176
dentry = d_lookup(parent, name);
11781177
if (likely(!dentry)) {
11791178
dentry = d_alloc_and_lookup(parent, name, nd);
@@ -1204,9 +1203,14 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
12041203
}
12051204
if (!d_invalidate(dentry)) {
12061205
dput(dentry);
1207-
dentry = NULL;
1208-
need_reval = 1;
1209-
goto l;
1206+
dentry = d_alloc_and_lookup(parent, name, nd);
1207+
if (IS_ERR(dentry)) {
1208+
mutex_unlock(&dir->i_mutex);
1209+
return PTR_ERR(dentry);
1210+
}
1211+
/* known good */
1212+
need_reval = 0;
1213+
status = 1;
12101214
}
12111215
}
12121216
mutex_unlock(&dir->i_mutex);

0 commit comments

Comments
 (0)