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>
flock.2: Move NOTES text describing implementation of flock()

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
flock.2: In some modern BSDs, fcntl() and flock() locks do interact

So, reword and extend the discussion of this topic in NOTES.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Reword discussion of mandatory lock bug a litte

Jeff Layton confirmed that the bug remains even in modern kernels.

Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: srcfix

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Minor rewording

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Note treatment of locks when an NFS client loses contact with the server

Based on text sent by Neil Brown.

Reported-by: NeilBrown <neilb@suse.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Refine discussion of locks when NFSv4 client loses contact with server

Reported-by: NeilBrown <neilb@suse.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: nfsv4leasetime controls the "contact lost" interval for NFSv4

Jeff Layton:
   The difference here is subtle. The gracetime is how long after a reboot
   should knfsd allow clients to reclaim state (and deny the creation of
   new locks and opens). The leasetime is how long the NFSv4 lease period
   is. There is a relationship between the two that's illustrated in the
   comments above write_gracetime:

     /**
      * write_gracetime - Set or report current NFSv4 grace period time
      *
      * As above, but sets the time of the NFSv4 grace period.
      *
      * Note this should never be set to less than the *previous*
      * lease-period time, but we don't try to enforce this.  (In the common
      * case (a new boot), we don't know what the previous lease time was
      * anyway.)
      */

   The value you're interested in here is the nfsv4leasetime. If the
   client doesn't renew its lease within that period, then it's subject to
   the server giving up on it and dropping any state that it holds on that
   clients' behalf.

   Note that this is not a firm timeout. The server runs a job
   periodically to clean out expired stateful objects, and it's likely
   that there is some time (maybe even up to another whole lease period)
   between when the timeout expires and the job actually runs. If the
   client gets a RENEW in there within that window, its lease will be
   renewed and its state preserved.

Reported-by: Jeff Layton <jlayton@poochiereds.net>
Cowritten-by: Jeff Layton <jlayton@poochiereds.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Add NOTES subhead for record locking and NFS

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: wfix + ffix: fine-tuning on NFSv4 client locking text

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Minor change: move some NOTES text on record locking

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Add para introducing advisory locks and noting existence of OFD locks

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Document open file description locks

As provided by the fcntl() operations F_OFD_SETLK,
F_OFD_SETLKW, and F_OFD_GETLK

Signed-off-by: Jeff Layton <jlayton@poochiereds.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Tweaks and rewrites of pieces of Jeff Layton's patch

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: OFD locks are Linux-specific and available since Linux 3.15

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Minor fixes to introductory par on OFD locks

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Detail the limitations of traditional (process-associated) locks

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: Describe semantics for compatible and conflicting OFD locks

And describe how threads can use OFD locks to ensure
exclusive access to a file.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
fcntl.2: CONFORMING TO: note that OFD locks are Linux-specific

But they make their way into the next POSIX release

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>