Blob Blame History Raw
From f1121d1e7ff76ace6e89fbe275abc3abedd5940b Mon Sep 17 00:00:00 2001
From: Jan Chaloupka <jchaloup@redhat.com>
Date: Mon, 29 Sep 2014 21:43:53 +0200
Subject: [PATCH] flock.2 NFS flock

---
 man-pages/man2/flock.2 | 48 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/man-pages/man2/flock.2 b/man-pages/man2/flock.2
index 60537fe..b8c55d1 100644
--- a/man-pages/man2/flock.2
+++ b/man-pages/man2/flock.2
@@ -145,19 +145,12 @@ possibly implemented in terms of
 .BR fcntl (2),
 appears on most UNIX systems.
 .SH NOTES
-.BR flock ()
-does not lock files over NFS.
-Use
-.BR fcntl (2)
-instead: that does work over NFS, given a sufficiently recent version of
-Linux and a server which supports locking.
-.PP
 Since kernel 2.0,
 .BR flock ()
 is implemented as a system call in its own right rather
 than being emulated in the GNU C library as a call to
 .BR fcntl (2).
-This yields true BSD semantics:
+This yields classical BSD semantics:
 there is no interaction between the types of lock
 placed by
 .BR flock ()
@@ -166,6 +159,45 @@ and
 and
 .BR flock ()
 does not detect deadlock.
+(Note, however, that on some modern BSDs,
+.\" E.g., according to the flock(2) man page, FreeBSD since at least 5.3
+.BR flock ()
+and
+.BR fcntl (2)
+locks
+.I do
+interact with one another.)
+.PP
+In Linux kernels up to 2.6.11,
+.BR flock ()
+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)
+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
 .BR flock ()
 places advisory locks only; given suitable permissions on a file,
-- 
1.9.3