From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve French Subject: Re: [RFC PATCH] cleaning up negative dentries when remote directory is changed Date: Thu, 24 Nov 2005 20:06:31 -0600 Message-ID: <438671A7.4060809@austin.rr.com> References: <438669D9.7060505@austin.rr.com> <1132883741.8985.24.camel@lade.trondhjem.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from ms-smtp-01.texas.rr.com ([24.93.47.40]:49868 "EHLO ms-smtp-01-eri0.texas.rr.com") by vger.kernel.org with ESMTP id S1161090AbVKYCGA (ORCPT ); Thu, 24 Nov 2005 21:06:00 -0500 To: Trond Myklebust In-Reply-To: <1132883741.8985.24.camel@lade.trondhjem.org> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Trond Myklebust wrote: > On Thu, 2005-11-24 at 19:33 -0600, Steve French wrote: > >> Due to the dcache caching negative dentries, files which were deleted on >> the client (if it resulted in a negative denty) and soon after readded >> on the server would still appear deleted to stat (lookup) at least for >> the case of cifs . Although a readdir would readd the positive dentry, >> it would be nice to invalidate negative dentries if the client sees that >> the parent directory changed (on the server) so that the negative >> dentries would get tossed. Looking around some other examples, it >> looks like at least two (coda, nfs) handle this by calling >> shrink_dcache_parent(dentry) >> > > No they don't. shrink_dcache_parent() gets rid of _all_ unused child > dentries, which is worse than not caching the negative dentry. > > d_drop() is the right thing to do when you are talking about a single > dentry. > > >> which is the obvious way to do this (as in the attached patch which >> seems to work for cifs and address the reported bug). Is there a >> better way to remove the negative dentries (which may no longer be >> negative) under a changed directory? >> > > The way we do it in NFS is that we check the mtime of the parent > directory. If the latter has changed since the last time we revalidated > the negative dentry we call d_drop() in order to force a new lookup (the > timestamp is stored in dentry->d_time). > > I don't even see any code in my vfs being called on the negative dentry other than the lookup on the parent e.g: ls /mnt/modified_dir/deleted_file I see that the lookup on modified_dir hits cifs's dentry_revalidate routine but there is no call to dentry_revalidate on "deleted_file" ... does nfs export some magic dentry routines other than revalidate? > In order to deal with the (rare) case where the server does not support > mtime, we also have a hard limit on the lifetime of the negative dentry. > > Cheers, > Trond > > >