diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-02-28 22:35:17 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-04-11 17:41:58 -0600 |
commit | 6cb78689fa94c80784faef76744746aee558c344 (patch) | |
tree | bd0a745c5c4e6baa6c65bc44a6ae5c80aa36dca6 /fs/io_uring.c | |
parent | 2e052d443df15d71277f6b8509badae4310ebd92 (diff) | |
download | lwn-6cb78689fa94c80784faef76744746aee558c344.tar.gz lwn-6cb78689fa94c80784faef76744746aee558c344.zip |
io_uring: untie alloc_async_data and needs_async_data
All opcode handlers pretty well know whether they need async data or
not, and can skip testing for needs_async_data. The exception is rw
the generic path, but those test the flag by hand anyway. So, check the
flag and make io_alloc_async_data() allocating unconditionally.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 7833ccd085ba..e45893823652 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3128,21 +3128,13 @@ static void io_req_map_rw(struct io_kiocb *req, const struct iovec *iovec, } } -static inline int __io_alloc_async_data(struct io_kiocb *req) +static inline int io_alloc_async_data(struct io_kiocb *req) { WARN_ON_ONCE(!io_op_defs[req->opcode].async_size); req->async_data = kmalloc(io_op_defs[req->opcode].async_size, GFP_KERNEL); return req->async_data == NULL; } -static int io_alloc_async_data(struct io_kiocb *req) -{ - if (!io_op_defs[req->opcode].needs_async_data) - return 0; - - return __io_alloc_async_data(req); -} - static int io_setup_async_rw(struct io_kiocb *req, const struct iovec *iovec, const struct iovec *fast_iov, struct iov_iter *iter, bool force) @@ -3150,7 +3142,7 @@ static int io_setup_async_rw(struct io_kiocb *req, const struct iovec *iovec, if (!force && !io_op_defs[req->opcode].needs_async_data) return 0; if (!req->async_data) { - if (__io_alloc_async_data(req)) { + if (io_alloc_async_data(req)) { kfree(iovec); return -ENOMEM; } @@ -5904,7 +5896,7 @@ static int io_req_defer_prep(struct io_kiocb *req) /* some opcodes init it during the inital prep */ if (req->async_data) return 0; - if (__io_alloc_async_data(req)) + if (io_alloc_async_data(req)) return -EAGAIN; return io_req_prep_async(req); } |