public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] Fix hang in posix_locks_deadlock()
@ 2007-10-17 18:51 George G. Davis
  2007-10-17 23:41 ` George G. Davis
  2007-10-18 18:57 ` George G. Davis
  0 siblings, 2 replies; 35+ messages in thread
From: George G. Davis @ 2007-10-17 18:51 UTC (permalink / raw)
  To: linux-kernel

From: Armin Kuster <AKuster@mvista.com>

We have observed hangs in posix_locks_deadlock() when multiple threads
use fcntl(2) F_SETLKW to synchronize file accesses.  The problem appears
to be due to an error in the implementation of posix_locks_deadlock() in
which "goto next_task" is used to break out of the list_for_each_entry()
file_lock search after which the posix_same_owner(caller_fl, block_fl)
test may evaluate to false and the list_for_each_entry() loop restarts
all over again.  This in turn leads to a hang where posix_locks_deadlock()
never returns.  The workaround is to change the posix_same_owner()
test within the list_for_each_entry() loop to directly compare caller_fl
against current fl entry.


Signed-off-by: Armin Kuster <AKuster@mvista.com>
Signed-off-by: George G. Davis <gdavis@mvista.com>

---
Not sure if this is the correct fix but it does resolve the hangs we're
observing in posix_locks_deadlock().  Comments greatly appreciated...

diff --git a/fs/locks.c b/fs/locks.c
index 7f9a3ea..7669a0c 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -702,14 +702,11 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
 {
 	struct file_lock *fl;
 
-next_task:
 	if (posix_same_owner(caller_fl, block_fl))
 		return 1;
 	list_for_each_entry(fl, &blocked_list, fl_link) {
-		if (posix_same_owner(fl, block_fl)) {
-			fl = fl->fl_next;
-			block_fl = fl;
-			goto next_task;
+		if (posix_same_owner(fl, caller_fl)) {
+ 			return 1;
 		}
 	}
 	return 0;

-- 
Regards,
George

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

end of thread, other threads:[~2007-11-02 15:06 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-17 18:51 [RFC][PATCH] Fix hang in posix_locks_deadlock() George G. Davis
2007-10-17 23:41 ` George G. Davis
2007-10-18 18:57 ` George G. Davis
2007-10-26 17:07   ` J. Bruce Fields
2007-10-26 22:47     ` J. Bruce Fields
2007-10-28 17:31       ` [PATCH] locks: fix possible infinite loop in posix deadlock detection J. Bruce Fields
2007-10-28 17:43         ` [RFC, PATCH] locks: remove " J. Bruce Fields
2007-10-28 18:27           ` Matthew Wilcox
2007-10-28 18:40             ` Alan Cox
2007-10-28 20:11               ` Matthew Wilcox
2007-10-28 21:38                 ` Alan Cox
2007-10-28 21:45                   ` Jiri Kosina
2007-10-28 23:38                   ` Matthew Wilcox
2007-10-28 23:44                     ` Alan Cox
2007-10-28 21:50                 ` Trond Myklebust
2007-10-28 22:41                   ` Matthew Wilcox
2007-10-28 22:48                     ` Alan Cox
2007-10-28 22:55                       ` Matthew Wilcox
2007-10-28 23:38                         ` Alan Cox
2007-10-29  2:29                           ` J. Bruce Fields
2007-10-29  8:08                             ` Alan Cox
2007-10-29  9:15                             ` Jiri Kosina
2007-10-30 15:35                               ` J. Bruce Fields
2007-10-28 22:55                     ` Jiri Kosina
2007-10-28 23:31                       ` Matthew Wilcox
2007-10-29  9:11                         ` Jiri Kosina
2007-10-29  2:10                     ` J. Bruce Fields
2007-10-29  3:26                     ` Trond Myklebust
2007-10-29  1:13               ` J. Bruce Fields
2007-10-29  8:06           ` Alan Cox
2007-10-30 15:51             ` J. Bruce Fields
2007-10-30 15:20         ` [PATCH, RESEND] locks: fix possible infinite loop in " J. Bruce Fields
2007-10-30 15:35           ` Alan Cox
2007-10-28 17:47       ` [RFC][PATCH] Fix hang in posix_locks_deadlock() J. Bruce Fields
2007-11-02 15:05     ` George G. Davis

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