Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/rw: Allocate async data through helper

This abstract away the cache details.

Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
Link: https://lore.kernel.org/r/20241216204615.759089-8-krisman@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Gabriel Krisman Bertazi and committed by
Jens Axboe
d7f11616 f49a8537

+16 -20
+16 -20
io_uring/rw.c
··· 208 208 } 209 209 } 210 210 211 + static void io_rw_async_data_init(void *obj) 212 + { 213 + struct io_async_rw *rw = (struct io_async_rw *)obj; 214 + 215 + rw->free_iovec = 0; 216 + rw->bytes_done = 0; 217 + } 218 + 211 219 static int io_rw_alloc_async(struct io_kiocb *req) 212 220 { 213 221 struct io_ring_ctx *ctx = req->ctx; 214 222 struct io_async_rw *rw; 215 223 216 - rw = io_alloc_cache_get(&ctx->rw_cache); 217 - if (rw) { 218 - if (rw->free_iovec) { 219 - kasan_mempool_unpoison_object(rw->free_iovec, 220 - rw->free_iov_nr * sizeof(struct iovec)); 221 - req->flags |= REQ_F_NEED_CLEANUP; 222 - } 223 - req->flags |= REQ_F_ASYNC_DATA; 224 - req->async_data = rw; 225 - goto done; 226 - } 227 - 228 - if (!io_alloc_async_data(req)) { 229 - rw = req->async_data; 230 - rw->free_iovec = NULL; 231 - rw->free_iov_nr = 0; 232 - done: 224 + rw = io_uring_alloc_async_data(&ctx->rw_cache, req, io_rw_async_data_init); 225 + if (!rw) 226 + return -ENOMEM; 227 + if (rw->free_iovec) { 228 + kasan_mempool_unpoison_object(rw->free_iovec, 229 + rw->free_iov_nr * sizeof(struct iovec)); 230 + req->flags |= REQ_F_NEED_CLEANUP; 233 231 rw->bytes_done = 0; 234 - return 0; 235 232 } 236 - 237 - return -ENOMEM; 233 + return 0; 238 234 } 239 235 240 236 static int io_prep_rw_setup(struct io_kiocb *req, int ddir, bool do_import)