Occasionally the NFS Client does not read data from NFS exports synchronously, such as when it was written by another NFS Client. For example, after NFS Client A writes a file by “echo hello > /NFS_mountpoint/testfile”, NFS Client B can not read the file with “No such file”, or can read but the contents of the file could be old one.
NFS Clients caches various NFS data. RFC 1813 for NFSv3 specification says:
Clients can perform caching in varied manner.
and also says:
The NFS version 3 protocol does not define a policy for caching on the client or server. In particular, there is no support for strict cache consistency between a client and server, nor between different clients. Therefore this is designed behavior of Linux NFS client.
Therefore this is designed behavior of Linux NFS client. Disable/skip NFS client caching by configuring NFS client mount options, or read/write the data with O_DIRECT/O_SYNC.
To disable all caches for NFS client, add “sync” for mount option, ex.
# mount -t nfs -o vers=3,sync NFS_Server:/NFS_Export/ /NFS_Mountpoint
To disable caching directory entries by NFS client, add “noac,lookupcache=none” for the mount option, such as in the following example:
# mount -t nfs -o vers=3,noac,lookupcache=none NFS_Server:/NFS_Export/ /NFS_Mountpoint