This patch aborts SUNRPC tasks upon raise of per-net "kill_tasks" toggle.
This is needed to abort pernding tasks, which are waiting for timeout.

Signed-off-by: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com>
---
 net/sunrpc/clnt.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 2635c49..8543de4 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -2537,6 +2537,20 @@ retry:
 EXPORT_SYMBOL_GPL(rpc_clnt_swap_deactivate);
 #endif /* CONFIG_SUNRPC_SWAP */
 
+static void rpc_kill_tasks(struct net *net)
+{
+       struct rpc_clnt *clnt;
+       struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
+
+       spin_lock(&sn->rpc_client_lock);
+       list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
+               spin_lock(&clnt->cl_lock);
+               xprt_wake_pending_tasks(clnt->cl_xprt, -EIO);
+               spin_unlock(&clnt->cl_lock);
+       }
+       spin_unlock(&sn->rpc_client_lock);
+}
+
 static ssize_t write_kill_tasks(struct file *file, const char __user *buf,
                         size_t count, loff_t *ppos)
 {
@@ -2556,6 +2570,10 @@ static ssize_t write_kill_tasks(struct file *file, const 
char __user *buf,
        if (res)
                return res;
 
+       /* Kill pending tasks */
+       if (kill_tasks && !sn->kill_tasks)
+               rpc_kill_tasks(net);
+
        sn->kill_tasks = !!kill_tasks;
        return count;
 }

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to