NFS (Network File System) version 3 and 4
Sometime NFS can result in weird problems. For example, NFS mounted directories sometimes contain stale file handles. If you run command such as ls or vi you will see an error:
Issue
- Clients mounting NFS filesystems report stale file handles
- What are some causes of stale file handles and how can they be prevented?
- I am seeing application logs stating read or write operations on an NFS file, or operations on an NFS directory, complete with errno = 116 (ESTALE)
- Change the file id size from 64-bits to 32-bits in NFS Server, there is ‘stale file handle’ error and below messages in /var/log/messages
# ls -l
.: Stale File Handle
# grep -i nfsĀ /var/log/messages
kernel: NFS: server lhub.nas error: fileid changed
kernel: fsid 0:13: expected fileid 0x1015734f5, got 0x15734f5
A filehandle becomes stale whenever the file or directory referenced by the handle is removed by another host, while your client still holds an active reference to the object. A typical example occurs when the current directory of a process, running on your client, is removed from the server (either by a process running on the server or on another client).
So this can occur if the directory is modified on the NFS server, but the directories modification time is not updated.
solution
- Any change to the file system or storage that the NFS export resides on may cause stale file handles. Examples:
- If no FSID is specified for the export then moving the export to a new block device or the block device being assigned a new major/minor number will cause stale file handles
- Changing the underlying file systems or inode map will cause stale file handles regardless of FSID
- Modifying an export’s explicitly defined FSID will cause stale file handles and require remount
- Adding an explicitly defined FSID to an export that does not yet have one will not cause stale file handles
- Incorrectly configured clustered NFS may lead to stale file handles during failover events
- Certain bugs in NFS servers or NFS clients can cause stale file handles
- Mounting filesystems from a very large number of NFS servers (several hundred or more) can cause port exhaustion of ‘reserved ports’ (under 1024). Beginning with RHEL 6, the mount option “noresvport” is available, and may help by allowing non-reserved ports to be used. Before RHEL 6, this mount option is not available.
A possible Solution is to Remount the directory from the NFS Client
# umount -f /path/to/mountpoint
# mount -t nfs nfsserver:/path/to/share /path/to/mountpoint