Skip to content

Commit 49f7a30

Browse files
krismanaxboe
authored andcommitted
io_uring: Add generic helper to allocate async data
This helper replaces io_alloc_async_data by using the folded allocation. Do it in a header to allow the compiler to decide whether to inline. Signed-off-by: Gabriel Krisman Bertazi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 479b2f4 commit 49f7a30

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

io_uring/io_uring.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/poll.h>
99
#include <linux/io_uring_types.h>
1010
#include <uapi/linux/eventpoll.h>
11+
#include "alloc_cache.h"
1112
#include "io-wq.h"
1213
#include "slist.h"
1314
#include "filetable.h"
@@ -222,6 +223,16 @@ static inline void io_req_set_res(struct io_kiocb *req, s32 res, u32 cflags)
222223
req->cqe.flags = cflags;
223224
}
224225

226+
static inline void *io_uring_alloc_async_data(struct io_alloc_cache *cache,
227+
struct io_kiocb *req,
228+
void (*init_once)(void *obj))
229+
{
230+
req->async_data = io_cache_alloc(cache, GFP_KERNEL, init_once);
231+
if (req->async_data)
232+
req->flags |= REQ_F_ASYNC_DATA;
233+
return req->async_data;
234+
}
235+
225236
static inline bool req_has_async_data(struct io_kiocb *req)
226237
{
227238
return req->flags & REQ_F_ASYNC_DATA;

0 commit comments

Comments
 (0)