|
|
7dd887 |
From f1121d1e7ff76ace6e89fbe275abc3abedd5940b Mon Sep 17 00:00:00 2001
|
|
|
7dd887 |
From: Jan Chaloupka <jchaloup@redhat.com>
|
|
|
7dd887 |
Date: Mon, 29 Sep 2014 21:43:53 +0200
|
|
|
7dd887 |
Subject: [PATCH] flock.2 NFS flock
|
|
|
7dd887 |
|
|
|
7dd887 |
---
|
|
|
7dd887 |
man-pages/man2/flock.2 | 48 ++++++++++++++++++++++++++++++++++++++++--------
|
|
|
7dd887 |
1 file changed, 40 insertions(+), 8 deletions(-)
|
|
|
7dd887 |
|
|
|
7dd887 |
diff --git a/man-pages/man2/flock.2 b/man-pages/man2/flock.2
|
|
|
7dd887 |
index 60537fe..b8c55d1 100644
|
|
|
7dd887 |
--- a/man-pages/man2/flock.2
|
|
|
7dd887 |
+++ b/man-pages/man2/flock.2
|
|
|
7dd887 |
@@ -145,19 +145,12 @@ possibly implemented in terms of
|
|
|
7dd887 |
.BR fcntl (2),
|
|
|
7dd887 |
appears on most UNIX systems.
|
|
|
7dd887 |
.SH NOTES
|
|
|
7dd887 |
-.BR flock ()
|
|
|
7dd887 |
-does not lock files over NFS.
|
|
|
7dd887 |
-Use
|
|
|
7dd887 |
-.BR fcntl (2)
|
|
|
7dd887 |
-instead: that does work over NFS, given a sufficiently recent version of
|
|
|
7dd887 |
-Linux and a server which supports locking.
|
|
|
7dd887 |
-.PP
|
|
|
7dd887 |
Since kernel 2.0,
|
|
|
7dd887 |
.BR flock ()
|
|
|
7dd887 |
is implemented as a system call in its own right rather
|
|
|
7dd887 |
than being emulated in the GNU C library as a call to
|
|
|
7dd887 |
.BR fcntl (2).
|
|
|
7dd887 |
-This yields true BSD semantics:
|
|
|
7dd887 |
+This yields classical BSD semantics:
|
|
|
7dd887 |
there is no interaction between the types of lock
|
|
|
7dd887 |
placed by
|
|
|
7dd887 |
.BR flock ()
|
|
|
7dd887 |
@@ -166,6 +159,45 @@ and
|
|
|
7dd887 |
and
|
|
|
7dd887 |
.BR flock ()
|
|
|
7dd887 |
does not detect deadlock.
|
|
|
7dd887 |
+(Note, however, that on some modern BSDs,
|
|
|
7dd887 |
+.\" E.g., according to the flock(2) man page, FreeBSD since at least 5.3
|
|
|
7dd887 |
+.BR flock ()
|
|
|
7dd887 |
+and
|
|
|
7dd887 |
+.BR fcntl (2)
|
|
|
7dd887 |
+locks
|
|
|
7dd887 |
+.I do
|
|
|
7dd887 |
+interact with one another.)
|
|
|
7dd887 |
+.PP
|
|
|
7dd887 |
+In Linux kernels up to 2.6.11,
|
|
|
7dd887 |
+.BR flock ()
|
|
|
7dd887 |
+does not lock files over NFS
|
|
|
7dd887 |
+(i.e., the scope of locks was limited to the local system).
|
|
|
7dd887 |
+Instead, one could use
|
|
|
7dd887 |
+.BR fcntl (2)
|
|
|
7dd887 |
+byte-range locking, which does work over NFS,
|
|
|
7dd887 |
+given a sufficiently recent version of
|
|
|
7dd887 |
+Linux and a server which supports locking.
|
|
|
7dd887 |
+Since Linux 2.6.12, NFS clients support
|
|
|
7dd887 |
+.BR flock ()
|
|
|
7dd887 |
+locks by emulating them as byte-range locks on the entire file.
|
|
|
7dd887 |
+This means that
|
|
|
7dd887 |
+.BR fcntl (2)
|
|
|
7dd887 |
+and
|
|
|
7dd887 |
+.BR flock ()
|
|
|
7dd887 |
+locks
|
|
|
7dd887 |
+.I do
|
|
|
7dd887 |
+interact with one another over NFS.
|
|
|
7dd887 |
+Since Linux 2.6.37,
|
|
|
7dd887 |
+.\" commit 5eebde23223aeb0ad2d9e3be6590ff8bbfab0fc2
|
|
|
7dd887 |
+the kernel supports a compatibility mode that allows
|
|
|
7dd887 |
+.BR flock ()
|
|
|
7dd887 |
+locks (and also
|
|
|
7dd887 |
+.BR fcntl (2)
|
|
|
7dd887 |
+byte region locks) to be treated as local;
|
|
|
7dd887 |
+see the discussion of the
|
|
|
7dd887 |
+.I "local_lock"
|
|
|
7dd887 |
+option in
|
|
|
7dd887 |
+.BR nfs (5).
|
|
|
7dd887 |
.PP
|
|
|
7dd887 |
.BR flock ()
|
|
|
7dd887 |
places advisory locks only; given suitable permissions on a file,
|
|
|
7dd887 |
--
|
|
|
7dd887 |
1.9.3
|
|
|
7dd887 |
|