From: Weston Andros Adamson Date: Tue, 30 Oct 2012 21:01:40 +0000 (-0400) Subject: SUNRPC: add WARN_ON_ONCE for potential deadlock X-Git-Tag: next-20121101~86^2~16 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1b58f88c3f137875bff2ed382194ea56bda5fc9a;p=karo-tx-linux.git SUNRPC: add WARN_ON_ONCE for potential deadlock rpc_shutdown_client should never be called from a workqueue context. If it is, it could deadlock looping forever trying to kill tasks that are assigned to the same kworker thread (and will never run rpc_exit_task). Signed-off-by: Weston Andros Adamson Signed-off-by: Trond Myklebust --- diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index cdc7564b4512..dd2532c10324 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -607,6 +607,13 @@ EXPORT_SYMBOL_GPL(rpc_killall_tasks); */ void rpc_shutdown_client(struct rpc_clnt *clnt) { + /* + * To avoid deadlock, never call rpc_shutdown_client from a + * workqueue context! + */ + WARN_ON_ONCE(current->flags & PF_WQ_WORKER); + might_sleep(); + dprintk_rcu("RPC: shutting down %s client for %s\n", clnt->cl_protname, rcu_dereference(clnt->cl_xprt)->servername);