All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] prevent sunrpc deadlock with debug on
@ 2004-12-16 16:57 Olaf Kirch
  2004-12-28 23:43 ` Trond Myklebust
  0 siblings, 1 reply; 4+ messages in thread
From: Olaf Kirch @ 2004-12-16 16:57 UTC (permalink / raw)
  To: nfs

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]

Here's a patch we added to our kernel a while ago, but which
I forgot to submit... here it is.

Olaf
-- 
Olaf Kirch     | Things that make Monday morning interesting, #2:
okir@suse.de   |        "We have 8,000 NFS mount points, why do we keep
---------------+ 	 running out of privileged ports?"

[-- Attachment #2: sunrpc-sched-deadlock --]
[-- Type: text/plain, Size: 1293 bytes --]

From: Shirly Ma <xma@us.ibm.com>
Subject: Prevent sunrpc deadlock with debugging turned on
References: 38960

This patch fixes a deadlock in the RPC code when debugging is enabled.

CPU 1:
	rpc_wake_up_task
		spin_lock_bh(&rpc_queue_lock);
		-> __rpc_wake_up_task
			-> rpc_show_tasks
				-> spin_lock(&rpc_sched_lock);

CPU 2:
	rpc_killall_tasks
		spin_lock(&rpc_sched_lock);
		-> rpc_wake_up_task()
			spin_lock_bh(&rpc_queue_lock);

This is a very rare condition, but it was actually observed several times
during test runs on ppc64.

Signed-off-by: Olaf Kirch <okir@suse.de>

diff -urN linux-2.6.5-7.13/net/sunrpc/sched.c linux-2.6.5-7.13p/net/sunrpc/sched.c
--- linux-2.6.5-7.13/net/sunrpc/sched.c	2004-04-30 10:46:58.000000000 -0500
+++ linux-2.6.5-7.13p/net/sunrpc/sched.c	2004-04-30 17:21:05.000000000 -0500
@@ -931,12 +931,16 @@
 	/*
 	 * Spin lock all_tasks to prevent changes...
 	 */
+again:
 	spin_lock(&rpc_sched_lock);
 	alltask_for_each(rovr, le, &all_tasks)
-		if (!clnt || rovr->tk_client == clnt) {
+		if (!(rovr->tk_flags & RPC_TASK_KILLED) && 
+		    (!clnt || rovr->tk_client == clnt)) {
 			rovr->tk_flags |= RPC_TASK_KILLED;
 			rpc_exit(rovr, -EIO);
+			spin_unlock(&rpc_sched_lock);
 			rpc_wake_up_task(rovr);
+			goto again;
 		}
 	spin_unlock(&rpc_sched_lock);
 }

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

end of thread, other threads:[~2005-01-05 17:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-16 16:57 [PATCH] prevent sunrpc deadlock with debug on Olaf Kirch
2004-12-28 23:43 ` Trond Myklebust
2005-01-05 16:44   ` Olaf Kirch
2005-01-05 17:21     ` Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.