提交 23f4e892 编写于 作者: X Xiaoguang Wang

io_uring: cleanup io_alloc_async_ctx()

to #28170604

commit 3d9932a8b240c9019f48358e8a6928c53c2c7f6b upstream

Cleanup io_alloc_async_ctx() a bit, add a new __io_alloc_async_ctx(),
so io_setup_async_rw() won't need to check whether async_ctx is true
or false again.
Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 cd99ef9b
...@@ -2472,12 +2472,18 @@ static void io_req_map_rw(struct io_kiocb *req, ssize_t io_size, ...@@ -2472,12 +2472,18 @@ static void io_req_map_rw(struct io_kiocb *req, ssize_t io_size,
} }
} }
static inline int __io_alloc_async_ctx(struct io_kiocb *req)
{
req->io = kmalloc(sizeof(*req->io), GFP_KERNEL);
return req->io == NULL;
}
static int io_alloc_async_ctx(struct io_kiocb *req) static int io_alloc_async_ctx(struct io_kiocb *req)
{ {
if (!io_op_defs[req->opcode].async_ctx) if (!io_op_defs[req->opcode].async_ctx)
return 0; return 0;
req->io = kmalloc(sizeof(*req->io), GFP_KERNEL);
return req->io == NULL; return __io_alloc_async_ctx(req);
} }
static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size, static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size,
...@@ -2487,7 +2493,7 @@ static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size, ...@@ -2487,7 +2493,7 @@ static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size,
if (!io_op_defs[req->opcode].async_ctx) if (!io_op_defs[req->opcode].async_ctx)
return 0; return 0;
if (!req->io) { if (!req->io) {
if (io_alloc_async_ctx(req)) if (__io_alloc_async_ctx(req))
return -ENOMEM; return -ENOMEM;
io_req_map_rw(req, io_size, iovec, fast_iov, iter); io_req_map_rw(req, io_size, iovec, fast_iov, iter);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册