From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Uday Shankar <ushankar@purestorage.com>,
Caleb Sander Mateos <csander@purestorage.com>,
Keith Busch <kbusch@kernel.org>, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH V3 1/6] ublk: allow io buffer register/unregister command issued from other task contexts
Date: Fri, 9 May 2025 23:06:04 +0800 [thread overview]
Message-ID: <20250509150611.3395206-2-ming.lei@redhat.com> (raw)
In-Reply-To: <20250509150611.3395206-1-ming.lei@redhat.com>
`ublk_queue` is read only for io buffer register/unregister command. Both
`ublk_io` and block layer request are read-only for IO buffer register/
unregister command.
So the two command can be issued from other task contexts.
Not same with other three ublk commands, these two are for handling target
IO only, we shouldn't limit their issue task context, otherwise it becomes
hard for ublk server(backend) to use zero copy feature.
Reported-by: Uday Shankar <ushankar@purestorage.com>
Closes: https://lore.kernel.org/linux-block/20250410-ublk_task_per_io-v3-2-b811e8f4554a@purestorage.com/
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/ublk_drv.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index cb612151e9a1..31f06e734250 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2057,6 +2057,12 @@ static bool ublk_get_data(const struct ublk_queue *ubq, struct ublk_io *io)
return ublk_start_io(ubq, req, io);
}
+static bool is_io_buf_reg_unreg_cmd(unsigned int cmd_op)
+{
+ return _IOC_NR(cmd_op) == UBLK_IO_REGISTER_IO_BUF ||
+ _IOC_NR(cmd_op) == UBLK_IO_UNREGISTER_IO_BUF;
+}
+
static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
unsigned int issue_flags,
const struct ublksrv_io_cmd *ub_cmd)
@@ -2076,8 +2082,15 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
goto out;
ubq = ublk_get_queue(ub, ub_cmd->q_id);
- if (ubq->ubq_daemon && ubq->ubq_daemon != current)
- goto out;
+ /*
+ * Both `ublk_io` and block layer request are read-only for IO
+ * buffer register/unregister command, so the two are allowed to be
+ * issued from other task contexts
+ */
+ if (!is_io_buf_reg_unreg_cmd(cmd_op)) {
+ if (ubq->ubq_daemon && ubq->ubq_daemon != current)
+ goto out;
+ }
if (tag >= ubq->q_depth)
goto out;
--
2.47.0
next prev parent reply other threads:[~2025-05-09 15:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 15:06 [PATCH V3 0/6] ublk: support to register bvec buffer automatically Ming Lei
2025-05-09 15:06 ` Ming Lei [this message]
2025-05-12 17:39 ` [PATCH V3 1/6] ublk: allow io buffer register/unregister command issued from other task contexts Caleb Sander Mateos
2025-05-13 2:26 ` Ming Lei
2025-05-13 17:09 ` Caleb Sander Mateos
2025-05-12 20:25 ` Caleb Sander Mateos
2025-05-13 3:05 ` Ming Lei
2025-05-13 17:19 ` Caleb Sander Mateos
2025-05-09 15:06 ` [PATCH V3 2/6] ublk: convert to refcount_t Ming Lei
2025-05-09 15:06 ` [PATCH V3 3/6] ublk: prepare for supporting to register request buffer automatically Ming Lei
2025-05-13 19:45 ` Caleb Sander Mateos
2025-05-09 15:06 ` [PATCH V3 4/6] ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG Ming Lei
2025-05-13 19:50 ` Caleb Sander Mateos
2025-05-17 11:02 ` Ming Lei
2025-05-18 17:10 ` Caleb Sander Mateos
2025-05-19 4:49 ` Ming Lei
2025-05-19 15:20 ` Caleb Sander Mateos
2025-05-20 1:15 ` Ming Lei
2025-05-13 19:54 ` Caleb Sander Mateos
2025-05-09 15:06 ` [PATCH V3 5/6] selftests: ublk: support UBLK_F_AUTO_BUF_REG Ming Lei
2025-05-09 15:06 ` [PATCH V3 6/6] selftests: ublk: add test for covering UBLK_AUTO_BUF_REG_FALLBACK Ming Lei
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=20250509150611.3395206-2-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=kbusch@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.