Skip to content

Commit 168e4b3

Browse files
westonandrosadamsonTrond Myklebust
authored andcommitted
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 <dros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 3d70f8c commit 168e4b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/sunrpc/clnt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ EXPORT_SYMBOL_GPL(rpc_killall_tasks);
607607
*/
608608
void rpc_shutdown_client(struct rpc_clnt *clnt)
609609
{
610+
/*
611+
* To avoid deadlock, never call rpc_shutdown_client from a
612+
* workqueue context!
613+
*/
614+
WARN_ON_ONCE(current->flags & PF_WQ_WORKER);
615+
might_sleep();
616+
610617
dprintk_rcu("RPC: shutting down %s client for %s\n",
611618
clnt->cl_protname,
612619
rcu_dereference(clnt->cl_xprt)->servername);

0 commit comments

Comments
 (0)