Here's my set up: One NFS Server machine (v4), several NFS client machines.
When a client machine write files to the NFS mount, the other clients see the new content instantly : no problem.
But, when the server machine modify the content of the file, this new content is not shown on the client until I do a ls
of the directory from the client.
I'm absolutely stumped on this inconsistency…any help would be greatly appreciated!
Infos :
- nfs 1.2.3-r1 on both client and server
- acregmin, acregmax, acdirmin, acdirmax, lookupcache : default values
Best Answer
Adding as an answer based on your comment.
The solution is to add
lookupcache=none
to your nfs mount options.What happens is that the first time your client reads the file it does a NFS lookup to get the NFS fileid. It then caches the NFS fileid, and when you go back to open the file, it uses the cache. Normally this isnt a problem as when the file is updated its fileid stays the same. But for some reason the old file is being removed, and a new one is created (or renamed, or something to where its not the same file).
Now normally this isnt a problem either as when your client tries to open a fileid which isnt there, it will get an error from the server and do another lookup to get the new fileid. But for some reason the NFS server is letting the client open that old fileid. Perhaps another client has the file open and so its not being deleted yet, I dont know.
In any case the way to solve it is to tell the client to always do an nfslookup before opening a file by using the nfs mount option
lookupcache=none
. The downside to this is that it can be expensive if you are frequently opening files since it adds more traffic to the NFS server.