From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve French Subject: [RFC PATCH] cleaning up negative dentries when remote directory is changed Date: Thu, 24 Nov 2005 19:33:13 -0600 Message-ID: <438669D9.7060505@austin.rr.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070005050901020209070503" Return-path: Received: from ms-smtp-02.texas.rr.com ([24.93.47.41]:36561 "EHLO ms-smtp-02-eri0.texas.rr.com") by vger.kernel.org with ESMTP id S1161081AbVKYBcp (ORCPT ); Thu, 24 Nov 2005 20:32:45 -0500 To: linux-fsdevel@vger.kernel.org Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org This is a multi-part message in MIME format. --------------070005050901020209070503 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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) 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? --------------070005050901020209070503 Content-Type: text/x-patch; name="dir-revalidate.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dir-revalidate.patch" diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 05b5258..45b67e9 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1039,14 +1042,18 @@ int cifs_revalidate(struct dentry *diren filemap_fdatawrite(direntry->d_inode->i_mapping); } if (invalidate_inode) { - if (direntry->d_inode->i_mapping) - filemap_fdatawait(direntry->d_inode->i_mapping); - /* may eventually have to do this for open files too */ - if (list_empty(&(cifsInode->openFileList))) { - /* Has changed on server - flush read ahead pages */ - cFYI(1, ("Invalidating read ahead data on " - "closed file")); - invalidate_remote_inode(direntry->d_inode); + if(S_ISDIR(direntry->d_inode->i_mode)) { + shrink_dcache_parent(direntry); + } else if (S_ISREG(direntry->d_inode->i_mode)) { + if (direntry->d_inode->i_mapping) + filemap_fdatawait(direntry->d_inode->i_mapping); + /* may eventually have to do this for open files too */ + if (list_empty(&(cifsInode->openFileList))) { + /* changed on server - flush read ahead pages */ + cFYI(1, ("Invalidating read ahead data on " + "closed file")); + invalidate_remote_inode(direntry->d_inode); + } } } /* up(&direntry->d_inode->i_sem); */ --------------070005050901020209070503--