5

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.

3 Answers 3

3

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"

3

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.

2

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 but they 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 a machine across the net or an application 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .