From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Caleb Sander Mateos <csander@purestorage.com>,
Uday Shankar <ushankar@purestorage.com>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 1/2] ublk: rename auto buffer registration helpers
Date: Fri, 23 Jan 2026 21:51:58 +0800 [thread overview]
Message-ID: <20260123135205.2202474-2-ming.lei@redhat.com> (raw)
In-Reply-To: <20260123135205.2202474-1-ming.lei@redhat.com>
Rename the auto buffer registration functions for clarity:
- __ublk_do_auto_buf_reg() -> ublk_auto_buf_register()
- ublk_prep_auto_buf_reg_io() -> ublk_auto_buf_io_setup()
- ublk_do_auto_buf_reg() -> ublk_auto_buf_dispatch()
Add comments documenting the locking requirements for each function.
No functional change.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/ublk_drv.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 31fda782c47c..7981decd1cee 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1509,10 +1509,16 @@ enum auto_buf_reg_res {
AUTO_BUF_REG_OK,
};
-static void ublk_prep_auto_buf_reg_io(const struct ublk_queue *ubq,
- struct request *req, struct ublk_io *io,
- struct io_uring_cmd *cmd,
- enum auto_buf_reg_res res)
+/*
+ * Setup io state after auto buffer registration.
+ *
+ * Must be called after ublk_auto_buf_register() is done.
+ * Caller must hold io->lock in batch context.
+ */
+static void ublk_auto_buf_io_setup(const struct ublk_queue *ubq,
+ struct request *req, struct ublk_io *io,
+ struct io_uring_cmd *cmd,
+ enum auto_buf_reg_res res)
{
if (res == AUTO_BUF_REG_OK) {
io->task_registered_buffers = 1;
@@ -1523,8 +1529,9 @@ static void ublk_prep_auto_buf_reg_io(const struct ublk_queue *ubq,
__ublk_prep_compl_io_cmd(io, req);
}
+/* Register request bvec to io_uring for auto buffer registration. */
static enum auto_buf_reg_res
-__ublk_do_auto_buf_reg(const struct ublk_queue *ubq, struct request *req,
+ublk_auto_buf_register(const struct ublk_queue *ubq, struct request *req,
struct ublk_io *io, struct io_uring_cmd *cmd,
unsigned int issue_flags)
{
@@ -1544,15 +1551,21 @@ __ublk_do_auto_buf_reg(const struct ublk_queue *ubq, struct request *req,
return AUTO_BUF_REG_OK;
}
-static void ublk_do_auto_buf_reg(const struct ublk_queue *ubq, struct request *req,
- struct ublk_io *io, struct io_uring_cmd *cmd,
- unsigned int issue_flags)
+/*
+ * Dispatch IO to userspace with auto buffer registration.
+ *
+ * Only called in non-batch context from task work, io->lock not held.
+ */
+static void ublk_auto_buf_dispatch(const struct ublk_queue *ubq,
+ struct request *req, struct ublk_io *io,
+ struct io_uring_cmd *cmd,
+ unsigned int issue_flags)
{
- enum auto_buf_reg_res res = __ublk_do_auto_buf_reg(ubq, req, io, cmd,
+ enum auto_buf_reg_res res = ublk_auto_buf_register(ubq, req, io, cmd,
issue_flags);
if (res != AUTO_BUF_REG_FAIL) {
- ublk_prep_auto_buf_reg_io(ubq, req, io, cmd, res);
+ ublk_auto_buf_io_setup(ubq, req, io, cmd, res);
io_uring_cmd_done(cmd, UBLK_IO_RES_OK, issue_flags);
}
}
@@ -1627,7 +1640,7 @@ static void ublk_dispatch_req(struct ublk_queue *ubq, struct request *req)
return;
if (ublk_support_auto_buf_reg(ubq) && ublk_rq_has_data(req)) {
- ublk_do_auto_buf_reg(ubq, req, io, io->cmd, issue_flags);
+ ublk_auto_buf_dispatch(ubq, req, io, io->cmd, issue_flags);
} else {
ublk_init_req_ref(ubq, io);
ublk_complete_io_cmd(io, req, UBLK_IO_RES_OK, issue_flags);
@@ -1648,7 +1661,7 @@ static bool __ublk_batch_prep_dispatch(struct ublk_queue *ubq,
return false;
if (ublk_support_auto_buf_reg(ubq) && ublk_rq_has_data(req)) {
- res = __ublk_do_auto_buf_reg(ubq, req, io, cmd,
+ res = ublk_auto_buf_register(ubq, req, io, cmd,
data->issue_flags);
if (res == AUTO_BUF_REG_FAIL)
@@ -1656,7 +1669,7 @@ static bool __ublk_batch_prep_dispatch(struct ublk_queue *ubq,
}
ublk_io_lock(io);
- ublk_prep_auto_buf_reg_io(ubq, req, io, cmd, res);
+ ublk_auto_buf_io_setup(ubq, req, io, cmd, res);
ublk_io_unlock(io);
return true;
--
2.47.0
next prev parent reply other threads:[~2026-01-23 13:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 13:51 [PATCH 0/2] ublk: auto buffer helpers rename & document io reference Ming Lei
2026-01-23 13:51 ` Ming Lei [this message]
2026-01-23 13:51 ` [PATCH 2/2] ublk: document IO reference counting design Ming Lei
2026-01-23 20:37 ` Caleb Sander Mateos
2026-01-24 1:30 ` Ming Lei
2026-01-24 1:38 ` Caleb Sander Mateos
2026-01-24 2:55 ` Ming Lei
2026-01-23 19:13 ` [PATCH 0/2] ublk: auto buffer helpers rename & document io reference Jens Axboe
2026-01-24 1:03 ` Ming Lei
2026-01-24 3:18 ` 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=20260123135205.2202474-2-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=linux-block@vger.kernel.org \
--cc=ushankar@purestorage.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