diff options
author | Jens Axboe <axboe@kernel.dk> | 2020-04-13 11:16:34 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-04-13 11:22:52 -0600 |
commit | 2bae047ec9576da72d5003487de0bb93e747fff7 (patch) | |
tree | 51ea48b19baf2d062a97457b30047b3440c565d6 /fs/io_uring.c | |
parent | 74ce6ce43d4fc6ce15efb21378d9ef26125c298b (diff) | |
download | linux-2bae047ec9576da72d5003487de0bb93e747fff7.tar.bz2 |
io_uring: io_async_task_func() should check and honor cancelation
If the request has been marked as canceled, don't try and issue it.
Instead just fill a canceled event and finish the request.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 7b41f6231955..aac54772e12e 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4181,6 +4181,7 @@ static void io_async_task_func(struct callback_head *cb) struct io_kiocb *req = container_of(cb, struct io_kiocb, task_work); struct async_poll *apoll = req->apoll; struct io_ring_ctx *ctx = req->ctx; + bool canceled; trace_io_uring_task_run(req->ctx, req->opcode, req->user_data); @@ -4192,8 +4193,22 @@ static void io_async_task_func(struct callback_head *cb) if (hash_hashed(&req->hash_node)) hash_del(&req->hash_node); + canceled = READ_ONCE(apoll->poll.canceled); + if (canceled) { + io_cqring_fill_event(req, -ECANCELED); + io_commit_cqring(ctx); + } + spin_unlock_irq(&ctx->completion_lock); + if (canceled) { + kfree(apoll); + io_cqring_ev_posted(ctx); + req_set_fail_links(req); + io_put_req(req); + return; + } + /* restore ->work in case we need to retry again */ memcpy(&req->work, &apoll->work, sizeof(req->work)); |