lockf(1) and NFS

Rick Macklem rmacklem at uoguelph.ca
Sat Aug 30 11:47:01 UTC 2014


Don Lewis wrote:
> 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.
> 
> 
> 
Doing locking locally within the client is still possible with the "nolockd"
option. However, when this mount option is used all file locking,
including POSIX byte range locks, are done locally.

Linux has a similar mount option (called "nolock" I think?), but I
don't know if Solaris has any mount option.

I'm pretty sure Ivan knows about this, so I suspect he needs lockf(1)
to work across multiple clients for his app., but don't know for sure?

rick



More information about the freebsd-fs mailing list