public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/locks.c: Fix posix locking for threaded tasks
@ 2002-06-10  2:48 Matthew Wilcox
  2002-06-10  6:41 ` Andreas Dilger
  2002-06-12  9:40 ` Alan Cox
  0 siblings, 2 replies; 8+ messages in thread
From: Matthew Wilcox @ 2002-06-10  2:48 UTC (permalink / raw)
  To: Linus Torvalds, Marcelo Tosatti
  Cc: Saurabh Desai, Stephen Rothwell, linux-kernel


Saurabh Desai believes that locks created by threads should not conflict
with each other.  I'm inclined to agree; I don't know why the test for
->fl_pid was added, but the comment suggests that whoever added it wasn't
sure either.

Frankly, I have no clue about the intended semantics for threads, and
SUS v3 does not offer any enlightenment.  But it seems reasonable that
processes which share a files_struct should share locks.  After all,
if one process closes the fd, they'll remove locks belonging to the
other process.

Here's a patch generated against 2.4; it also applies to 2.5.
Please apply.

===== fs/locks.c 1.9 vs edited =====
--- 1.9/fs/locks.c	Mon Jun  3 18:49:43 2002
+++ edited/fs/locks.c	Fri Jun  7 21:24:12 2002
@@ -380,15 +380,12 @@
 }
 
 /*
- * Check whether two locks have the same owner
- * N.B. Do we need the test on PID as well as owner?
- * (Clone tasks should be considered as one "owner".)
+ * Locks are deemed to have the same owner if the tasks share files_struct.
  */
 static inline int
 locks_same_owner(struct file_lock *fl1, struct file_lock *fl2)
 {
-	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.

-- 
Revolutions do not require corporate support.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-06-12 22:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-10  2:48 [PATCH] fs/locks.c: Fix posix locking for threaded tasks Matthew Wilcox
2002-06-10  6:41 ` Andreas Dilger
2002-06-10 12:41   ` Matthew Wilcox
2002-06-10 20:30     ` Matthew Wilcox
2002-06-12  9:40 ` Alan Cox
2002-06-12 11:45   ` Matthew Wilcox
2002-06-12 22:18     ` Saurabh Desai
2002-06-12 22:33       ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox