From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:45043 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbcCJEnV (ORCPT ); Wed, 9 Mar 2016 23:43:21 -0500 Date: Thu, 10 Mar 2016 04:43:16 +0000 From: Al Viro To: "Drokin, Oleg" Cc: "Dilger, Andreas" , Linus Torvalds , "" , Mark Fasheh Subject: Re: races in ll_splice_alias() and elsewhere (ext4, ocfs2) Message-ID: <20160310044316.GI17997@ZenIV.linux.org.uk> References: <20160308211148.GX17997@ZenIV.linux.org.uk> <20160309003416.GY17997@ZenIV.linux.org.uk> <7C3EBB6F-54AC-4744-BEC1-33EA82216F85@intel.com> <20160309012658.GZ17997@ZenIV.linux.org.uk> <34C2B1C3-2B7F-490B-A03A-3BCDDFC8BE48@intel.com> <20160310022041.GF17997@ZenIV.linux.org.uk> <73CAA5F1-C749-42ED-9A34-D96B5854A9B9@intel.com> <20160310033428.GH17997@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Mar 10, 2016 at 03:46:43AM +0000, Drokin, Oleg wrote: > > Wait a minute. If it's hashed, has the right name and the right parent, > > why the hell are we calling ->lookup() on a new dentry in the first place? > > Why hadn't we simply picked it from dcache? > > This is because of the trickery we do in the d_compare. > our d_compare looks at the "invalid" flag and if it's set, returns "not matching", > triggering the lookup instead of revalidate. > This makes revalidate simple and fast. > (We used to have a complicated revalidate with a lot of code duplication with > lookup in order to be able to query the server and pass all sorts of data there > and it was nothing but trouble). *Ugh*... That's really nasty. We certainly could make d_exact_match() accept unhashed ones and make rehashing conditional (NFS doesn't pull anything similar, so it won't care), but your ->d_revalidate() has exact same problem as ext4_d_revalidate() one mentioned upthread - there's no warranty that dentry->d_parent will stay stable. We are *NOT* guaranteed locked parent when ->d_revalidate() is called, or we would have to lock every damn directory on the way through the pathname resolution. Moreover, ->d_revalidate() really can overlap with rename(2).