From: NeilBrown <neilb@suse.de>
To: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Cc: "Stefan (metze) Metzmacher" <metze@samba.org>,
Jeff Layton <jlayton@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Ganesha NFS List <nfs-ganesha-devel@lists.sourceforge.net>,
Suresh Jayaraman <sjayaraman@suse.de>,
Trond Myklebust <trond.myklebust@fys.uio.no>,
Christoph Hellwig <hch@infradead.org>,
linux-nfs@vger.kernel.org,
"J. Bruce Fields" <bfields@fieldses.org>
Subject: Re: flock() and NFS [Was: Re: [PATCH] locks: rename file-private locks to file-description locks]
Date: Sun, 27 Apr 2014 20:04:31 +1000 [thread overview]
Message-ID: <20140427200431.426c98d1@notabene.brown> (raw)
In-Reply-To: <535CCAD2.4060304@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3152 bytes --]
On Sun, 27 Apr 2014 11:16:02 +0200 "Michael Kerrisk (man-pages)"
<mtk.manpages@gmail.com> wrote:
> [Trimming some folk from CC, and adding various NFS people]
>
> On 04/27/2014 06:51 AM, NeilBrown wrote:
>
> [...]
>
> > Note to Michael: The text
> > flock() does not lock files over NFS.
> > in flock(2) is no longer accurate. The reality is ... complex.
> > See nfs(5), and search for "local_lock".
>
> Ahhh -- I see:
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=5eebde23223aeb0ad2d9e3be6590ff8bbfab0fc2
>
> Thanks for the heads up.
>
> Just in general, it would be great if the flock(2) and fcntl(2) man pages
> contained correct details for NFS, of course. So, for example, if there
> are any current gotchas for NFS and fcntl() byte-range locking, I'd like
> to add those to the fcntl(2) man page.
The only peculiarities I can think of are:
- With NFS, locking or unlocking a region forces a flush of any cached data
for that file (or maybe for the region of the file). I'm not sure if this
is worth mentioning.
- With NFSv4 the client can lose a lock if it is out of contact with the
server for a period of time. When this happens, any IO to the file by a
process which "thinks" it holds a lock will fail until that process closes
and re-opens the file.
This behaviour is since 3.12. Prior to that the client might lose and
regain the lock without ever knowing thus potentially risking corruption
(but only if client and server lost contact for an extended period).
>
> Anyway, returning to your point about flock(), how would this text
> look for the flock(2) manual page:
>
> NOTES
> Since kernel 2.0, flock() is implemented as a system call in
> its own right rather than being emulated in the GNU C library
> as a call to fcntl(2). This yields classical BSD semantics:
> there is no interaction between the types of lock placed by
> flock() and fcntl(2), and flock() does not detect deadlock.
> (Note, however, that on some modern BSDs, flock() and fcntl(2)
> locks do interact with one another.)
>
> In Linux kernels up to 2.6.11, flock() does not lock files over
> NFS (i.e., the scope of locks was limited to the local system).
> Instead, one could use 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 flock() locks by emulating them as byte-range
> locks on the entire file. This means that fcntl(2) and flock()
> locks do interact with one another over NFS. Since Linux
> 2.6.37, the kernel supports a compatibility mode that allows
> flock() locks (and also fcntl(2) byte region locks) to be
> treated as local; see the discussion of the local_lock option
> in nfs(5).
> ?
That seems to cover it quite well - thanks.
NeilBrown
>
> Thanks,
>
> Michael
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2014-04-27 10:04 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-21 13:45 [PATCH] locks: rename file-private locks to file-description locks Jeff Layton
2014-04-21 14:02 ` Rich Felker
2014-04-21 14:23 ` Michael Kerrisk (man-pages)
2014-04-21 16:09 ` Christoph Hellwig
2014-04-21 16:42 ` Jeff Layton
2014-04-21 17:03 ` [Nfs-ganesha-devel] " Frank Filz
2014-04-21 18:20 ` Michael Kerrisk (man-pages)
2014-04-21 16:10 ` Rich Felker
2014-04-21 16:45 ` Jeff Layton
2014-04-21 18:01 ` Andy Lutomirski
2014-04-21 18:43 ` Michael Kerrisk (man-pages)
2014-04-21 18:18 ` Michael Kerrisk (man-pages)
2014-04-21 18:32 ` Jeff Layton
2014-04-21 18:48 ` Rich Felker
2014-04-21 19:16 ` Jeff Layton
2014-04-21 20:22 ` Rich Felker
2014-04-21 18:32 ` Michael Kerrisk (man-pages)
2014-04-21 18:34 ` Christoph Hellwig
2014-04-21 18:39 ` Michael Kerrisk (man-pages)
2014-04-21 18:46 ` Rich Felker
2014-04-21 19:39 ` Michael Kerrisk (man-pages)
2014-04-21 19:55 ` Jeff Layton
2014-04-21 21:15 ` Stefan (metze) Metzmacher
2014-04-22 4:54 ` Michael Kerrisk (man-pages)
2014-04-27 4:51 ` NeilBrown
2014-04-27 9:14 ` Michael Kerrisk (man-pages)
2014-04-27 9:16 ` flock() and NFS [Was: Re: [PATCH] locks: rename file-private locks to file-description locks] Michael Kerrisk (man-pages)
2014-04-27 10:04 ` NeilBrown [this message]
2014-04-27 11:11 ` Michael Kerrisk (man-pages)
2014-04-27 21:28 ` NeilBrown
2014-04-29 9:07 ` Michael Kerrisk (man-pages)
2014-04-29 9:24 ` NeilBrown
2014-04-29 9:53 ` Michael Kerrisk (man-pages)
2014-04-29 11:34 ` Jeff Layton
2014-04-29 12:20 ` Michael Kerrisk (man-pages)
2014-04-28 10:23 ` [PATCH] locks: rename file-private locks to file-description locks Jeff Layton
2014-04-28 10:46 ` NeilBrown
2014-04-21 18:48 ` Theodore Ts'o
2014-04-21 18:51 ` Rich Felker
2014-04-21 19:04 ` Theodore Ts'o
2014-04-21 19:06 ` Christoph Hellwig
2014-04-21 20:10 ` Michael Kerrisk (man-pages)
2014-04-21 20:20 ` Rich Felker
2014-04-21 14:25 ` Michael Kerrisk (man-pages)
2014-04-21 16:05 ` Stefan (metze) Metzmacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140427200431.426c98d1@notabene.brown \
--to=neilb@suse.de \
--cc=bfields@fieldses.org \
--cc=hch@infradead.org \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=metze@samba.org \
--cc=mtk.manpages@gmail.com \
--cc=nfs-ganesha-devel@lists.sourceforge.net \
--cc=sjayaraman@suse.de \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).