io_uring: simplify reissue in kiocb_done
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 23 Nov 2021 00:07:46 +0000 (00:07 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 23 Nov 2021 19:24:20 +0000 (12:24 -0700)
Simplify failed resubmission prep in kiocb_done(), it's a bit ugly with
conditional logic and hand handling cflags / select buffers. Instead,
punt to tw and use io_req_task_complete() already handling all the
cases.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/667c33484b05b612e9420e1b1d5f4dc46d0ee9ce.1637524285.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index b07196b4511c421a81ddda68a6cde64dbbf717f3..8b7b30835c72c001e9918b85412ed6aed18cf5e3 100644 (file)
@@ -2948,17 +2948,10 @@ static void kiocb_done(struct kiocb *kiocb, ssize_t ret,
                if (io_resubmit_prep(req)) {
                        io_req_task_queue_reissue(req);
                } else {
-                       unsigned int cflags = io_put_rw_kbuf(req);
-                       struct io_ring_ctx *ctx = req->ctx;
-
                        req_set_fail(req);
-                       if (issue_flags & IO_URING_F_UNLOCKED) {
-                               mutex_lock(&ctx->uring_lock);
-                               __io_req_complete(req, issue_flags, ret, cflags);
-                               mutex_unlock(&ctx->uring_lock);
-                       } else {
-                               __io_req_complete(req, issue_flags, ret, cflags);
-                       }
+                       req->result = ret;
+                       req->io_task_work.func = io_req_task_complete;
+                       io_req_task_work_add(req);
                }
        }
 }