linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] cleaning up negative dentries when remote directory is changed
@ 2005-11-25  1:33 Steve French
  2005-11-25  1:55 ` Trond Myklebust
  0 siblings, 1 reply; 5+ messages in thread
From: Steve French @ 2005-11-25  1:33 UTC (permalink / raw)
  To: linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

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?



[-- Attachment #2: dir-revalidate.patch --]
[-- Type: text/x-patch, Size: 1206 bytes --]

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); */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-11-25  2:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-25  1:33 [RFC PATCH] cleaning up negative dentries when remote directory is changed Steve French
2005-11-25  1:55 ` Trond Myklebust
2005-11-25  2:06   ` Steve French
2005-11-25  2:18     ` Trond Myklebust
2005-11-25  2:29       ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).