FAILED: patch "[PATCH] io_uring: fix files cancellation" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From bee749b187ac57d1faf00b2ab356ff322230fce8 Mon Sep 17 00:00:00 2001
From: Pavel Begunkov <[email protected]>
Date: Wed, 25 Nov 2020 02:19:23 +0000
Subject: [PATCH] io_uring: fix files cancellation
io_uring_cancel_files()'s task check condition mistakenly got flipped.
1. There can't be a request in the inflight list without IO_WQ_WORK_FILES, kill this check to keep the whole condition simpler.
2. Also, don't call the function for files==NULL to not do such a check, all that staff is already handled well by its counter part, __io_uring_cancel_task_requests().
With that just flip the task check.
Also, it iowq-cancels all request of current task there, don't forget to set right ->files into struct io_task_cancel.
fs/io_uring.c +4 -4
@@ -8688,15 +8688,14 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx, struct files_struct *files) {while (!list_empty_careful (&ctx->inflight_list)) { -struct io_task_cancel cancel = { .task = task, .files =NULL , }; +struct io_task_cancel cancel = { .task = task, .files = files };struct io_kiocb *req;DEFINE_WAIT (wait);bool found = false;spin_lock_irq (&ctx->inflight_lock);list_for_each_entry (req, &ctx->inflight_list, inflight_entry) { -if (req->task == task && - (req->work.flags &IO_WQ_WORK_FILES ) && +if (req->task != task || req->work.identity->files != files)continue ; found = true;
@@ -8768,10 +8767,11 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,io_cancel_defer_files (ctx, task, files);io_cqring_overflow_flush (ctx, true, task, files); -io_uring_cancel_files (ctx, task, files);if (!files)__io_uring_cancel_task_requests (ctx, task); +else +io_uring_cancel_files (ctx, task, files);if ((ctx->flags &IORING_SETUP_SQPOLL ) && ctx->sq_data) {atomic_dec (&task->io_uring->in_idle);