title: flock and NFS -- what happens upon unexpected shutdown?
body: <p>I am using <code>flock</code> within an HPC application on a file system shared among many machines via NFS. Locking works fine as long as all machines behave as expected (Quote from <a href="http://en.wikipedia.org/wiki/File_locking" rel="nofollow">http://en.wikipedia.org/wiki/File_locking</a>: "Kernel 2.6.12 and above implement flock calls on NFS files using POSIX byte-range locks. These locks will be visible to other NFS clients that implement fcntl-style POSIX locks").</p>
  
  <p>I would like to know what is expected to happen if one of the machines that has acquired a certain lock unexpectedly shuts down, e.g. due to a power outage. I am not sure where to look this up. My guess is that this is entirely up to NFS and its way to deal with NFS handles of non-responsive machines. I could imagine that the other clients will still see the lock until a timeout occurs and the NFS server declares all NFS handles of the machine that timed out as invalid. Is that correct? What would that timeout be? What happens if the machine comes up again within the timeout? Can you recommend a definite reference to look all of this up?</p>
  
  <p>Thanks!</p>