From: Trond Myklebust Date: Thu, 10 Apr 2008 17:55:48 -0400 SUNRPC: Add a helper rpc_drain_client() Signed-off-by: Trond Myklebust --- net/sunrpc/clnt.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index fc7e539..d424e66 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -373,6 +373,26 @@ out_no_clnt: } EXPORT_SYMBOL_GPL(rpc_clone_client); +static void rpc_drain_client(struct rpc_clnt *clnt, int timeout_secs) +{ + struct rpc_task *task; + int i; + + spin_lock(&clnt->cl_lock); + list_for_each_entry(task, &clnt->cl_tasks, tk_task) { + if (atomic_inc_not_zero(&task->count) == 0) + continue; + spin_unlock(&clnt->cl_lock); + while (timeout_secs != 0) { + if (__rpc_wait_for_completion_task(task, + rpc_wait_bit)); + } + rpc_put_task(task); + spin_lock(&clnt->cl_lock); + } + spin_unlock(&clnt->cl_lock); +} + /* * Properly shut down an RPC client, terminating all outstanding * requests.