]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring/alloc_cache: get rid of _nocache() helper
authorJens Axboe <axboe@kernel.dk>
Thu, 23 Jan 2025 14:34:36 +0000 (07:34 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 23 Jan 2025 18:32:34 +0000 (11:32 -0700)
Just allow passing in NULL for the cache, if the type in question
doesn't have a cache associated with it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.h
io_uring/timeout.c
io_uring/waitid.c

index 67adbb3c1bf58c88c6783f90581c2c5bdf7b1a8c..ab619e63ef39c89f536b0725e448d9cce2f9a09c 100644 (file)
@@ -228,18 +228,14 @@ static inline void io_req_set_res(struct io_kiocb *req, s32 res, u32 cflags)
 static inline void *io_uring_alloc_async_data(struct io_alloc_cache *cache,
                                              struct io_kiocb *req)
 {
-       req->async_data = io_cache_alloc(cache, GFP_KERNEL);
-       if (req->async_data)
-               req->flags |= REQ_F_ASYNC_DATA;
-       return req->async_data;
-}
+       if (cache) {
+               req->async_data = io_cache_alloc(cache, GFP_KERNEL);
+       } else {
+               const struct io_issue_def *def = &io_issue_defs[req->opcode];
 
-static inline void *io_uring_alloc_async_data_nocache(struct io_kiocb *req)
-{
-       const struct io_issue_def *def = &io_issue_defs[req->opcode];
-
-       WARN_ON_ONCE(!def->async_size);
-       req->async_data = kmalloc(def->async_size, GFP_KERNEL);
+               WARN_ON_ONCE(!def->async_size);
+               req->async_data = kmalloc(def->async_size, GFP_KERNEL);
+       }
        if (req->async_data)
                req->flags |= REQ_F_ASYNC_DATA;
        return req->async_data;
index 2bd7e0a317bba54d15a00f77891607a58e06fba6..48fc8cf707843bfbf94afa1dca7d91f4fb51fe8b 100644 (file)
@@ -544,7 +544,7 @@ static int __io_timeout_prep(struct io_kiocb *req,
 
        if (WARN_ON_ONCE(req_has_async_data(req)))
                return -EFAULT;
-       data = io_uring_alloc_async_data_nocache(req);
+       data = io_uring_alloc_async_data(NULL, req);
        if (!data)
                return -ENOMEM;
        data->req = req;
index 6778c0ee76c427d54579ea84c98b1b78df53e5a0..853e97a7b0ecb96dd4ae2f63d3e5cda3286c25e3 100644 (file)
@@ -303,7 +303,7 @@ int io_waitid(struct io_kiocb *req, unsigned int issue_flags)
        struct io_waitid_async *iwa;
        int ret;
 
-       iwa = io_uring_alloc_async_data_nocache(req);
+       iwa = io_uring_alloc_async_data(NULL, req);
        if (!iwa)
                return -ENOMEM;