Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753926AbbEPEdA (ORCPT ); Sat, 16 May 2015 00:33:00 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:58928 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbbEPEc6 (ORCPT ); Sat, 16 May 2015 00:32:58 -0400 Date: Sat, 16 May 2015 05:31:47 +0100 From: Al Viro To: Linus Torvalds Cc: Dave Chinner , Andreas Dilger , NeilBrown , Christoph Hellwig , Linux Kernel Mailing List , linux-fsdevel Subject: Re: [RFC][PATCHSET v3] non-recursive pathname resolution & RCU symlinks Message-ID: <20150516043147.GR7232@ZenIV.linux.org.uk> References: <20150514112304.GT15721@dastard> <20150516093022.51e1464e@notabene.brown> <20150516112503.2f970573@notabene.brown> <20150516015540.GP7232@ZenIV.linux.org.uk> <20150516031647.GQ7232@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: 1921 Lines: 38 On Fri, May 15, 2015 at 08:37:20PM -0700, Linus Torvalds wrote: > On May 15, 2015 8:17 PM, "Al Viro" wrote: > > > > What for? All we need is a flag, waitqueue and being woken > > up when the flag gets cleared. > > You need to have the flag somewhere. > > The child dentry doesn't exist yet. > > That's the point of the hashed entry. It approximates the not-yet-existing > child dentry that we have *not* added to the parent until after lookup. Point, but... A lot of our problems comes from the fact that ->i_mutex doubles as protection against the addition to the list of children, on top of protection of directory itself. What if we do the following: have the normal case of __lookup_hash() (and other callers of lookup_real()) * allocate dentry, marked "in-lookup" * do dcache lookup, likely to come up empty, _without_ touching potential matches' d_lock, i.e. based on __d_lookup_rcu() (under rcu_read_lock(), with rename_lock loop around it). Hold parent's ->d_lock while walking the chain, grab refcount in the unlikely case the match had been found. If nothing's found *and* rename_lock hadn't been touched, insert the new dentry into hash and list of children before dropping ->d_lock. * call ->lookup() (still under ->i_mutex, shared) * clear "in-lookup" bit on _original_ dentry (we might very well have returned a different one) * kick the wait queue of parent's ->i_mutex I'll need to think about that after I get some sleep, but it smells like that could be feasible. Of course, that assumes we'll be able to cope with hashed-but-currently-in-lookup dentries, but I think it might be doable with some massage... -- 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/