提交 013538bd 编写于 作者: J Jens Axboe

io_uring: add 'io_comp_state' to struct io_submit_state

No functional changes in this patch, just in preparation for passing back
pending completions to the caller and completing them in a batched
fashion.
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 e1e16097
...@@ -678,6 +678,12 @@ struct io_kiocb { ...@@ -678,6 +678,12 @@ struct io_kiocb {
#define IO_IOPOLL_BATCH 8 #define IO_IOPOLL_BATCH 8
struct io_comp_state {
unsigned int nr;
struct list_head list;
struct io_ring_ctx *ctx;
};
struct io_submit_state { struct io_submit_state {
struct blk_plug plug; struct blk_plug plug;
...@@ -687,6 +693,11 @@ struct io_submit_state { ...@@ -687,6 +693,11 @@ struct io_submit_state {
void *reqs[IO_IOPOLL_BATCH]; void *reqs[IO_IOPOLL_BATCH];
unsigned int free_reqs; unsigned int free_reqs;
/*
* Batch completion logic
*/
struct io_comp_state comp;
/* /*
* File reference cache * File reference cache
*/ */
...@@ -6006,12 +6017,15 @@ static void io_submit_state_end(struct io_submit_state *state) ...@@ -6006,12 +6017,15 @@ static void io_submit_state_end(struct io_submit_state *state)
* Start submission side cache. * Start submission side cache.
*/ */
static void io_submit_state_start(struct io_submit_state *state, static void io_submit_state_start(struct io_submit_state *state,
unsigned int max_ios) struct io_ring_ctx *ctx, unsigned int max_ios)
{ {
blk_start_plug(&state->plug); blk_start_plug(&state->plug);
#ifdef CONFIG_BLOCK #ifdef CONFIG_BLOCK
state->plug.nowait = true; state->plug.nowait = true;
#endif #endif
state->comp.nr = 0;
INIT_LIST_HEAD(&state->comp.list);
state->comp.ctx = ctx;
state->free_reqs = 0; state->free_reqs = 0;
state->file = NULL; state->file = NULL;
state->ios_left = max_ios; state->ios_left = max_ios;
...@@ -6146,7 +6160,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr, ...@@ -6146,7 +6160,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
if (!percpu_ref_tryget_many(&ctx->refs, nr)) if (!percpu_ref_tryget_many(&ctx->refs, nr))
return -EAGAIN; return -EAGAIN;
io_submit_state_start(&state, nr); io_submit_state_start(&state, ctx, nr);
ctx->ring_fd = ring_fd; ctx->ring_fd = ring_fd;
ctx->ring_file = ring_file; ctx->ring_file = ring_file;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册