diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2023-01-23 14:37:16 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-01-29 15:17:41 -0700 |
commit | c8576f3e612d3c5b01d434ae296b9b76d7907708 (patch) | |
tree | e920d94aea33013acfab94c19eb47f591c409d5d /io_uring/io_uring.h | |
parent | b5083dfa36676e7b5d72bf3d70f429a0d08c5075 (diff) |
io_uring: refactor req allocation
Follow the io_get_sqe pattern returning the result via a pointer
and hide request cache refill inside io_alloc_req().
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/8c37c2e8a3cb5e4cd6a8ae3b91371227a92708a6.1674484266.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.h')
-rw-r--r-- | io_uring/io_uring.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index 9270156288aa..f90816aac896 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -341,16 +341,9 @@ static inline bool io_req_cache_empty(struct io_ring_ctx *ctx) return !ctx->submit_state.free_list.next; } -static inline bool io_alloc_req_refill(struct io_ring_ctx *ctx) -{ - if (unlikely(io_req_cache_empty(ctx))) - return __io_alloc_req_refill(ctx); - return true; -} - extern struct kmem_cache *req_cachep; -static inline struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx) +static inline struct io_kiocb *io_extract_req(struct io_ring_ctx *ctx) { struct io_kiocb *req; @@ -360,6 +353,16 @@ static inline struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx) return req; } +static inline bool io_alloc_req(struct io_ring_ctx *ctx, struct io_kiocb **req) +{ + if (unlikely(io_req_cache_empty(ctx))) { + if (!__io_alloc_req_refill(ctx)) + return false; + } + *req = io_extract_req(ctx); + return true; +} + static inline bool io_allowed_defer_tw_run(struct io_ring_ctx *ctx) { return likely(ctx->submitter_task == current); |