[Devel] [PATCH RHEL COMMIT] sunrpc: do not place task to sleep if has to be killed

Konstantin Khorenko khorenko at virtuozzo.com
Tue Sep 28 14:42:41 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 217298fd26cc01c1302b6569255f10b1bcca93bc
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date:   Tue Sep 28 14:42:41 2021 +0300

    sunrpc: do not place task to sleep if has to be killed
    
    There might be a situation, when task is expected to be killed, but it's
    execution already passed this check in __rpc_execute() and the task is not yet
    sleeping. In this case it will fall into sleep. I.e. it's a race.
    This patch add check for per-net "kill_tasks" is enabled before going to
    sleep.
    What's good here, is that this check is done with queue->lock being held.
    And tasks killing is also performed with the same lock being held.
    IOW, this lock is a synchronization point, which guarantees us that task will
    either die by itself or killed.
    
    https://jira.sw.ru/browse/PSBM-68214
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
    
    (cherry-picked from vz8 commit 1553a5ef5c72 ("sunrpc: do not place task
    to sleep if has to be killed"))
    
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 net/sunrpc/sched.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index bf7119bd2f25..feaf6e98084d 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -369,6 +369,12 @@ static void __rpc_do_sleep_on_priority(struct rpc_wait_queue *q,
 		struct rpc_task *task,
 		unsigned char queue_priority)
 {
+	if (rpc_abort_task(task)) {
+		rpc_signal_task(task);
+		rpc_exit(task, -EIO);
+		return;
+	}
+
 	trace_rpc_task_sleep(task, q);
 
 	__rpc_add_wait_queue(q, task, queue_priority);


More information about the Devel mailing list