From: Ming Lei <tom.leiming@gmail.com>
To: linux-block@vger.kernel.org
Cc: Ming Lei <tom.leiming@gmail.com>, Jens Axboe <axboe@kernel.dk>,
Caleb Sander Mateos <csander@purestorage.com>,
Josef Bacik <josef@toxicpanda.com>,
Li RongQing <lirongqing@baidu.com>
Subject: [PATCH v3 10/12] selftests: ublk: stop a batch thread when PREP_IO_CMDS fails
Date: Sun, 11 Oct 2026 01:35:53 -0500 [thread overview]
Message-ID: <20261011063555.1142277-11-tom.leiming@gmail.com> (raw)
In-Reply-To: <20261011063555.1142277-1-tom.leiming@gmail.com>
Since STOP_DEV turns the server away until it closes /dev/ublkcN,
UBLK_U_IO_PREP_IO_CMDS can complete with UBLK_IO_RES_ABORT when it
races STOP_DEV. kublk asserts that PREP succeeds, so the daemon aborts
before it reports to `kublk add`, which then waits for the start event
forever.
Stop the thread like a failed FETCH_IO_CMDS does. The daemon's
START_DEV then fails, and `kublk add` gets the error.
Reported-by: Josef Bacik <josef@toxicpanda.com>
Closes: https://lore.kernel.org/linux-block/63d8149c093169706e7478e779116b61.josef@toxicpanda.com/
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
tools/testing/selftests/ublk/batch.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/ublk/batch.c b/tools/testing/selftests/ublk/batch.c
index d8d9ebed5979..dfc81ee17d07 100644
--- a/tools/testing/selftests/ublk/batch.c
+++ b/tools/testing/selftests/ublk/batch.c
@@ -410,9 +410,16 @@ static void ublk_batch_compl_commit_cmd(struct ublk_thread *t,
{
unsigned short buf_idx = user_data_to_tag(cqe->user_data);
- if (op == _IOC_NR(UBLK_U_IO_PREP_IO_CMDS))
- ublk_assert(cqe->res == 0);
- else if (op == _IOC_NR(UBLK_U_IO_COMMIT_IO_CMDS)) {
+ if (op == _IOC_NR(UBLK_U_IO_PREP_IO_CMDS)) {
+ /* e.g. UBLK_IO_RES_ABORT after STOP_DEV: stop like a FETCH */
+ if (cqe->res < 0) {
+ ublk_dbg(UBLK_DBG_IO_CMD, "%s: prep failed %d\n",
+ __func__, cqe->res);
+ t->state |= UBLKS_T_STOPPING;
+ } else {
+ ublk_assert(cqe->res == 0);
+ }
+ } else if (op == _IOC_NR(UBLK_U_IO_COMMIT_IO_CMDS)) {
int nr_elem = user_data_to_tgt_data(cqe->user_data);
ublk_assert(cqe->res == t->commit_buf_elem_size * nr_elem);
--
2.55.0
next prev parent reply other threads:[~2026-10-11 6:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 6:35 [PATCH v3 00/12] ublk: don't dispatch to canceled io commands Ming Lei
2026-10-11 6:35 ` [PATCH v3 01/12] ublk: keep a canceled FETCH round canceling until the server is gone Ming Lei
2026-10-11 6:35 ` [PATCH v3 02/12] ublk: mark the io command cancelable before publishing it Ming Lei
2026-10-11 6:35 ` [PATCH v3 03/12] ublk: mark the batch fetch command cancelable before linking it Ming Lei
2026-10-11 6:35 ` [PATCH v3 04/12] ublk: reset the FETCH round in release also without a disk Ming Lei
2026-10-11 6:35 ` [PATCH v3 05/12] ublk: reset the FETCH round under ub->mutex Ming Lei
2026-10-11 6:35 ` [PATCH v3 06/12] ublk: allow a NULL io->cmd in the cancel callback Ming Lei
2026-10-11 6:35 ` [PATCH v3 07/12] ublk: let STOP_DEV cancel the server's commands before its release Ming Lei
2026-10-11 6:35 ` [PATCH v3 08/12] ublk: refuse to go live after an io command was canceled Ming Lei
2026-10-11 6:35 ` [PATCH v3 09/12] selftests: ublk: move the control command helpers into ctrl.c Ming Lei
2026-10-11 6:35 ` Ming Lei [this message]
2026-10-11 6:35 ` [PATCH v3 11/12] selftests: ublk: add test for going live over canceled io commands Ming Lei
2026-10-11 6:35 ` [PATCH v3 12/12] ublk: use global index for reported zones 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=20261011063555.1142277-11-tom.leiming@gmail.com \
--to=tom.leiming@gmail.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=lirongqing@baidu.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