NFS client bug with fix

Olaf Flebbe (O.Flebbe@science-computing.uni-tuebingen.de)
Mon, 20 May 1996 18:41:37 +0200 (MET DST)


Hi,

if a directory is created on an NFS mounted Filesystem, the parent
inode count may not update, because of the attribute cache.

A simple demo
---------------------------------
#!/bin/sh

# creating test dir
mkdir test.$$

# creating another test dir
# Posix semantic implies that the inode count of test.$$ should
# be three afterwards.

mkdir test.$$/test.$$

touch test.$$/test.$$/gnufindmaynotfindme

find -name gnufindmaynotfindme -print

ls -ld test.$$ test.$$/test.$$

# be sure to time out the attribute cache
sleep 40

ls -ld test.$$ test.$$/test.$$

find -name gnufindmaynotfindme -print
---------------------

Output (without patch) mounted from a POSIX conforming machine is

drwxr-xr-x 2 olaf users 1024 Mar 30 22:36 test.238
drwxr-xr-x 2 olaf users 1024 Mar 30 22:36 test.238/test.238
drwxr-xr-x 3 olaf users 1024 Mar 30 22:36 test.238
drwxr-xr-x 2 olaf users 1024 Mar 30 22:36 test.238/test.238
./test.238/test.238/gnufindmaynotfindme

Note the wrong inode count in the dir test.238.

[ I wrote this example awhile ago ;-) ]

========
Simple Fix: delete the parent attribute cache entry when creating
a new directory.

--- dir.c.orig Fri Apr 26 17:40:22 1996
+++ dir.c Mon May 20 18:36:29 1996
@@ -476,8 +476,11 @@
sattr.atime.seconds = sattr.mtime.seconds = (unsigned) -1;
error = nfs_proc_mkdir(NFS_SERVER(dir), NFS_FH(dir),
name, &sattr, &fhandle, &fattr);
- if (!error)
+ if (!error) {
nfs_lookup_cache_add(dir, name, &fhandle, &fattr);
+ /* The parent dir inode count may have changed ! */
+ nfs_lookup_cache_remove( NULL, dir, NULL);
+ }
iput(dir);
return error;
}

-- 
  Dr. Olaf Flebbe                            Phone +49 (0)7071-9457-32
  science + computing gmbh                     FAX +49 (0)7071-9457-27
  Hagellocher Weg 71
  D-72070 Tuebingen  Email: o.flebbe@science-computing.uni-tuebingen.de