diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2020-09-30 22:57:01 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-09-30 20:38:45 -0600 |
commit | 291b2821e072e16b062c5a0e83f7642143c4399a (patch) | |
tree | 13c49761dfeaac08ebe8c248c89afcb27b2f9790 | |
parent | 145cc8c665f406cc189cfcf15a9875689e2c73b8 (diff) |
io_uring: simplify io_alloc_req()
Extract common code from if/else branches. That is cleaner and optimised
even better.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index fcb4e95cb88d..cdd59467576d 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -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, struct io_submit_state *state) { - gfp_t gfp = GFP_KERNEL | __GFP_NOWARN; - struct io_kiocb *req; - if (!state->free_reqs) { + gfp_t gfp = GFP_KERNEL | __GFP_NOWARN; size_t sz; int ret; @@ -1670,14 +1668,11 @@ static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx, goto fallback; ret = 1; } - state->free_reqs = ret - 1; - req = state->reqs[ret - 1]; - } else { - state->free_reqs--; - req = state->reqs[state->free_reqs]; + state->free_reqs = ret; } - return req; + state->free_reqs--; + return state->reqs[state->free_reqs]; fallback: return io_get_fallback_req(ctx); } |