4

I am interested in the impact of the read disk cache on accessing a file through NFS. Lets say I have a file on NFS. I access it (do "cat myfile") from a linux host "A". If there's enough RAM a file would end up in the disk cache. Now I modify that file from host "B". How does OS on host "A" knows that it has to invalidate that part of the cache? Is there some callback from the NFS? Or the disk cache expires quickly?

7

Answer A8 of the Linux NFS FAQ has an explanation.

A summary: it's up to the client to poll the server to ask for changes (by checking file attributes to see if they've changed since last time the client checked). Clients traditionally do that at regular intervals, but also any time they open a file. They also flush back any writes on close. This means that you get the results you'd expect as long as you ensure that no other client opens a file while one client holds it open for write.

This behavior is usually configurable using mount options, for example if you prefer stronger cache consistency at the expense of performance. See for example "man nfs" on a Linux client.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.