* [PATCH] io_uring: cleanup io_alloc_async_ctx()
@ 2020-03-27 7:36 Xiaoguang Wang
2020-03-27 8:26 ` Stefano Garzarella
2020-03-27 14:54 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Xiaoguang Wang @ 2020-03-27 7:36 UTC (permalink / raw)
To: io-uring; +Cc: axboe, joseph.qi, Xiaoguang Wang
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.
Signed-off-by: Xiaoguang Wang <[email protected]>
---
fs/io_uring.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3affd96a98ba..a85659eae137 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2169,12 +2169,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)
{
if (!io_op_defs[req->opcode].async_ctx)
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,
@@ -2184,7 +2190,7 @@ static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size,
if (!io_op_defs[req->opcode].async_ctx)
return 0;
if (!req->io) {
- if (io_alloc_async_ctx(req))
+ if (__io_alloc_async_ctx(req))
return -ENOMEM;
io_req_map_rw(req, io_size, iovec, fast_iov, iter);
--
2.17.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: cleanup io_alloc_async_ctx()
2020-03-27 7:36 [PATCH] io_uring: cleanup io_alloc_async_ctx() Xiaoguang Wang
@ 2020-03-27 8:26 ` Stefano Garzarella
2020-03-27 14:54 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2020-03-27 8:26 UTC (permalink / raw)
To: Xiaoguang Wang; +Cc: io-uring, axboe, joseph.qi
On Fri, Mar 27, 2020 at 03:36:52PM +0800, Xiaoguang Wang wrote:
> 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.
>
> Signed-off-by: Xiaoguang Wang <[email protected]>
> ---
> fs/io_uring.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
Looks good to me!
Reviewed-by: Stefano Garzarella <[email protected]>
Thanks,
Stefano
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 3affd96a98ba..a85659eae137 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2169,12 +2169,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)
> {
> if (!io_op_defs[req->opcode].async_ctx)
> 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,
> @@ -2184,7 +2190,7 @@ static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size,
> if (!io_op_defs[req->opcode].async_ctx)
> return 0;
> if (!req->io) {
> - if (io_alloc_async_ctx(req))
> + if (__io_alloc_async_ctx(req))
> return -ENOMEM;
>
> io_req_map_rw(req, io_size, iovec, fast_iov, iter);
> --
> 2.17.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring: cleanup io_alloc_async_ctx()
2020-03-27 7:36 [PATCH] io_uring: cleanup io_alloc_async_ctx() Xiaoguang Wang
2020-03-27 8:26 ` Stefano Garzarella
@ 2020-03-27 14:54 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-03-27 14:54 UTC (permalink / raw)
To: Xiaoguang Wang, io-uring; +Cc: joseph.qi
On 3/27/20 1:36 AM, Xiaoguang Wang wrote:
> 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.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-27 14:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-27 7:36 [PATCH] io_uring: cleanup io_alloc_async_ctx() Xiaoguang Wang
2020-03-27 8:26 ` Stefano Garzarella
2020-03-27 14:54 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox