Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752576AbbEOFHs (ORCPT ); Fri, 15 May 2015 01:07:48 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:54012 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbbEOFHp (ORCPT ); Fri, 15 May 2015 01:07:45 -0400 Date: Fri, 15 May 2015 06:07:20 +0100 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3 105/110] namei: make unlazy_walk and terminate_walk handle nd->stack, add unlazy_link Message-ID: <20150515050720.GA1127@ZenIV.linux.org.uk> References: <20150511180650.GA4147@ZenIV.linux.org.uk> <1431367690-5223-105-git-send-email-viro@ZenIV.linux.org.uk> <20150511234333.GA7232@ZenIV.linux.org.uk> <20150512041001.GB7232@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150512041001.GB7232@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2341 Lines: 75 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@vger.kernel.org > 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/