]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
io_uring: reliably cancel linked timeouts
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 4 Mar 2021 13:59:25 +0000 (13:59 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 4 Mar 2021 22:45:01 +0000 (15:45 -0700)
Linked timeouts are fired asynchronously (i.e. soft-irq), and use
generic cancellation paths to do its stuff, including poking into io-wq.
The problem is that it's racy to access tctx->io_wq, as
io_uring_task_cancel() and others may be happening at this exact moment.
Mark linked timeouts with REQ_F_INLIFGHT for now, making sure there are
no timeouts before io-wq destraction.

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

index fb4abea1e5d6262b2de3ded998b504ac16652c87..e55369555e5c056291ae05ff3933aae80ff74d99 100644 (file)
@@ -5500,6 +5500,7 @@ static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
 
        data->mode = io_translate_timeout_mode(flags);
        hrtimer_init(&data->timer, CLOCK_MONOTONIC, data->mode);
+       io_req_track_inflight(req);
        return 0;
 }