From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH v7 1/4] spinlock: A new lockref structure for lockless update of refcount Date: Mon, 9 Sep 2013 01:35:17 +0100 Message-ID: <20130909003517.GJ13318@ZenIV.linux.org.uk> References: <1375758759-29629-2-git-send-email-Waiman.Long@hp.com> <1377751465.4028.20.camel@pasglop> <20130829070012.GC27322@gmail.com> <20130909000300.GH13318@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Ingo Molnar , Benjamin Herrenschmidt , Waiman Long , Jeff Layton , Miklos Szeredi , Ingo Molnar , Thomas Gleixner , linux-fsdevel , Linux Kernel Mailing List , Peter Zijlstra , Steven Rostedt , Andi Kleen , "Chandramouleeswaran, Aswin" , "Norton, Scott J" To: Linus Torvalds Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, Sep 08, 2013 at 05:25:40PM -0700, Linus Torvalds wrote: > On Sun, Sep 8, 2013 at 5:03 PM, Al Viro wrote: > > > > Well... unlazy_walk() is always followed by terminate_walk() very shortly, > > but there's a minor problem - terminate_walk() uses "are we in RCU > > mode?" for two things: > > a) do we need to do path_put() here? > > b) do we need to unlock? > > If you introduce the third case ("no need to do unlock and no need to > > do path_put()"), we'd better decide how to check for that case... > > Actually, I decided to take advantage of those two cases instead, and > I have a patch that I think does the right thing. Basically, I start > off unlazy_walk() with just doing that lockref_get_not_dead() on the > parent dentry, and if that fails I just return an error in RCU mode > (so terminate_walk() does what it always used to do, and we haven't > done anything else to any refcounts). > > Now, if the lockref_get_not_dead() succeeded, that means that we have > a reference on the nd->path.dentry, and we can now just do > "mntget(nd->path.mnt);". Ta-Daa! We now have everything done for the > non-RCU case for terminate_walk(). > > So after that point, we clear LOOKUP_RCU, and make the rule be that > any return (error or success) has to do unlock_rcu_walk(). And then > all the other refcounts are easy, we can just "dput(dentry);" after > that. > > I haven't tested it yet, I was going to reboot into it just now. But > I'm attaching the patch here. Maybe I missed some detail, but it all > seems simpler. > > Note that this patch requires the "lockref_get_not_dead()" cleanup at > the top of my current -git. That should also work, replacing the current tip of #for-next. Do you prefer to merge those two diffs of yours into a single commit?