io_uring: choose right tctx->io_wq for try cancel
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 1 Mar 2021 18:20:45 +0000 (18:20 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 4 Mar 2021 13:38:03 +0000 (06:38 -0700)
When we cancel SQPOLL, @task in io_uring_try_cancel_requests() will
differ from current. Use the right tctx from passed in @task, and don't
forget that it can be NULL when the io_uring ctx exits.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 361befa..d6c5465 100644 (file)
@@ -8636,7 +8636,8 @@ static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
                                         struct files_struct *files)
 {
        struct io_task_cancel cancel = { .task = task, .files = files, };
-       struct io_uring_task *tctx = current->io_uring;
+       struct task_struct *tctx_task = task ?: current;
+       struct io_uring_task *tctx = tctx_task->io_uring;
 
        while (1) {
                enum io_wq_cancel cret;