From: Chuck Lever Date: Mon, 26 Aug 2002 04:01:55 +0000 (-0700) Subject: [PATCH] eliminate hangs during RPC client shutdown X-Git-Tag: v2.5.32~19 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=c5983232ad0bf91e2a866d4b4c1607fefc0a4957;p=history.git [PATCH] eliminate hangs during RPC client shutdown this eliminates an infinite loop in rpciod if an RPC client's reference counter accidentally goes negative. i've been running this under load since 2.5.30 with no ill effects. --- diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 048978395042..984342395ac7 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -138,19 +138,27 @@ out_no_auth: int rpc_shutdown_client(struct rpc_clnt *clnt) { - dprintk("RPC: shutting down %s client for %s\n", - clnt->cl_protname, clnt->cl_server); - while (atomic_read(&clnt->cl_users)) { -#ifdef RPC_DEBUG - dprintk("RPC: rpc_shutdown_client: client %s, tasks=%d\n", - clnt->cl_protname, atomic_read(&clnt->cl_users)); -#endif + dprintk("RPC: shutting down %s client for %s, tasks=%d\n", + clnt->cl_protname, clnt->cl_server, + atomic_read(&clnt->cl_users)); + + while (atomic_read(&clnt->cl_users) > 0) { /* Don't let rpc_release_client destroy us */ clnt->cl_oneshot = 0; clnt->cl_dead = 0; rpc_killall_tasks(clnt); sleep_on_timeout(&destroy_wait, 1*HZ); } + + if (atomic_read(&clnt->cl_users) < 0) { + printk(KERN_ERR "RPC: rpc_shutdown_client clnt %p tasks=%d\n", + clnt, atomic_read(&clnt->cl_users)); +#ifdef RPC_DEBUG + rpc_show_tasks(); +#endif + BUG(); + } + return rpc_destroy_client(clnt); }