From: Ken Preslan <kpreslan@redhat.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, sfrench@samba.org
Subject: Re: [PATCH] Allow cluster-wide flock
Date: Tue, 31 Aug 2004 17:42:14 -0500 [thread overview]
Message-ID: <20040831224214.GA28219@potassium.msp.redhat.com> (raw)
In-Reply-To: <1093907129.8729.148.camel@lade.trondhjem.org>
On Mon, Aug 30, 2004 at 07:05:29PM -0400, Trond Myklebust wrote:
> ...
> Firstly, it would be nice to throw out the existing wait loop in
> sys_flock(), and replace it with a call to this new
> flock_lock_file_wait(). I suppose that can be done in a separate cleanup
> patch, though...
> ...
> One solution that I've already suggested to Ken & co is to use a
> separate f_op->flock() call. That would be my preference, since the
> filesystems have to treat flock and posix locks differently anyway.
> ...
Thanks for the suggestions. Below is a patch that implements both of
them.
diff -urN -p linux-2.6.9-rc1-mm2/fs/locks.c linux/fs/locks.c
--- linux-2.6.9-rc1-mm2/fs/locks.c 2004-08-31 16:44:58.385205028 -0500
+++ linux/fs/locks.c 2004-08-31 16:45:03.260092514 -0500
@@ -1392,24 +1392,12 @@ asmlinkage long sys_flock(unsigned int f
if (error)
goto out_free;
- if (filp->f_op && filp->f_op->lock) {
- error = filp->f_op->lock(filp,
- (can_sleep) ? F_SETLKW : F_SETLK,
- lock);
- goto out_free;
- }
-
- for (;;) {
- error = flock_lock_file(filp, lock);
- if ((error != -EAGAIN) || !can_sleep)
- break;
- error = wait_event_interruptible(lock->fl_wait, !lock->fl_next);
- if (!error)
- continue;
-
- locks_delete_block(lock);
- break;
- }
+ if (filp->f_op && filp->f_op->flock)
+ error = filp->f_op->flock(filp,
+ (can_sleep) ? F_SETLKW : F_SETLK,
+ lock);
+ else
+ error = flock_lock_file_wait(filp, lock);
out_free:
if (list_empty(&lock->fl_link)) {
@@ -1766,10 +1754,10 @@ void locks_remove_flock(struct file *fil
if (!inode->i_flock)
return;
- if (filp->f_op && filp->f_op->lock) {
+ if (filp->f_op && filp->f_op->flock) {
struct file_lock fl = { .fl_flags = FL_FLOCK,
.fl_type = F_UNLCK };
- filp->f_op->lock(filp, F_SETLKW, &fl);
+ filp->f_op->flock(filp, F_SETLKW, &fl);
}
lock_kernel();
diff -urN -p linux-2.6.9-rc1-mm2/include/linux/fs.h linux/include/linux/fs.h
--- linux-2.6.9-rc1-mm2/include/linux/fs.h 2004-08-31 16:44:58.386204800 -0500
+++ linux/include/linux/fs.h 2004-08-31 16:45:03.261092285 -0500
@@ -983,6 +983,7 @@ struct file_operations {
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
int (*check_flags)(int);
int (*dir_notify)(struct file *filp, unsigned long arg);
+ int (*flock) (struct file *, int, struct file_lock *);
};
struct inode_operations {
--
Ken Preslan <kpreslan@redhat.com>
next prev parent reply other threads:[~2004-08-31 22:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-30 23:05 [PATCH] Allow cluster-wide flock Trond Myklebust
2004-08-31 22:42 ` Ken Preslan [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-08-31 3:11 Steve French
2004-08-30 15:19 Ken Preslan
2004-08-30 14:35 ` Alan Cox
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=20040831224214.GA28219@potassium.msp.redhat.com \
--to=kpreslan@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sfrench@samba.org \
--cc=trond.myklebust@fys.uio.no \
/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