From: Caleb Sander Mateos <csander@purestorage.com>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Caleb Sander Mateos <csander@purestorage.com>
Subject: [PATCH 5/5] ublk: store req in ublk_uring_cmd_pdu for ublk_cmd_tw_cb()
Date: Fri, 28 Mar 2025 12:04:11 -0600 [thread overview]
Message-ID: <20250328180411.2696494-6-csander@purestorage.com> (raw)
In-Reply-To: <20250328180411.2696494-1-csander@purestorage.com>
Pass struct request *rq to ublk_cmd_tw_cb() through ublk_uring_cmd_pdu,
mirroring how it works for ublk_cmd_list_tw_cb(). This saves some
pointer dereferences, as well as the bounds check in blk_mq_tag_to_rq().
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
drivers/block/ublk_drv.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 23250471562a..466a23b89379 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -87,11 +87,14 @@ struct ublk_uring_cmd_pdu {
*
* It should have been stored to request payload, but we do want
* to avoid extra pre-allocation, and uring_cmd payload is always
* free for us
*/
- struct request *req_list;
+ union {
+ struct request *req;
+ struct request *req_list;
+ };
/*
* The following two are valid in this cmd whole lifetime, and
* setup in ublk uring_cmd handler
*/
@@ -1266,22 +1269,21 @@ static void ublk_dispatch_req(struct ublk_queue *ubq,
static void ublk_cmd_tw_cb(struct io_uring_cmd *cmd,
unsigned int issue_flags)
{
struct ublk_uring_cmd_pdu *pdu = ublk_get_uring_cmd_pdu(cmd);
struct ublk_queue *ubq = pdu->ubq;
- int tag = pdu->tag;
- struct request *req = blk_mq_tag_to_rq(
- ubq->dev->tag_set.tags[ubq->q_id], tag);
- ublk_dispatch_req(ubq, req, issue_flags);
+ ublk_dispatch_req(ubq, pdu->req, issue_flags);
}
static void ublk_queue_cmd(struct ublk_queue *ubq, struct request *rq)
{
- struct ublk_io *io = &ubq->ios[rq->tag];
+ struct io_uring_cmd *cmd = ubq->ios[rq->tag].cmd;
+ struct ublk_uring_cmd_pdu *pdu = ublk_get_uring_cmd_pdu(cmd);
- io_uring_cmd_complete_in_task(io->cmd, ublk_cmd_tw_cb);
+ pdu->req = rq;
+ io_uring_cmd_complete_in_task(cmd, ublk_cmd_tw_cb);
}
static void ublk_cmd_list_tw_cb(struct io_uring_cmd *cmd,
unsigned int issue_flags)
{
--
2.45.2
next prev parent reply other threads:[~2025-03-28 18:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 18:04 [PATCH 0/5] Minor ublk optimizations Caleb Sander Mateos
2025-03-28 18:04 ` [PATCH 1/5] ublk: remove unused cmd argument to ublk_dispatch_req() Caleb Sander Mateos
2025-03-28 18:04 ` [PATCH 2/5] ublk: skip 1 NULL check in ublk_cmd_list_tw_cb() loop Caleb Sander Mateos
2025-03-28 18:04 ` [PATCH 3/5] ublk: get ubq from pdu in ublk_cmd_list_tw_cb() Caleb Sander Mateos
2025-03-28 18:04 ` [PATCH 4/5] ublk: avoid redundant io->cmd in ublk_queue_cmd_list() Caleb Sander Mateos
2025-03-28 18:04 ` Caleb Sander Mateos [this message]
2025-03-28 19:20 ` [PATCH 0/5] Minor ublk optimizations Jens Axboe
2025-03-29 0:23 ` Ming Lei
2025-03-29 11:57 ` 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=20250328180411.2696494-6-csander@purestorage.com \
--to=csander@purestorage.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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