public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Caleb Sander Mateos <csander@purestorage.com>
To: Jens Axboe <axboe@kernel.dk>, Ming Lei <ming.lei@redhat.com>
Cc: io-uring@vger.kernel.org, Caleb Sander Mateos <csander@purestorage.com>
Subject: [PATCH 3/3] io_uring/cmd: consolidate REQ_F_BUFFER_SELECT checks
Date: Thu, 21 Aug 2025 10:33:08 -0600	[thread overview]
Message-ID: <20250821163308.977915-4-csander@purestorage.com> (raw)
In-Reply-To: <20250821163308.977915-1-csander@purestorage.com>

io_uring_cmd_prep() checks that REQ_F_BUFFER_SELECT is set in the
io_kiocb's flags iff IORING_URING_CMD_MULTISHOT is set in the SQE's
uring_cmd_flags. Consolidate the IORING_URING_CMD_MULTISHOT and
!IORING_URING_CMD_MULTISHOT branches into a single check that the
IORING_URING_CMD_MULTISHOT flag matches the REQ_F_BUFFER_SELECT flag.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 io_uring/uring_cmd.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index c8fd204f6892..482cc5be1f8d 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -199,17 +199,13 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 		if (ioucmd->flags & IORING_URING_CMD_MULTISHOT)
 			return -EINVAL;
 		req->buf_index = READ_ONCE(sqe->buf_index);
 	}
 
-	if (ioucmd->flags & IORING_URING_CMD_MULTISHOT) {
-		if (!(req->flags & REQ_F_BUFFER_SELECT))
-			return -EINVAL;
-	} else {
-		if (req->flags & REQ_F_BUFFER_SELECT)
-			return -EINVAL;
-	}
+	if (!!(ioucmd->flags & IORING_URING_CMD_MULTISHOT) !=
+	    !!(req->flags & REQ_F_BUFFER_SELECT))
+		return -EINVAL;
 
 	ioucmd->cmd_op = READ_ONCE(sqe->cmd_op);
 
 	ac = io_uring_alloc_async_data(&req->ctx->cmd_cache, req);
 	if (!ac)
-- 
2.45.2


  parent reply	other threads:[~2025-08-21 16:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-21 16:33 [PATCH 0/3] IORING_URING_CMD_MULTISHOT fixups Caleb Sander Mateos
2025-08-21 16:33 ` [PATCH 1/3] io_uring/cmd: fix io_uring_mshot_cmd_post_cqe() for !CONFIG_IO_URING Caleb Sander Mateos
2025-08-21 16:38   ` Jens Axboe
2025-08-21 16:33 ` [PATCH 2/3] io_uring/cmd: deduplicate uring_cmd_flags checks Caleb Sander Mateos
2025-08-22  1:16   ` Ming Lei
2025-08-21 16:33 ` Caleb Sander Mateos [this message]
2025-08-22  1:18   ` [PATCH 3/3] io_uring/cmd: consolidate REQ_F_BUFFER_SELECT checks Ming Lei
2025-08-22  1:59 ` (subset) [PATCH 0/3] IORING_URING_CMD_MULTISHOT fixups Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250821163308.977915-4-csander@purestorage.com \
    --to=csander@purestorage.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox