SUNRPC: add WARN_ON_ONCE for potential deadlock
authorWeston Andros Adamson <dros@netapp.com>
Tue, 30 Oct 2012 21:01:40 +0000 (17:01 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Sun, 4 Nov 2012 19:43:38 +0000 (14:43 -0500)
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 <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/clnt.c

index cdc7564b4512d7f79606bc87fb7726a668a9b9a0..dd2532c10324cd11b67f4d7bda1e427a7e76fbd3 100644 (file)
@@ -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);