1. Rename rpc_kill_tasks to rpc_set_kill_net and add value parameter, so that function can now both enable and disable RPC traffic. 2. Move sn->kill_tasks check to rpc_set_kill_net so that file write function is only responsible for parsing and calling, not for logic checks.
This will allow later usage of rpc_set_kill_net without kill_tasks check duplication. https://virtuozzo.atlassian.net/browse/VSTOR-126316 Feature: improve kill-tasks Signed-off-by: Vladimir Riabchun <[email protected]> --- v2 -> v3: - Rename rpc_kill_tasks and add a new parameter - Support clearing sn->kill_tasks in rpc_set_kill_net net/sunrpc/clnt.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 266cf0fbbad5..0b7f69eb910d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -3406,15 +3406,32 @@ 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) +static void rpc_set_kill_net(struct net *net, bool new_value) { struct rpc_clnt *clnt; struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); + if (sn->kill_tasks == new_value) + return; + + sn->kill_tasks = new_value; + if (!new_value) { + pr_info_ratelimited( + "task (%s:%d) cleared RPC kill_tasks in net [%u]\n", + current->comm, current->pid, net->ns.inum); + return; + } 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); + + pr_info_ratelimited("task (%s:%d) killed RPC in net:[%u]%s\n", + current->comm, current->pid, net->ns.inum, +#ifdef CONFIG_VE + net->owner_ve == &ve0 ? "(host)" : +#endif + ""); } static ssize_t write_kill_tasks(struct file *file, const char __user *buf, @@ -3422,7 +3439,6 @@ static ssize_t write_kill_tasks(struct file *file, const char __user *buf, { 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; @@ -3437,19 +3453,8 @@ static ssize_t write_kill_tasks(struct file *file, const char __user *buf, if (res) return res; - sn->kill_tasks = !!kill_tasks; - - /* Kill pending tasks */ - if (sn->kill_tasks && !prev_kill_tasks) { - rpc_kill_tasks(net); - pr_info_ratelimited( - "kill-tasks: by task (%s:%d) in net:[%u]%s\n", - current->comm, current->pid, net->ns.inum, -#ifdef CONFIG_VE - net->owner_ve == &ve0 ? "(host)" : -#endif - ""); - } + /* Kill pending tasks or forget about previous murder */ + rpc_set_kill_net(net, kill_tasks); return count; } -- 2.47.1 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
