Skip to content

Commit

Permalink
untangling do_lookup() - take __lookup_hash()-calling case out of line.
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Mar 31, 2012
1 parent a325554 commit 81e6f52
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,22 +1208,14 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
dentry = __d_lookup(parent, name);
}

if (dentry && unlikely(d_need_lookup(dentry))) {
if (unlikely(!dentry))
goto need_lookup;

if (unlikely(d_need_lookup(dentry))) {
dput(dentry);
dentry = NULL;
goto need_lookup;
}
retry:
if (unlikely(!dentry)) {
struct inode *dir = parent->d_inode;
BUG_ON(nd->inode != dir);

mutex_lock(&dir->i_mutex);
dentry = __lookup_hash(name, parent, nd);
mutex_unlock(&dir->i_mutex);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
goto done;
}
if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE) && need_reval)
status = d_revalidate(dentry, nd);
if (unlikely(status <= 0)) {
Expand All @@ -1233,8 +1225,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
}
if (!d_invalidate(dentry)) {
dput(dentry);
dentry = NULL;
goto retry;
goto need_lookup;
}
}
done:
Expand All @@ -1249,6 +1240,16 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
nd->flags |= LOOKUP_JUMPED;
*inode = path->dentry->d_inode;
return 0;

need_lookup:
BUG_ON(nd->inode != parent->d_inode);

mutex_lock(&parent->d_inode->i_mutex);
dentry = __lookup_hash(name, parent, nd);
mutex_unlock(&parent->d_inode->i_mutex);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
goto done;
}

static inline int may_lookup(struct nameidata *nd)
Expand Down

0 comments on commit 81e6f52

Please sign in to comment.