提交 c2a8418d 编写于 作者: A Al Viro 提交者: sanglipeng

saner calling conventions for unlazy_child()

stable inclusion
from stable-v5.10.162
commit 36ec31201a3da85a112dd368be04aee05c713459
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7P7OH

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=36ec31201a3da85a112dd368be04aee05c713459

--------------------------------

[ Upstream commit ae66db45 ]

same as for the previous commit - instead of 0/-ECHILD make
it return true/false, rename to try_to_unlazy_child().
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 bc08878b
...@@ -719,19 +719,19 @@ static bool try_to_unlazy(struct nameidata *nd) ...@@ -719,19 +719,19 @@ static bool try_to_unlazy(struct nameidata *nd)
} }
/** /**
* unlazy_child - try to switch to ref-walk mode. * try_to_unlazy_next - try to switch to ref-walk mode.
* @nd: nameidata pathwalk data * @nd: nameidata pathwalk data
* @dentry: child of nd->path.dentry * @dentry: next dentry to step into
* @seq: seq number to check dentry against * @seq: seq number to check @dentry against
* Returns: 0 on success, -ECHILD on failure * Returns: true on success, false on failure
* *
* unlazy_child attempts to legitimize the current nd->path, nd->root and dentry * Similar to to try_to_unlazy(), but here we have the next dentry already
* for ref-walk mode. @dentry must be a path found by a do_lookup call on * picked by rcu-walk and want to legitimize that in addition to the current
* @nd. Must be called from rcu-walk context. * nd->path and nd->root for ref-walk mode. Must be called from rcu-walk context.
* Nothing should touch nameidata between unlazy_child() failure and * Nothing should touch nameidata between try_to_unlazy_next() failure and
* terminate_walk(). * terminate_walk().
*/ */
static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned seq) static bool try_to_unlazy_next(struct nameidata *nd, struct dentry *dentry, unsigned seq)
{ {
BUG_ON(!(nd->flags & LOOKUP_RCU)); BUG_ON(!(nd->flags & LOOKUP_RCU));
...@@ -761,7 +761,7 @@ static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned se ...@@ -761,7 +761,7 @@ static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned se
if (unlikely(!legitimize_root(nd))) if (unlikely(!legitimize_root(nd)))
goto out_dput; goto out_dput;
rcu_read_unlock(); rcu_read_unlock();
return 0; return true;
out2: out2:
nd->path.mnt = NULL; nd->path.mnt = NULL;
...@@ -769,11 +769,11 @@ static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned se ...@@ -769,11 +769,11 @@ static int unlazy_child(struct nameidata *nd, struct dentry *dentry, unsigned se
nd->path.dentry = NULL; nd->path.dentry = NULL;
out: out:
rcu_read_unlock(); rcu_read_unlock();
return -ECHILD; return false;
out_dput: out_dput:
rcu_read_unlock(); rcu_read_unlock();
dput(dentry); dput(dentry);
return -ECHILD; return false;
} }
static inline int d_revalidate(struct dentry *dentry, unsigned int flags) static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
...@@ -1390,7 +1390,7 @@ static inline int handle_mounts(struct nameidata *nd, struct dentry *dentry, ...@@ -1390,7 +1390,7 @@ static inline int handle_mounts(struct nameidata *nd, struct dentry *dentry,
return -ENOENT; return -ENOENT;
if (likely(__follow_mount_rcu(nd, path, inode, seqp))) if (likely(__follow_mount_rcu(nd, path, inode, seqp)))
return 0; return 0;
if (unlazy_child(nd, dentry, seq)) if (!try_to_unlazy_next(nd, dentry, seq))
return -ECHILD; return -ECHILD;
// *path might've been clobbered by __follow_mount_rcu() // *path might've been clobbered by __follow_mount_rcu()
path->mnt = nd->path.mnt; path->mnt = nd->path.mnt;
...@@ -1511,7 +1511,7 @@ static struct dentry *lookup_fast(struct nameidata *nd, ...@@ -1511,7 +1511,7 @@ static struct dentry *lookup_fast(struct nameidata *nd,
status = d_revalidate(dentry, nd->flags); status = d_revalidate(dentry, nd->flags);
if (likely(status > 0)) if (likely(status > 0))
return dentry; return dentry;
if (unlazy_child(nd, dentry, seq)) if (!try_to_unlazy_next(nd, dentry, seq))
return ERR_PTR(-ECHILD); return ERR_PTR(-ECHILD);
if (unlikely(status == -ECHILD)) if (unlikely(status == -ECHILD))
/* we'd been told to redo it in non-rcu mode */ /* we'd been told to redo it in non-rcu mode */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册