io_uring: reuse io_req_task_queue_fail()
Use io_req_task_queue_fail() on the fail path of io_req_task_queue().
It's unlikely to happen, so don't care about additional overhead, but
allows to keep all the req->result invariant in a single function.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/fs/io_uring.c b/fs/io_uring.c
index db0c4b2..49cdeaf 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2011,18 +2011,6 @@ static void io_req_task_submit(struct callback_head *cb)
__io_req_task_submit(req);
}
-static void io_req_task_queue(struct io_kiocb *req)
-{
- int ret;
-
- req->task_work.func = io_req_task_submit;
- ret = io_req_task_work_add(req);
- if (unlikely(ret)) {
- req->result = -ECANCELED;
- io_req_task_work_add_fallback(req, io_req_task_cancel);
- }
-}
-
static void io_req_task_queue_fail(struct io_kiocb *req, int ret)
{
req->result = ret;
@@ -2032,6 +2020,14 @@ static void io_req_task_queue_fail(struct io_kiocb *req, int ret)
io_req_task_work_add_fallback(req, io_req_task_cancel);
}
+static void io_req_task_queue(struct io_kiocb *req)
+{
+ req->task_work.func = io_req_task_submit;
+
+ if (unlikely(io_req_task_work_add(req)))
+ io_req_task_queue_fail(req, -ECANCELED);
+}
+
static inline void io_queue_next(struct io_kiocb *req)
{
struct io_kiocb *nxt = io_req_find_next(req);