Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756520AbbDWFBM (ORCPT ); Thu, 23 Apr 2015 01:01:12 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:47130 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751430AbbDWFBK (ORCPT ); Thu, 23 Apr 2015 01:01:10 -0400 Date: Thu, 23 Apr 2015 06:01:03 +0100 From: Al Viro To: NeilBrown Cc: Christoph Hellwig , Linus Torvalds , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC][PATCHSET] non-recursive link_path_walk() and reducing stack footprint Message-ID: <20150423050103.GZ889@ZenIV.linux.org.uk> References: <20150420181222.GK889@ZenIV.linux.org.uk> <20150421144959.GR889@ZenIV.linux.org.uk> <20150421150408.GA29838@infradead.org> <553668C1.8030707@nod.at> <20150421154504.GT889@ZenIV.linux.org.uk> <20150421212007.GU889@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150421212007.GU889@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: 2603 Lines: 45 On Tue, Apr 21, 2015 at 10:20:07PM +0100, Al Viro wrote: > I agree that unlazy_walk() attempted when walking a symlink ought to fail > with -ECHILD; we can't legitimize the symlink itself, so once we are out > of RCU mode, there's nothing to hold the inode of symlink (and its body) > from getting freed. Solution is wrong though; for example, when > nested symlink occurs in the middle of a trailing one, we should *not* > remove the flag upon leaving the nested symlink. > > Another unpleasant thing is that ->follow_link() saying "can't do that in > RCU mode" ends up with restart from scratch - that actually risks to be > worse than the mainline; there we would attempt unlazy_walk() and normally > it would've succeed. > > AFAICS, the real rule is "can't unlazy if nd->last.name points into a symlink > body and we might still need to access it"... Actually, I'm not sure anymore. What if we have unlazy_walk() legitimize all the symlinks we are traversing? They are visible in nd->stack, after all... It would mean more complex unlazy_walk(), but not terribly so - succeeding legitimize_mnt() won't block and we already deal with the possibility of having vfsmount legitimized, only to be dropped afterwards. The real unpleasantness here is different - it's the need to keep ->d_seq of those dentries to tell if they can be grabbed. That's 4 more bytes per level plus the fun with alignment. OTOH, it both avoids the fun with getting the logics of when to bail out right *and* avoids the guaranteed restarts when running into a symlink we can't deal with in RCU mode - we could simply unlazy and continue in such a situation. Hell knows... it probably means going all the way wrt dynamic (on demand) allocation, though. Say it, keeping a couple of levels on stack and allocating when we need more; the interesting part is in not freeing that sucker too early. At the very least, we don't want the progression through RCU/normal/ revalidate-everything modes to trigger allocation/freeing on each step; the nesting depth is going to be the same every time. That's not hard to do... I'm about to fall asleep right now, so all of the above might very well be complete hogwash; I'll look into it when I wake up. If anyone has any comments (including "Al, you are nuts", but something more specific would be more interesting), please reply. -- 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/