Re: [PATCH v3 105/110] namei: make unlazy_walk and terminate_walk handle nd->stack, add unlazy_link

From: Al Viro
Date: Fri May 15 2015 - 01:07:59 EST


On Tue, May 12, 2015 at 05:10:01AM +0100, Al Viro wrote:

> +static int unlazy_link(struct nameidata *nd, struct path *link, unsigned seq)
> +{
> + if (unlikely(!legitimize_path(nd, link, seq))) {
> + drop_links(nd);
> + rcu_read_unlock();
> + nd->flags &= ~LOOKUP_RCU;
> + nd->path.mnt = NULL;
> + nd->path.dentry = NULL;
> + if (!(nd->flags & LOOKUP_ROOT))
> + nd->root.mnt = NULL;

... and nd->depth should be set to 0, to avoid bogus path_put() on the
stuff in nd->stack[...].link when we get to terminate_walk(). Fixed and
folded.

> + } else if (likely(unlazy_walk(nd, NULL, 0)) == 0) {
> + return 0;
> + }
> + path_put(link);
> + return -ECHILD;
> +}
> +
> static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
> {
> return dentry->d_op->d_revalidate(dentry, flags);
> @@ -1537,20 +1613,6 @@ static inline int handle_dots(struct nameidata *nd, int type)
> return 0;
> }
>
> -static void terminate_walk(struct nameidata *nd)
> -{
> - if (!(nd->flags & LOOKUP_RCU)) {
> - path_put(&nd->path);
> - } else {
> - nd->flags &= ~LOOKUP_RCU;
> - if (!(nd->flags & LOOKUP_ROOT))
> - nd->root.mnt = NULL;
> - rcu_read_unlock();
> - }
> - while (unlikely(nd->depth))
> - put_link(nd);
> -}
> -
> static int pick_link(struct nameidata *nd, struct path *link,
> struct inode *inode, unsigned seq)
> {
> @@ -1561,13 +1623,12 @@ static int pick_link(struct nameidata *nd, struct path *link,
> return -ELOOP;
> }
> if (nd->flags & LOOKUP_RCU) {
> - if (unlikely(nd->path.mnt != link->mnt ||
> - unlazy_walk(nd, link->dentry, seq))) {
> + if (unlikely(unlazy_link(nd, link, seq)))
> return -ECHILD;
> - }
> + } else {
> + if (link->mnt == nd->path.mnt)
> + mntget(link->mnt);
> }
> - if (link->mnt == nd->path.mnt)
> - mntget(link->mnt);
> error = nd_alloc_stack(nd);
> if (unlikely(error)) {
> path_put(link);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/