mirror of https://gitee.com/openkylin/linux.git
io_uring: move req link into submit_state
Move struct io_submit_link into submit_state, which is a part of a submission state and so belongs to it. It saves us from explicitly passing it, and init/deinit is now nicely hidden in io_submit_state_[start,end]. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
a6b8cadcea
commit
a1ab7b35db
|
@ -283,8 +283,14 @@ struct io_comp_state {
|
|||
struct list_head locked_free_list;
|
||||
};
|
||||
|
||||
struct io_submit_link {
|
||||
struct io_kiocb *head;
|
||||
struct io_kiocb *last;
|
||||
};
|
||||
|
||||
struct io_submit_state {
|
||||
struct blk_plug plug;
|
||||
struct io_submit_link link;
|
||||
|
||||
/*
|
||||
* io_kiocb alloc cache
|
||||
|
@ -6746,15 +6752,10 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct io_submit_link {
|
||||
struct io_kiocb *head;
|
||||
struct io_kiocb *last;
|
||||
};
|
||||
|
||||
static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
|
||||
const struct io_uring_sqe *sqe,
|
||||
struct io_submit_link *link)
|
||||
const struct io_uring_sqe *sqe)
|
||||
{
|
||||
struct io_submit_link *link = &ctx->submit_state.link;
|
||||
int ret;
|
||||
|
||||
ret = io_init_req(ctx, req, sqe);
|
||||
|
@ -6829,6 +6830,8 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
|
|||
static void io_submit_state_end(struct io_submit_state *state,
|
||||
struct io_ring_ctx *ctx)
|
||||
{
|
||||
if (state->link.head)
|
||||
io_queue_link_head(state->link.head);
|
||||
if (state->comp.nr)
|
||||
io_submit_flush_completions(&state->comp, ctx);
|
||||
if (state->plug_started)
|
||||
|
@ -6844,6 +6847,8 @@ static void io_submit_state_start(struct io_submit_state *state,
|
|||
{
|
||||
state->plug_started = false;
|
||||
state->ios_left = max_ios;
|
||||
/* set only head, no need to init link_last in advance */
|
||||
state->link.head = NULL;
|
||||
}
|
||||
|
||||
static void io_commit_sqring(struct io_ring_ctx *ctx)
|
||||
|
@ -6891,7 +6896,6 @@ static const struct io_uring_sqe *io_get_sqe(struct io_ring_ctx *ctx)
|
|||
|
||||
static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
|
||||
{
|
||||
struct io_submit_link link;
|
||||
int submitted = 0;
|
||||
|
||||
/* if we have a backlog and couldn't flush it all, return BUSY */
|
||||
|
@ -6908,9 +6912,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
|
|||
|
||||
percpu_counter_add(¤t->io_uring->inflight, nr);
|
||||
refcount_add(nr, ¤t->usage);
|
||||
|
||||
io_submit_state_start(&ctx->submit_state, nr);
|
||||
link.head = NULL;
|
||||
|
||||
while (submitted < nr) {
|
||||
const struct io_uring_sqe *sqe;
|
||||
|
@ -6929,7 +6931,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
|
|||
}
|
||||
/* will complete beyond this point, count as submitted */
|
||||
submitted++;
|
||||
if (io_submit_sqe(ctx, req, sqe, &link))
|
||||
if (io_submit_sqe(ctx, req, sqe))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -6942,10 +6944,8 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
|
|||
percpu_counter_sub(&tctx->inflight, unused);
|
||||
put_task_struct_many(current, unused);
|
||||
}
|
||||
if (link.head)
|
||||
io_queue_link_head(link.head);
|
||||
io_submit_state_end(&ctx->submit_state, ctx);
|
||||
|
||||
io_submit_state_end(&ctx->submit_state, ctx);
|
||||
/* Commit SQ ring head once we've consumed and submitted all SQEs */
|
||||
io_commit_sqring(ctx);
|
||||
|
||||
|
|
Loading…
Reference in New Issue