flock.2: Add more details on NFS, including Linux 2.6.37 changes

Also: move NOTES text describing interaction of fcntl()
and flock() locks.

Reviewed-by: NeilBrown <neilb@suse.de>
Reported-by: NeilBrown <neilb@suse.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2014-04-27 10:03:41 +02:00
parent fee98b6e5c
commit e449654fdb
1 changed files with 28 additions and 4 deletions

View File

@ -32,7 +32,7 @@
.\" FIXME: Maybe document LOCK_MAND, LOCK_RW, LOCK_READ, LOCK_WRITE
.\" which only have effect for SAMBA.
.\"
.TH FLOCK 2 2014-04-22 "Linux" "Linux Programmer's Manual"
.TH FLOCK 2 2014-04-27 "Linux" "Linux Programmer's Manual"
.SH NAME
flock \- apply or remove an advisory lock on an open file
.SH SYNOPSIS
@ -146,12 +146,36 @@ possibly implemented in terms of
.BR fcntl (2),
appears on most UNIX systems.
.SH NOTES
In Linux kernels up to 2.6.11,
.BR flock ()
does not lock files over NFS.
Use
does not lock files over NFS
(i.e., the scope of locks was limited to the local system).
Instead, one could use
.BR fcntl (2)
instead: that does work over NFS, given a sufficiently recent version of
byte-range locking, which does work over NFS,
given a sufficiently recent version of
Linux and a server which supports locking.
Since Linux 2.6.12, NFS clients support
.BR flock ()
locks by emulating them as byte-range locks on the entire file.
This means that
.BR fcntl (2)
and
.BR flock ()
locks
.I do
interact with one another over NFS.
Since Linux 2.6.37,
.\" commit 5eebde23223aeb0ad2d9e3be6590ff8bbfab0fc2
the kernel supports a compatibility mode that allows
.BR flock ()
locks (and also
.BR fcntl (2)
byte region locks) to be treated as local;
see the discussion of the
.I "local_lock"
option in
.BR nfs (5).
.PP
Since kernel 2.0,
.BR flock ()