Commit de59bc10 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: fail links more in io_submit_sqe()

Instead of marking a link with REQ_F_FAIL_LINK on an error and delaying
its failing to the caller, do it eagerly right when after getting an
error in io_submit_sqe(). This renders FAIL_LINK checks in
io_queue_link_head() useless and we can skip it.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 1ee43ba8
...@@ -6645,15 +6645,6 @@ static void io_queue_sqe(struct io_kiocb *req) ...@@ -6645,15 +6645,6 @@ static void io_queue_sqe(struct io_kiocb *req)
} }
} }
static inline void io_queue_link_head(struct io_kiocb *req)
{
if (unlikely(req->flags & REQ_F_FAIL_LINK)) {
io_put_req(req);
io_req_complete(req, -ECANCELED);
} else
io_queue_sqe(req);
}
/* /*
* Check SQE restrictions (opcode and flags). * Check SQE restrictions (opcode and flags).
* *
...@@ -6768,9 +6759,13 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, ...@@ -6768,9 +6759,13 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
fail_req: fail_req:
io_put_req(req); io_put_req(req);
io_req_complete(req, ret); io_req_complete(req, ret);
if (link->head) {
/* fail even hard links since we don't submit */ /* fail even hard links since we don't submit */
if (link->head)
link->head->flags |= REQ_F_FAIL_LINK; link->head->flags |= REQ_F_FAIL_LINK;
io_put_req(link->head);
io_req_complete(link->head, -ECANCELED);
link->head = NULL;
}
return ret; return ret;
} }
ret = io_req_prep(req, sqe); ret = io_req_prep(req, sqe);
...@@ -6811,7 +6806,7 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, ...@@ -6811,7 +6806,7 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
/* last request of a link, enqueue the link */ /* last request of a link, enqueue the link */
if (!(req->flags & (REQ_F_LINK | REQ_F_HARDLINK))) { if (!(req->flags & (REQ_F_LINK | REQ_F_HARDLINK))) {
io_queue_link_head(head); io_queue_sqe(head);
link->head = NULL; link->head = NULL;
} }
} else { } else {
...@@ -6837,7 +6832,7 @@ static void io_submit_state_end(struct io_submit_state *state, ...@@ -6837,7 +6832,7 @@ static void io_submit_state_end(struct io_submit_state *state,
struct io_ring_ctx *ctx) struct io_ring_ctx *ctx)
{ {
if (state->link.head) if (state->link.head)
io_queue_link_head(state->link.head); io_queue_sqe(state->link.head);
if (state->comp.nr) if (state->comp.nr)
io_submit_flush_completions(&state->comp, ctx); io_submit_flush_completions(&state->comp, ctx);
if (state->plug_started) if (state->plug_started)
......
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