Skip to contentSkip to conversation

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

PATCH In review Jens Axboe 5 participants 5 messages Apr 5, 2023 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

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

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.

---

io_uring/uring_cmd.c +1 -3
index 3d825d939b13..f7a96bc76ea1 100644
@@ -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)) {
Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jens Axboe
Quoted 4 lines · Jens Axboe

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 on v1 1/1
#3 lore raw
In reply to Jens Axboe
Quoted 34 lines · Jens Axboe

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.

---

io_uring/uring_cmd.c +1 -4
index 3d825d939b13..f7a96bc76ea1 100644
@@ -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)) {
 
--
Quoted 2 lines

Jens Axboe

Looks good.

Reviewed-by on v1 1/1
#4 lore raw
In reply to Jens Axboe
Quoted 5 lines · Jens Axboe

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.