Skip to content

Commit

Permalink
untangling do_lookup() - eliminate a loop.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro committed Mar 31, 2012
1 parent 37c17e1 commit acc9cb3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,6 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
BUG_ON(nd->inode != dir);

mutex_lock(&dir->i_mutex);
l:
dentry = d_lookup(parent, name);
if (likely(!dentry)) {
dentry = d_alloc_and_lookup(parent, name, nd);
Expand Down Expand Up @@ -1204,9 +1203,14 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
}
if (!d_invalidate(dentry)) {
dput(dentry);
dentry = NULL;
need_reval = 1;
goto l;
dentry = d_alloc_and_lookup(parent, name, nd);
if (IS_ERR(dentry)) {
mutex_unlock(&dir->i_mutex);
return PTR_ERR(dentry);
}
/* known good */
need_reval = 0;
status = 1;
}
}
mutex_unlock(&dir->i_mutex);
Expand Down

0 comments on commit acc9cb3

Please sign in to comment.