--- Begin Message --- Hi Trond et al,
The following one line patch invalidates the attributes of the underlying inode when a file is renamed. Some filesystems update ctime upon rename(). One such filesystem is ext3, and a comment in the relevant code there indicates this is true with other Unix filesystems as well.
The following problem was observed on Fedora Core 1 running a stock kernel.org 2.6.0-test10.
The server is running Solaris 2.8 but I have verified the same issue exists with a server running Linix 2.4.22. These operations a done via a Perl script.
1. Check out a CVS repository into an NFS mounted directory.
2. Move files from CVS working directory into another directory in the same filesystem.
3. Tar up the resultant directory.
4. Tar prints lots of "file changed after we read it" messages.
Tar obtains ctime via stat() before reading the file and compares it to the ctime obtained via fstat() after having read the file. The two differ because the intervening open() forces an attribute refresh due to CTO consistency at which time ctime is updated. Forcing a cache invalidation during rename() eliminates this particular scenario.
Thanks,
Shantanu
--- 2.6.0-test10/fs/nfs/dir.c.~1~ 2003-10-17 17:43:11.000000000 -0400
+++ 2.6.0-test10/fs/nfs/dir.c 2003-11-26 12:42:27.000000000 -0500
@@ -1257,6 +1257,7 @@
nfs_zap_caches(new_dir);
nfs_zap_caches(old_dir);
+ NFS_CACHEINV(old_inode);
error = NFS_PROTO(old_dir)->rename(old_dir, &old_dentry->d_name,
new_dir, &new_dentry->d_name);
out:
--- End Message ---