Commit 291b2821 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: simplify io_alloc_req()

Extract common code from if/else branches. That is cleaner and optimised
even better.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 145cc8c6
...@@ -1650,10 +1650,8 @@ static struct io_kiocb *io_get_fallback_req(struct io_ring_ctx *ctx) ...@@ -1650,10 +1650,8 @@ static struct io_kiocb *io_get_fallback_req(struct io_ring_ctx *ctx)
static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx, static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx,
struct io_submit_state *state) struct io_submit_state *state)
{ {
gfp_t gfp = GFP_KERNEL | __GFP_NOWARN;
struct io_kiocb *req;
if (!state->free_reqs) { if (!state->free_reqs) {
gfp_t gfp = GFP_KERNEL | __GFP_NOWARN;
size_t sz; size_t sz;
int ret; int ret;
...@@ -1670,14 +1668,11 @@ static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx, ...@@ -1670,14 +1668,11 @@ static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx,
goto fallback; goto fallback;
ret = 1; ret = 1;
} }
state->free_reqs = ret - 1; state->free_reqs = ret;
req = state->reqs[ret - 1];
} else {
state->free_reqs--;
req = state->reqs[state->free_reqs];
} }
return req; state->free_reqs--;
return state->reqs[state->free_reqs];
fallback: fallback:
return io_get_fallback_req(ctx); return io_get_fallback_req(ctx);
} }
......
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