提交 40107f78 编写于 作者: A Al Viro 提交者: Joseph Qi

fs/namei.c: new helper - legitimize_root()

to #26323588

commit ee594bfff389aa9105f713135211c0da736e5698 upstream.

identical logics in unlazy_walk() and unlazy_child()
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 38549ac1
...@@ -643,6 +643,13 @@ static bool legitimize_links(struct nameidata *nd) ...@@ -643,6 +643,13 @@ static bool legitimize_links(struct nameidata *nd)
return true; return true;
} }
static bool legitimize_root(struct nameidata *nd)
{
if (!nd->root.mnt || (nd->flags & LOOKUP_ROOT))
return true;
return legitimize_path(nd, &nd->root, nd->root_seq);
}
/* /*
* Path walking has 2 modes, rcu-walk and ref-walk (see * Path walking has 2 modes, rcu-walk and ref-walk (see
* Documentation/filesystems/path-lookup.txt). In situations when we can't * Documentation/filesystems/path-lookup.txt). In situations when we can't
...@@ -676,10 +683,8 @@ static int unlazy_walk(struct nameidata *nd) ...@@ -676,10 +683,8 @@ static int unlazy_walk(struct nameidata *nd)
goto out2; goto out2;
if (unlikely(!legitimize_path(nd, &nd->path, nd->seq))) if (unlikely(!legitimize_path(nd, &nd->path, nd->seq)))
goto out1; goto out1;
if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { if (unlikely(!legitimize_root(nd)))
if (unlikely(!legitimize_path(nd, &nd->root, nd->root_seq))) goto out;
goto out;
}
rcu_read_unlock(); rcu_read_unlock();
BUG_ON(nd->inode != parent->d_inode); BUG_ON(nd->inode != parent->d_inode);
return 0; return 0;
...@@ -738,12 +743,10 @@ static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned se ...@@ -738,12 +743,10 @@ static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned se
* Sequence counts matched. Now make sure that the root is * Sequence counts matched. Now make sure that the root is
* still valid and get it if required. * still valid and get it if required.
*/ */
if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { if (unlikely(!legitimize_root(nd))) {
if (unlikely(!legitimize_path(nd, &nd->root, nd->root_seq))) { rcu_read_unlock();
rcu_read_unlock(); dput(dentry);
dput(dentry); return -ECHILD;
return -ECHILD;
}
} }
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册