From: "J. Bruce Fields" <bfields@fieldses.org>
To: David Howells <dhowells@redhat.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] AFS: Implement file locking
Date: Sun, 27 May 2007 12:12:52 -0400 [thread overview]
Message-ID: <20070527161252.GA12804@fieldses.org> (raw)
In-Reply-To: <18750.1180255870@redhat.com>
On Sun, May 27, 2007 at 09:51:10AM +0100, David Howells wrote:
> J. Bruce Fields <bfields@fieldses.org> wrote:
> > So if I request a write lock while holding a read lock, my request will
> > be denied?
>
> At the moment, yes. Don't the POSIX and flock lock-handling routines in the
> kernel normally do that anyway?
No, they'd upgrade in that case.
> > This is a little strange, though--if there's somebody waiting for a
> > write lock on an inode (because somebody else already holds a read lock
> > on it), that shouldn't block requests for read locks.
>
> That depends on whether you want fairness or not.
Neither posix nor flock locks delay a lock because of pending
conflicting locks. SUS, as I read it, wouldn't allow that.
> Allowing read locks to jump the queue like this can lead to starvation
> for your writers.
If you want fairness the best that you can do is to ensure that when
more than one pending lock can be applied, the one that has been waiting
longest will be chosen. But you can't make all such lock requests wait
for a lock that hasn't even been applied yet.
You can contrive examples of applications that would be correct given
the standard fcntl behavior, but that would deadlock on a system that
didn't allow read locks to jump the queue in the above situation. I
have no idea whether such applications actually exist in practice, but
I'd be uneasy about changing the standard behavior without inventing
some new kind of lock.
--b.
next prev parent reply other threads:[~2007-05-27 16:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-24 16:55 [PATCH] AFS: Implement file locking David Howells
2007-05-25 7:31 ` Jiri Slaby
2007-05-26 2:23 ` J. Bruce Fields
2007-05-26 3:11 ` Kyle Moffett
2007-05-27 0:12 ` David Howells
2007-05-26 23:55 ` David Howells
2007-05-27 2:25 ` J. Bruce Fields
2007-05-27 8:51 ` David Howells
2007-05-27 16:12 ` J. Bruce Fields [this message]
2007-05-29 9:34 ` David Howells
2007-05-29 20:08 ` J. Bruce Fields
2007-05-29 12:43 ` David Howells
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=20070527161252.GA12804@fieldses.org \
--to=bfields@fieldses.org \
--cc=akpm@osdl.org \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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).