Commit 5182ed2e authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: refactor io_submit_flush_completions

Don't init req_batch before we actually need it. Also, add a small clean
up for req declaration.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/ad85512e12bd3a20d521e9782750300970e5afc8.1624739600.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4cfb25bf
...@@ -2132,22 +2132,22 @@ static void io_submit_flush_completions(struct io_ring_ctx *ctx) ...@@ -2132,22 +2132,22 @@ static void io_submit_flush_completions(struct io_ring_ctx *ctx)
{ {
struct io_comp_state *cs = &ctx->submit_state.comp; struct io_comp_state *cs = &ctx->submit_state.comp;
int i, nr = cs->nr; int i, nr = cs->nr;
struct io_kiocb *req;
struct req_batch rb; struct req_batch rb;
io_init_req_batch(&rb);
spin_lock_irq(&ctx->completion_lock); spin_lock_irq(&ctx->completion_lock);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
req = cs->reqs[i]; struct io_kiocb *req = cs->reqs[i];
__io_cqring_fill_event(ctx, req->user_data, req->result, __io_cqring_fill_event(ctx, req->user_data, req->result,
req->compl.cflags); req->compl.cflags);
} }
io_commit_cqring(ctx); io_commit_cqring(ctx);
spin_unlock_irq(&ctx->completion_lock); spin_unlock_irq(&ctx->completion_lock);
io_cqring_ev_posted(ctx); io_cqring_ev_posted(ctx);
io_init_req_batch(&rb);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
req = cs->reqs[i]; struct io_kiocb *req = cs->reqs[i];
/* submission and completion refs */ /* submission and completion refs */
if (req_ref_sub_and_test(req, 2)) if (req_ref_sub_and_test(req, 2))
......
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