summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-06-30 15:20:42 +0300
committerJens Axboe <axboe@kernel.dk>2020-06-30 09:32:04 -0600
commit0be0b0e33b0bfd08264b108512e44b3907fe987b (patch)
tree35088536ae39ccdd6a6340b401756124e25d0402 /fs/io_uring.c
parentea1164e574e9af0a15ab730ead0861a4c7724142 (diff)
downloadlwn-0be0b0e33b0bfd08264b108512e44b3907fe987b.tar.gz
lwn-0be0b0e33b0bfd08264b108512e44b3907fe987b.zip
io_uring: simplify io_async_task_func()
Greatly simplify io_async_task_func() removing duplicated functionality of __io_req_task_submit(). This do one extra spin lock/unlock for cancelled poll case, but that shouldn't happen often. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 2c17c2613205..82b35948ac5b 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4608,7 +4608,6 @@ 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 = false;
trace_io_uring_task_run(req->ctx, req->opcode, req->user_data);
@@ -4618,15 +4617,8 @@ static void io_async_task_func(struct callback_head *cb)
}
/* If req is still hashed, it cannot have been canceled. Don't check. */
- if (hash_hashed(&req->hash_node)) {
+ if (hash_hashed(&req->hash_node))
hash_del(&req->hash_node);
- } else {
- canceled = READ_ONCE(apoll->poll.canceled);
- if (canceled) {
- io_cqring_fill_event(req, -ECANCELED);
- io_commit_cqring(ctx);
- }
- }
spin_unlock_irq(&ctx->completion_lock);
@@ -4635,21 +4627,10 @@ static void io_async_task_func(struct callback_head *cb)
memcpy(&req->work, &apoll->work, sizeof(req->work));
kfree(apoll);
- if (!canceled) {
- __set_current_state(TASK_RUNNING);
- if (io_sq_thread_acquire_mm(ctx, req)) {
- io_cqring_add_event(req, -EFAULT, 0);
- goto end_req;
- }
- mutex_lock(&ctx->uring_lock);
- __io_queue_sqe(req, NULL, NULL);
- mutex_unlock(&ctx->uring_lock);
- } else {
- io_cqring_ev_posted(ctx);
-end_req:
- req_set_fail_links(req);
- io_double_put_req(req);
- }
+ if (!READ_ONCE(apoll->poll.canceled))
+ __io_req_task_submit(req);
+ else
+ __io_req_task_cancel(req, -ECANCELED);
}
static int io_async_wake(struct wait_queue_entry *wait, unsigned mode, int sync,