Managing NFS and NIS, 2nd Edition - Mike Eisler [234]
/net/inchun/export/folder/data2: Stale NFS file handle
total 6
-rw-rw-rw- 1 labiaga staff 2883 Apr 10 20:03 data1
44 0.00000 tarsus -> inchun NFS C GETATTR2 FH=FA14
45 0.00101 inchun -> tarsus NFS R GETATTR2 OK
46 0.00032 tarsus -> inchun NFS C GETATTR2 FH=F66F
47 0.00191 inchun -> tarsus NFS R GETATTR2 OK
48 0.00032 tarsus -> inchun NFS C GETATTR2 FH=F8CD
49 0.00214 inchun -> tarsus NFS R GETATTR2 Stale NFS file handle
The directory attributes reported in packet 45 are the same as those seen in packet 40, therefore tarsus assumes that it can safely use the cached filehandles associated with the cached entries of this directory. In packet 46, tarsus requests the attributes of filehandle F66F, corresponding to the data1 file. The server replies with the attributes in packet 47. tarsus then proceeds to request the attributes of filehandle F8CD, which corresponds to the data2 file. The server replies with a "Stale NFS filehandle" error because there is no file on the server associated with the given filehandle. This problem would never have occurred had the server updated the modification time after removing the file causing tarsus to detect that the directory had been changed.
Directory caching works nicely when the NFS server obeys Unix directory semantics. Many non-Unix NFS servers provide such semantics even if they have to submit themselves to interesting contortions. Having said this, there is nothing in the NFS protocol specification that requires the modification time of a directory to be updated when a file is removed. You may therefore need to disable Solaris NFS directory caching if you're running into problems interacting with non-Unix servers. To permanently disable NFS directory caching, add this line to /etc/system:
set nfs:nfs_disable_rddir_cache = 0x1
The Solaris kernel reads /etc/system at startup and sets the value of nfs_disable_rddir_cache to 0x1 in the nfs kernel module. The change takes effect only after reboot. Use adb to disable caching during the current session, postponing the need to reboot. You still need to set the tunable in /etc/system to make the change permanent through reboots:
aqua# adb -w -k /dev/ksyms /dev/mem
physmem 3ac8
nfs_disable_rddir_cache/W1
nfs_disable_rddir_cache: 0x0 = 0x1
adb is an interactive assembly level debugger that enables you to consult and modify the kernel's memory contents. The -k directive instructs adb to perform kernel memory mapping accessing the kernel's memory via /dev/mem, and obtaining the kernel's symbol table from /dev/ksyms. The -w directive allows you to modify the kernel memory contents. A word of caution: adb is a power tool that will cause serious data corruption and potential system panics when misused.
Incorrect mount point permissions
Not all problems involving NFS filesystems originate on the network or other fileservers. NFS filesystems closely resemble local filesystems, consequently common local system administration concepts and problem solving techniques apply to NFS mounted filesystems as well. A user reported problems resolving the "current directory" when inside an NFS mounted filesystem. The filesystem was automounted using the following direct map:
Excerpt from /etc/auto_direct:
/packages -ro aqua:/export
The user was able to cd into the directory and list the directory contents except for the ".." entry. He was not able to execute the pwd command when inside the NFS directory either:
$ cd /packages
$ ls -la
./..: Permission denied
total 6
drwxr-xr-x 4 root sys 512 Oct 1 12:16 ./
drwxr-xr-x 2 root other 512 Oct 1 12:16 pkg1/
drwxr-xr-x 2 root other 512 Oct 1 12:16 pkg2/
$ pwd
pwd: cannot determine current directory!
He performed the same procedure as superuser and noticed that it worked correctly:
# cd /packages
# ls -la
total 8
drwxr-xr-x 4 root sys 512 Oct 1 12:16 .
drwxr-xr-x 38 root root 1024 Oct 1 12:14 ..
drwxr-xr-x 2 root other 512 Oct 1 12:16 pkg1
drwxr-xr-x 2 root other 512 Oct 1 12:16 pkg2
# pwd
/packages
# ls -ld /packages
drwxr-xr-x 4 root sys 512 Oct 1 12:16 /packages
Note