linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: ams@gnu.org
Cc: libc-alpha@sourceware.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, tytso@mit.edu, dalias@libc.org,
	mtk.manpages@gmail.com, samba-technical@lists.samba.org,
	nfs-ganesha-devel@lists.sourceforge.net, carlos@redhat.com,
	metze@samba.org, hch@infradead.org, bharrosh@panasas.com
Subject: Re: [RFC][glibc PATCH] fcntl-linux.h: add new definitions and manual updates for open file description locks
Date: Wed, 23 Apr 2014 15:23:18 -0400	[thread overview]
Message-ID: <20140423152318.117f291b@tlielax.poochiereds.net> (raw)
In-Reply-To: <E1Wd2Os-00061e-GU@fencepost.gnu.org>

On Wed, 23 Apr 2014 15:00:06 -0400
ams@gnu.org (Alfred M. Szmidt) wrote:

>    > Likewise.  You infact write that it does get the lock information
>    > later in the document wrt. F_OFD_GETLK.
> 
>    Sorry, I disagree here...GETLK is really a misnomer, IMO. TESTLK
>    would have been a better name.
> 
>    GETLK are used is to "get the first lock".
> 
>    It's a way to test whether a particular lock can be applied, and to
>    return information about a conflicting lock if it can't. If, for
>    instance there is no conflicting lock, then you don't "get" any
>    lock information back (l_type just gets reset to F_UNLCK).
> 
> While I kinda see your point, it isn't what GETLK does; it really does
> get you information about the first lock -- you're not testing
> anything.  It is also the terminology used in the POSIX standard.


You *are* testing a lock.

For instance, a process has locked bytes 0-5 for read in the file. I
then submit a F_GETLK request from another process and set:

    l_type = F_WRLCK
    l_start = 7
    l_len = 1

...this range does not overlap with the original range, and so no lock
will be returned even though one is being held on the file. In order to
determine whether it should return information about a lock it has to
first _test_ whether it conflicts with the information in the struct
flock that was passed down.

Similarly, if the struct flock I submit to the F_GETLK request has this:

   l_type = F_RDLCK
   l_start = 0
   l_len = 1

...then I also will not get any information about a lock back. The
information in the lock request does not conflict with the one being
held on the file (because they are both read locks).

If F_GETLK were just "getting" a lock, then there would be no test
involved, but that's not how this works. F_GETLK has to test and see
whether there is a conflicting lock before it can return anything.

If all you're objecting to is the change in verbiage on those two
pieces, then I'll back that part out in the interest of wrapping this
up.

I still think I'm correct though ;)

-- 
Jeff Layton <jlayton@redhat.com>

      parent reply	other threads:[~2014-04-23 19:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-23 11:39 [RFC][glibc PATCH] fcntl-linux.h: add new definitions and manual updates for open file description locks Jeff Layton
2014-04-23 12:37 ` Michael Kerrisk (man-pages)
2014-04-23 15:09 ` Alfred M. Szmidt
2014-04-23 15:28   ` Jeff Layton
2014-04-23 19:00     ` Alfred M. Szmidt
2014-04-23 19:13       ` Michael Kerrisk (man-pages)
2014-04-23 19:23       ` Jeff Layton [this message]

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=20140423152318.117f291b@tlielax.poochiereds.net \
    --to=jlayton@redhat.com \
    --cc=ams@gnu.org \
    --cc=bharrosh@panasas.com \
    --cc=carlos@redhat.com \
    --cc=dalias@libc.org \
    --cc=hch@infradead.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=mtk.manpages@gmail.com \
    --cc=nfs-ganesha-devel@lists.sourceforge.net \
    --cc=samba-technical@lists.samba.org \
    --cc=tytso@mit.edu \
    /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).