From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Piggin Subject: Re: lifetime of DCACHE_DISCONECTED dentries Date: Tue, 16 Nov 2010 17:45:03 +1100 Message-ID: References: <20101112184353.GA32745@fieldses.org> <20101115174837.GB10044@fieldses.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: "J. Bruce Fields" Return-path: In-Reply-To: <20101115174837.GB10044-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org> Sender: linux-nfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On Tue, Nov 16, 2010 at 4:48 AM, J. Bruce Fields = wrote: > On Sat, Nov 13, 2010 at 10:53:12PM +1100, Nick Piggin wrote: >> On Sat, Nov 13, 2010 at 5:43 AM, J. Bruce Fields wrote: >> > =A0 =A0 =A0 =A0- putfh: look up the filehandle. =A0The only alias = found for the >> > =A0 =A0 =A0 =A0 =A0inode will be DCACHE_UNHASHED alias referenced = by the filp >> > =A0 =A0 =A0 =A0 =A0associated with the nfsd open. =A0d_obtain_alia= s() doesn't like >> > =A0 =A0 =A0 =A0 =A0this, so it creates a new DCACHE_DISCONECTED de= ntry and >> > =A0 =A0 =A0 =A0 =A0returns that instead. >> >> This seems to be where the thing goes wrong. It isn't a hashed dentr= y at >> this point here, so d_obtain_alias should not be making one. > > Sounds sensible. =A0(But can you think of any actual bugs that will r= esult > from trying to add a new hashed dentry in this case?) Well, this one? :) >> I think the inode i_nlink games are much more appropriate on this si= de of >> the equation, rather than the dput side (after all, d_obtain_alias i= s setting >> up an alias for the inode). >> >> Can you even put the link check into __d_find_alias? >> >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (S_ISDIR(inode->i_mode) || !d_unhas= hed(alias)) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (S_ISDIR(inode->i_mode) || !inode->= i_nlink || >> !d_unhashed(alias)) { >> >> Something like that? > > The immediate result of that would be for the close rpc (or any rpc's > sent after the file was unlinked) to fail with ESTALE. Why is that? Seems like it would be a bug, because a hashed dentry may be unhashed at any time concurrently to nfsd operation, so it should be able to tolerate that so long as it has a ref on the inode? > But nfsd already holds an open file in this case, and you could argue > that it should be using that from the start. Yes. > So, we could modify nfsd to add a hash mapping filehandles to the fil= p's > that it knows about, and have nfsd consult that hash before calling > dentry_to_fh. Could be an option. It would be a pity not just be able to use the alia= s list. What exactly goes wrong when it gets an unhashed alias back? -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html