All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] flock.2: describe flock on NFS filesystems
@ 2011-09-15  8:09 Petr Uzel
       [not found] ` <20110915080934.GA9293-hLZXBWembXzjFM9bn6wA6Q@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Uzel @ 2011-09-15  8:09 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

NFSv4 need file to be opened in RW-mode to place exclusive lock:
http://www.spinics.net/lists/linux-nfs/msg18502.html

flock works on NFS since 2.6.12:
http://nfs.sourceforge.net/#section_d ,section D10

Signed-off-by: Petr Uzel <petr.uzel-AlSwsSmVLrQ@public.gmane.org>
---
 man2/flock.2 |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/man2/flock.2 b/man2/flock.2
index f0d85af..c904f6b 100644
--- a/man2/flock.2
+++ b/man2/flock.2
@@ -107,7 +107,8 @@ are preserved across an
 .BR execve (2).
 
 A shared or exclusive lock can be placed on a file regardless of the
-mode in which the file was opened.
+mode in which the file was opened. The exception is NFSv4, where
+the file has to be opened for writing to place exclusive lock.
 .SH "RETURN VALUE"
 On success, zero is returned.
 On error, \-1 is returned, and
@@ -146,7 +147,8 @@ possibly implemented in terms of
 appears on most UNIX systems.
 .SH NOTES
 .BR flock ()
-does not lock files over NFS.
+does not lock files over NFS before kernel 2.6.12. Since
+2.6.12, kernel emulates flock () using fcntl(2).
 Use
 .BR fcntl (2)
 instead: that does work over NFS, given a sufficiently recent version of
-- 
1.7.3.4


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] flock.2: describe flock on NFS filesystems
       [not found] ` <20110915080934.GA9293-hLZXBWembXzjFM9bn6wA6Q@public.gmane.org>
@ 2017-10-03 18:42   ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2017-10-03 18:42 UTC (permalink / raw)
  To: Petr Uzel
  Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA

Hello Peter,

On 09/15/2011 10:09 AM, Petr Uzel wrote:
> NFSv4 need file to be opened in RW-mode to place exclusive lock:
> http://www.spinics.net/lists/linux-nfs/msg18502.html
> 
> flock works on NFS since 2.6.12:
> http://nfs.sourceforge.net/#section_d ,section D10

Long ago, this patch fell on the floor. Sorry about that.
Someone did later fix most of this, but the detail
that NFS requires the file to be opened for writing in
order to place a LOCK_EX lock was missing. I've added it
now.

Thanks,

Michael

> Signed-off-by: Petr Uzel <petr.uzel-AlSwsSmVLrQ@public.gmane.org>
> ---
>  man2/flock.2 |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/man2/flock.2 b/man2/flock.2
> index f0d85af..c904f6b 100644
> --- a/man2/flock.2
> +++ b/man2/flock.2
> @@ -107,7 +107,8 @@ are preserved across an
>  .BR execve (2).
>  
>  A shared or exclusive lock can be placed on a file regardless of the
> -mode in which the file was opened.
> +mode in which the file was opened. The exception is NFSv4, where
> +the file has to be opened for writing to place exclusive lock.
>  .SH "RETURN VALUE"
>  On success, zero is returned.
>  On error, \-1 is returned, and
> @@ -146,7 +147,8 @@ possibly implemented in terms of
>  appears on most UNIX systems.
>  .SH NOTES
>  .BR flock ()
> -does not lock files over NFS.
> +does not lock files over NFS before kernel 2.6.12. Since
> +2.6.12, kernel emulates flock () using fcntl(2).
>  Use
>  .BR fcntl (2)
>  instead: that does work over NFS, given a sufficiently recent version of
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-03 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-15  8:09 [PATCH] flock.2: describe flock on NFS filesystems Petr Uzel
     [not found] ` <20110915080934.GA9293-hLZXBWembXzjFM9bn6wA6Q@public.gmane.org>
2017-10-03 18:42   ` Michael Kerrisk (man-pages)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.