[Devel,RHEL7,COMMIT] sunrpc: pending tasks kill helper added

Submitted by Konstantin Khorenko on June 27, 2017, 10:05 a.m.

Details

Message ID 201706271005.v5RA5tDo027611@finist_cl7.x64_64.work.ct
State New
Series "Kill SUNRPC tasks on container fast stop"
Headers show

Commit Message

Konstantin Khorenko June 27, 2017, 10:05 a.m.
The commit is pushed to "branch-rh7-3.10.0-514.16.1.vz7.32.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.16.1.vz7.32.11
------>
commit eddce79feb06bcf28a536166049b6df275c573ac
Author: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Date:   Tue Jun 27 14:05:55 2017 +0400

    sunrpc: pending tasks kill helper added
    
    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.
    
    https://jira.sw.ru/browse/PSBM-66510
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 net/sunrpc/clnt.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Patch hide | download patch | download mbox

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;
 }