Skip to content

Commit

Permalink
SUNRPC: add WARN_ON_ONCE for potential deadlock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Weston Andros Adamson authored and Trond Myklebust committed Nov 4, 2012
1 parent 3d70f8c commit 168e4b3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 168e4b3

Please sign in to comment.