提交 acc9cb3c 编写于 作者: A Al Viro

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: NAl Viro <viro@zeniv.linux.org.uk>
上级 37c17e1f
...@@ -1173,7 +1173,6 @@ static int do_lookup(struct nameidata *nd, struct qstr *name, ...@@ -1173,7 +1173,6 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
BUG_ON(nd->inode != dir); BUG_ON(nd->inode != dir);
mutex_lock(&dir->i_mutex); mutex_lock(&dir->i_mutex);
l:
dentry = d_lookup(parent, name); dentry = d_lookup(parent, name);
if (likely(!dentry)) { if (likely(!dentry)) {
dentry = d_alloc_and_lookup(parent, name, nd); dentry = d_alloc_and_lookup(parent, name, nd);
...@@ -1204,9 +1203,14 @@ static int do_lookup(struct nameidata *nd, struct qstr *name, ...@@ -1204,9 +1203,14 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
} }
if (!d_invalidate(dentry)) { if (!d_invalidate(dentry)) {
dput(dentry); dput(dentry);
dentry = NULL; dentry = d_alloc_and_lookup(parent, name, nd);
need_reval = 1; if (IS_ERR(dentry)) {
goto l; mutex_unlock(&dir->i_mutex);
return PTR_ERR(dentry);
}
/* known good */
need_reval = 0;
status = 1;
} }
} }
mutex_unlock(&dir->i_mutex); mutex_unlock(&dir->i_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册