Skip to content

Commit 81e6f52

Browse files
author
Al Viro
committed
untangling do_lookup() - take __lookup_hash()-calling case out of line.
Signed-off-by: Al Viro <[email protected]>
1 parent a325554 commit 81e6f52

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

fs/namei.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,22 +1208,14 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
12081208
dentry = __d_lookup(parent, name);
12091209
}
12101210

1211-
if (dentry && unlikely(d_need_lookup(dentry))) {
1211+
if (unlikely(!dentry))
1212+
goto need_lookup;
1213+
1214+
if (unlikely(d_need_lookup(dentry))) {
12121215
dput(dentry);
1213-
dentry = NULL;
1216+
goto need_lookup;
12141217
}
1215-
retry:
1216-
if (unlikely(!dentry)) {
1217-
struct inode *dir = parent->d_inode;
1218-
BUG_ON(nd->inode != dir);
12191218

1220-
mutex_lock(&dir->i_mutex);
1221-
dentry = __lookup_hash(name, parent, nd);
1222-
mutex_unlock(&dir->i_mutex);
1223-
if (IS_ERR(dentry))
1224-
return PTR_ERR(dentry);
1225-
goto done;
1226-
}
12271219
if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE) && need_reval)
12281220
status = d_revalidate(dentry, nd);
12291221
if (unlikely(status <= 0)) {
@@ -1233,8 +1225,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
12331225
}
12341226
if (!d_invalidate(dentry)) {
12351227
dput(dentry);
1236-
dentry = NULL;
1237-
goto retry;
1228+
goto need_lookup;
12381229
}
12391230
}
12401231
done:
@@ -1249,6 +1240,16 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
12491240
nd->flags |= LOOKUP_JUMPED;
12501241
*inode = path->dentry->d_inode;
12511242
return 0;
1243+
1244+
need_lookup:
1245+
BUG_ON(nd->inode != parent->d_inode);
1246+
1247+
mutex_lock(&parent->d_inode->i_mutex);
1248+
dentry = __lookup_hash(name, parent, nd);
1249+
mutex_unlock(&parent->d_inode->i_mutex);
1250+
if (IS_ERR(dentry))
1251+
return PTR_ERR(dentry);
1252+
goto done;
12521253
}
12531254

12541255
static inline int may_lookup(struct nameidata *nd)

0 commit comments

Comments
 (0)