From: Jeff Layton <jlayton@redhat.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org, teigland@redhat.com
Subject: Re: [PATCH] lockd: handle fl_grant callbacks with coalesced locks (RFC)
Date: Mon, 24 Nov 2008 10:33:13 -0500 [thread overview]
Message-ID: <20081124103313.0c779324@tleilax.poochiereds.net> (raw)
In-Reply-To: <20081122011555.GA28485@fieldses.org>
On Fri, 21 Nov 2008 20:15:55 -0500
"J. Bruce Fields" <bfields@fieldses.org> wrote:
> On Wed, Nov 19, 2008 at 04:37:03PM -0500, Jeff Layton wrote:
> > Dave Teigland opened a bug stating that he was having some problems with
> > DLM and lockd. Essentially, the problem boiled down to the fact that
> > when you do a posix lock of a region that touches another lock, the VFS
> > will coalesce the locks and return a lock that encompasses the whole
> > range.
> >
> > The problem here is that DLM then does a fl_grant callback to lockd with
> > the new coalesced lock. The fl_grant callback then looks through all
> > of the blocks and eventually returns -ENOENT since none match the
> > coalesced lock.
>
> Ugh.
>
My sentiments exactly...
> > I'm having a very hard time tracking down info about how the fl_grant
> > callback is supposed to work. Is it OK to send an fl_grant callback
> > with a lock that's larger than the one requested? If so, then lockd
> > needs to account for that possibility. Also, what exactly is the
> > purpose of the second arg on fl_grant ("conf" in nlmsvc_grant_deferred)?
>
> It's only used in the case the lock failed, and it can optionally be set
> to a copy of the conflicting lock.
>
Ok, good to know. At some point, a file in Documentation on these interfaces
this might be a nice addition...
> > What follows is a patch that changes nlmsvc_grant_deferred to account
> > for the possibility that it may receive an fl_grant that has already
> > been coalesced. It changes nlmsvc_grant_deferred to walk the entire
> > list of blocks and grant any blocks that are covered by the range of
> > the lock in the grant callback, if doing so will not conflict with an
> > earlier grant.
>
> Hm. That might work.
>
It seems to with very basic, cursory testing, but it could be
broken and I'm just not seeing it. This code looks like it's only used
in a NLM over DLM setup though, so it's hard to comprehensively test
it. This scheme is certainly more complex than the current code, though
and I'm not sure I have everything right with it.
> > The patch is still very rough and is probably broken in subtle (and
> > maybe overt) ways, but it fixes the reproducer that Dave provided. It's
> > just intended as a starting point for discussion. Can anyone clarify how
> > fl_grant is supposed to work? Who's wrong here? DLM or NLM?
>
> I think this wasn't thought through, apologies. (It was my
> responsibility to make sure it was!)
>
> I also occasionally think that it would be better to keep any actual
> lock application the caller's responsibility, to the extent that's
> possible--so fl_grant would just be a notification, and it would be up
> to lockd to try the lock again and check the result. That's more or
> less the way it always worked before, and it seems a simpler model.
>
> Some work in the filesystem would be required to make sure it would be
> ready to return an answer on that second request.
>
> I also think there's a problem with lock cancelling in the current code.
>
No worries, I think we can come up with something workable now that we
understand the problem.
When I dug through the mailing list archives, the only thing I could
find on this was this post by you:
http://lkml.org/lkml/2008/4/15/246
...and in particular:
- With fl_grant the filesystem says: I'm giving you the final
result of the lock operation. In particular, if I'm telling
you it succeeded, that means I've already granted you the
lock; don't ask me about it again.
...that seems to contradict what you're suggesting above. I suppose we
could consider changing NLM to use the .fl_notify interface, which you
described as:
- With fl_notify the filesystem says: something just happened to
this lock. I'm not guaranteeing anything, I'm just telling
you this would be a good time to try the lock again. Do it
and maybe you'll get lucky!
...is that what you were suggesting?
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2008-11-24 15:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-19 21:37 [PATCH] lockd: handle fl_grant callbacks with coalesced locks (RFC) Jeff Layton
2008-11-22 1:15 ` J. Bruce Fields
2008-11-24 15:33 ` Jeff Layton [this message]
[not found] ` <20081124103313.0c779324-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-11-24 17:06 ` J. Bruce Fields
2008-11-25 15:12 ` Jeff Layton
2008-12-13 12:40 ` Jeff Layton
[not found] ` <20081213074042.2e8223c3-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-12-16 19:38 ` J. Bruce Fields
2008-12-16 19:56 ` J. Bruce Fields
2008-12-16 21:11 ` Jeff Layton
[not found] ` <20081216161158.2d173667-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-12-17 19:14 ` David Teigland
2008-12-17 20:01 ` J. Bruce Fields
2008-12-17 21:28 ` David Teigland
2009-01-20 23:05 ` J. Bruce Fields
2009-01-20 23:15 ` J. Bruce Fields
2009-01-15 16:30 ` David Teigland
2009-01-19 22:54 ` David Teigland
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=20081124103313.0c779324@tleilax.poochiereds.net \
--to=jlayton@redhat.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=teigland@redhat.com \
/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