Commit 2c4b8eb6 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

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: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e83acd7d
...@@ -2011,25 +2011,21 @@ static void io_req_task_submit(struct callback_head *cb) ...@@ -2011,25 +2011,21 @@ static void io_req_task_submit(struct callback_head *cb)
__io_req_task_submit(req); __io_req_task_submit(req);
} }
static void io_req_task_queue(struct io_kiocb *req) static void io_req_task_queue_fail(struct io_kiocb *req, int ret)
{ {
int ret; req->result = ret;
req->task_work.func = io_req_task_cancel;
req->task_work.func = io_req_task_submit; if (unlikely(io_req_task_work_add(req)))
ret = io_req_task_work_add(req);
if (unlikely(ret)) {
req->result = -ECANCELED;
io_req_task_work_add_fallback(req, io_req_task_cancel); io_req_task_work_add_fallback(req, io_req_task_cancel);
}
} }
static void io_req_task_queue_fail(struct io_kiocb *req, int ret) static void io_req_task_queue(struct io_kiocb *req)
{ {
req->result = ret; req->task_work.func = io_req_task_submit;
req->task_work.func = io_req_task_cancel;
if (unlikely(io_req_task_work_add(req))) if (unlikely(io_req_task_work_add(req)))
io_req_task_work_add_fallback(req, io_req_task_cancel); io_req_task_queue_fail(req, -ECANCELED);
} }
static inline void io_queue_next(struct io_kiocb *req) static inline void io_queue_next(struct io_kiocb *req)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment