[Devel] [PATCH RHEL COMMIT] sunrpc: pending tasks kill helper added
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Sep 28 14:42:40 MSK 2021
The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 8c8eb5292bae57a202cfe6b3240fe1e885585b3a
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date: Tue Sep 28 14:42:40 2021 +0300
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.
There could be a situation, when RPC task is not yet sleeping, but already
passed the check for "kill_tasks" in __rpc_execute().
There is a race in such a case, because task will fall into sleep anyway.
This patch makes this probability a little bit less.
https://jira.sw.ru/browse/PSBM-66510
https://jira.sw.ru/browse/PSBM-68214
rpc_killall_tasks helper is much better.
First, is's in upsteam (I wrote it, but forgot :( ).
Second, it kills *all* tasks (including sleeping in other than "pending"
queues).
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
(cherry-picked from vz8 commit 67bab1f08957 ("sunrpc: pending tasks kill
helper added"))
Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
net/sunrpc/clnt.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index c1415984a21e..7ec1b4a06515 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -3072,11 +3072,23 @@ rpc_clnt_swap_deactivate(struct rpc_clnt *clnt)
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)
+ rpc_killall_tasks(clnt);
+ 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)
{
struct net *net = PDE_DATA(file->f_path.dentry->d_inode);
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
+ bool prev_kill_tasks = sn->kill_tasks;
char tbuf[20];
unsigned long kill_tasks;
int res;
@@ -3092,6 +3104,11 @@ static ssize_t write_kill_tasks(struct file *file, const char __user *buf,
return res;
sn->kill_tasks = !!kill_tasks;
+
+ /* Kill pending tasks */
+ if (sn->kill_tasks && !prev_kill_tasks)
+ rpc_kill_tasks(net);
+
return count;
}
More information about the Devel
mailing list