Similar to Concurrent FTP access.

How is concurrent file access handled for NFS? Say that one client is updating/overwriting a file on a NFS server, and a process on the server is reading that same file directly from the file system at the same time. Is there some sort of atomic handling of file read/write in NFS/Linux or do I have to work with tmp files to ensure data consistency?

I'm worried that the process reading the file will get corrupt data.

link|improve this question

50% accept rate
feedback

3 Answers

up vote 1 down vote accepted

NFS usually comes with the sibling protocol NLM (Network Lock Monitor), but it only works with advisory (i.e. not enforeced) locks.

For this and other issues related to your question, you main want to read "NFS Considered Harmful"

link|improve this answer
feedback

These conflicts are usually resolved through locks. It is upon application to ensure proper locking. That said, it needs to be noted that most of applications do tend to lock files, especially during writes.

link|improve this answer
feedback

This problem is the same on any multitasking OS filesystem. What stops one process for changing a file that another is using. Locks. Nothing by default stops this. You can trust NLM or other systems if you want butthey can be buggy. We tend to create soft links. If the create fail someone else has the file. Remember to remove the link when you are finished with the file. There are always problems with removing dead locks when machine across the net or applications died as there are more error states, I find it had to believe that any NLM like system gets this 100% correct either.

If you want to guarantee access then you need a special gate-keep server that only allows atomic reads and writes of the whole file.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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