fcntl.2: Explain behaviour of F_GETLEASE during lease break

Here's a patch to the fcntl.2 manpage that explains
the working of F_GETLEASE in a bit more detail during
lease breaks. Basically, what happens is this: When a
lease break is initiated by a lease breaker, subsequent
F_GETLEASE calls return the target lease type after
the lease break and not the existing lease type. This
behavior persists until the lease holder downgrades/unlocks
the lease or the kernel forcibly does it after the lease
break timeout expires.

The implicit assumption is that F_GETLEASE should
return the existing lock type until the downgrade/unlock
has actually taken place, which is not true. I've verified
that the kernel indeed returns the target lease type. It
is also simple enough to verify this behavior in a small
program, where you can observe that the lease type
returned by F_GETLEASE in the signal handler for a
lease break is different from the existing lease type.

Signed-off-by: Abhijith Das <adas@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Abhijith Das 2012-04-15 09:49:21 +12:00 committed by Michael Kerrisk
parent a05228ea3a
commit a8ceabbc8c
1 changed files with 11 additions and 1 deletions

View File

@ -58,7 +58,7 @@
.\" 2010-06-17, Michael Kerrisk
.\" Document F_SETPIPE_SZ and F_GETPIPE_SZ.
.\"
.TH FCNTL 2 2012-03-25 "Linux" "Linux Programmer's Manual"
.TH FCNTL 2 2012-04-15 "Linux" "Linux Programmer's Manual"
.SH NAME
fcntl \- manipulate file descriptor
.SH SYNOPSIS
@ -865,6 +865,16 @@ the number of seconds specified in
.I /proc/sys/fs/lease-break-time
then the kernel forcibly removes or downgrades the lease holder's lease.
Once a lease break has been initiated,
.B F_GETLEASE
returns the target lease type (either
.B F_RDLCK
or
.BR F_UNLCK ,
depending on what would be compatible with the lease breaker)
until the lease holder voluntarily downgrades or removes the lease or
the kernel forcibly does so after the lease break timer expires.
Once the lease has been voluntarily or forcibly removed or downgraded,
and assuming the lease breaker has not unblocked its system call,
the kernel permits the lease breaker's system call to proceed.