* PATCH [1/7] Fix posix locking code
@ 2004-08-14 19:29 Trond Myklebust
2004-08-14 19:37 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: Trond Myklebust @ 2004-08-14 19:29 UTC (permalink / raw)
To: Linux Filesystem Development, linux-kernel, Linus Torvalds,
Andrew Morton
VFS: Fix up posix_same_owner() so that it only uses the
file_lock->fl_owner field when determining lock equality.
VFS: Fix up posix locking routines to use posix_same_owner() instead
of rolling their own checks.
Signed-off-by: Trond Myklebust <trond.myklebust@fys.uio.no>
locks.c | 27 ++++++++++-----------------
1 files changed, 10 insertions(+), 17 deletions(-)
diff -u --recursive --new-file --show-c-function linux-2.6.8.1/fs/locks.c linux-2.6.8.1-01-fix_locks/fs/locks.c
--- linux-2.6.8.1/fs/locks.c 2004-08-14 14:27:44.000000000 -0400
+++ linux-2.6.8.1-01-fix_locks/fs/locks.c 2004-08-14 14:28:58.000000000 -0400
@@ -414,14 +414,16 @@ static inline int locks_overlap(struct f
}
/*
- * Check whether two locks have the same owner. The apparently superfluous
- * check for fl_pid enables us to distinguish between locks set by lockd.
+ * Check whether two locks have the same owner.
*/
static inline int
posix_same_owner(struct file_lock *fl1, struct file_lock *fl2)
{
- return (fl1->fl_owner == fl2->fl_owner) &&
- (fl1->fl_pid == fl2->fl_pid);
+ /* FIXME: Replace this sort of thing with struct file_lock_operations */
+ if ((fl1->fl_type | fl2->fl_type) & FL_LOCKD)
+ return fl1->fl_owner == fl2->fl_owner &&
+ fl1->fl_pid == fl2->fl_pid;
+ return fl1->fl_owner == fl2->fl_owner;
}
/* Remove waiter from blocker's block list.
@@ -631,24 +633,15 @@ int posix_locks_deadlock(struct file_loc
struct file_lock *block_fl)
{
struct list_head *tmp;
- fl_owner_t caller_owner, blocked_owner;
- unsigned int caller_pid, blocked_pid;
-
- caller_owner = caller_fl->fl_owner;
- caller_pid = caller_fl->fl_pid;
- blocked_owner = block_fl->fl_owner;
- blocked_pid = block_fl->fl_pid;
next_task:
- if (caller_owner == blocked_owner && caller_pid == blocked_pid)
+ if (posix_same_owner(caller_fl, block_fl))
return 1;
list_for_each(tmp, &blocked_list) {
struct file_lock *fl = list_entry(tmp, struct file_lock, fl_link);
- if ((fl->fl_owner == blocked_owner)
- && (fl->fl_pid == blocked_pid)) {
+ if (posix_same_owner(fl, block_fl)) {
fl = fl->fl_next;
- blocked_owner = fl->fl_owner;
- blocked_pid = fl->fl_pid;
+ block_fl = fl;
goto next_task;
}
}
@@ -1684,7 +1677,7 @@ void locks_remove_posix(struct file *fil
lock_kernel();
while (*before != NULL) {
struct file_lock *fl = *before;
- if (IS_POSIX(fl) && (fl->fl_owner == owner)) {
+ if (IS_POSIX(fl) && posix_same_owner(fl, &lock)) {
locks_delete_lock(before);
continue;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH [1/7] Fix posix locking code
2004-08-14 19:29 PATCH [1/7] Fix posix locking code Trond Myklebust
@ 2004-08-14 19:37 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2004-08-14 19:37 UTC (permalink / raw)
To: Trond Myklebust
Cc: Linux Filesystem Development, linux-kernel, Linus Torvalds,
Andrew Morton
On Sat, Aug 14, 2004 at 03:29:02PM -0400, Trond Myklebust wrote:
> VFS: Fix up posix_same_owner() so that it only uses the
> file_lock->fl_owner field when determining lock equality.
>
> VFS: Fix up posix locking routines to use posix_same_owner() instead
> of rolling their own checks.
>
> Signed-off-by: Trond Myklebust <trond.myklebust@fys.uio.no>
I like this patch. Please apply.
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-08-14 19:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-14 19:29 PATCH [1/7] Fix posix locking code Trond Myklebust
2004-08-14 19:37 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®