lockf(1) and NFS

Don Lewis truckman at FreeBSD.org
Sat Aug 30 00:53:05 UTC 2014


On 29 Aug, Rick Macklem wrote:
> Ivan Voras wrote:
>> Hi,
>> 
>> I had some fun troubleshooting NFS locking and among other things,
>> found
>> that lockf(1) doesn't really work on NFSv4 mounts. Googling around
>> (so
>> correct me if I'm wrong), it looks like this is because NFS quietly
>> translates the old-style locks into POSIX range locks, and those
>> cannot
>> be acquired exclusively if the file is opened read-only.
>> 
> Yes, the NFSv4 protocol only supports POSIX byte range locks.
> The only alternative to translating flock(2) locks to POSIX locks is
> to not support flock(2) locks at all.

As I recall, on SunOS, flock(2) locks were local to the machine.  Looks
like that was changed later on ...

    "Locks obtained through the flock() mechanism under SunOS 4.1
     were known only within the system on which they were placed.
     This is no longer true."

<http://www.manpages.info/sunos/flock.3.html>

That was actually a feature because you could use flock() to coordinate
between local processes, while avoiding any NFS lock manager bugs, even
on diskless machines.




More information about the freebsd-fs mailing list