diff mbox series

io_uring/uring_cmd: assign ioucmd->cmd at async prep time

Message ID 863daab3-c397-85fc-4db5-b61e02ced047@kernel.dk (mailing list archive)
State New
Headers show
Series io_uring/uring_cmd: assign ioucmd->cmd at async prep time | expand

Commit Message

Jens Axboe April 5, 2023, 2:23 p.m. UTC
Rather than check this in the fast path issue, it makes more sense to
just assign the copy of the data when we're setting it up anyway. This
makes the code a bit cleaner, and removes the need for this check in
the issue path.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

Comments

Gabriel Krisman Bertazi April 5, 2023, 2:36 p.m. UTC | #1
Jens Axboe <axboe@kernel.dk> writes:

> Rather than check this in the fast path issue, it makes more sense to
> just assign the copy of the data when we're setting it up anyway. This
> makes the code a bit cleaner, and removes the need for this check in
> the issue path.
>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>

Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Keith Busch April 5, 2023, 3:29 p.m. UTC | #2
On Wed, Apr 05, 2023 at 08:23:15AM -0600, Jens Axboe wrote:
> Rather than check this in the fast path issue, it makes more sense to
> just assign the copy of the data when we're setting it up anyway. This
> makes the code a bit cleaner, and removes the need for this check in
> the issue path.

Looks good.

Reviewed-by: Keith Busch <kbusch@kernel.org>
Anuj gupta April 5, 2023, 3:44 p.m. UTC | #3
On Wed, Apr 5, 2023 at 7:54 PM Jens Axboe <axboe@kernel.dk> wrote:
>
> Rather than check this in the fast path issue, it makes more sense to
> just assign the copy of the data when we're setting it up anyway. This
> makes the code a bit cleaner, and removes the need for this check in
> the issue path.
>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>
> ---
>
> diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
> index 3d825d939b13..f7a96bc76ea1 100644
> --- a/io_uring/uring_cmd.c
> +++ b/io_uring/uring_cmd.c
> @@ -73,6 +73,7 @@ int io_uring_cmd_prep_async(struct io_kiocb *req)
>         cmd_size = uring_cmd_pdu_size(req->ctx->flags & IORING_SETUP_SQE128);
>
>         memcpy(req->async_data, ioucmd->cmd, cmd_size);
> +       ioucmd->cmd = req->async_data;
>         return 0;
>  }
>
> @@ -129,9 +130,6 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
>                 WRITE_ONCE(ioucmd->cookie, NULL);
>         }
>
> -       if (req_has_async_data(req))
> -               ioucmd->cmd = req->async_data;
> -
>         ret = file->f_op->uring_cmd(ioucmd, issue_flags);
>         if (ret == -EAGAIN) {
>                 if (!req_has_async_data(req)) {
>
> --
> Jens Axboe
>

Looks good.

Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Kanchan Joshi April 5, 2023, 6 p.m. UTC | #4
On Wed, Apr 5, 2023 at 7:54 PM Jens Axboe <axboe@kernel.dk> wrote:
>
> Rather than check this in the fast path issue, it makes more sense to
> just assign the copy of the data when we're setting it up anyway. This
> makes the code a bit cleaner, and removes the need for this check in
> the issue path.

Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
diff mbox series

Patch

diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index 3d825d939b13..f7a96bc76ea1 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -73,6 +73,7 @@  int io_uring_cmd_prep_async(struct io_kiocb *req)
 	cmd_size = uring_cmd_pdu_size(req->ctx->flags & IORING_SETUP_SQE128);
 
 	memcpy(req->async_data, ioucmd->cmd, cmd_size);
+	ioucmd->cmd = req->async_data;
 	return 0;
 }
 
@@ -129,9 +130,6 @@  int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
 		WRITE_ONCE(ioucmd->cookie, NULL);
 	}
 
-	if (req_has_async_data(req))
-		ioucmd->cmd = req->async_data;
-
 	ret = file->f_op->uring_cmd(ioucmd, issue_flags);
 	if (ret == -EAGAIN) {
 		if (!req_has_async_data(req)) {