[PATCH 4/4] selftests: ublk: clear reused batch SQE command flags
From: shao.mingyin
Date: Wed Nov 11 2026 - 10:52:57 EST
From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
Batch FETCH commands set IORING_URING_CMD_MULTISHOT and select a buffer.
When a SQE slot is reused for a PREP or COMMIT command, batch command
initialization overwrites the SQE flags but leaves uring_cmd_flags set.
The multishot flag then disagrees with buffer selection, so
io_uring_cmd_prep() rejects the command with -EINVAL. The completion
assertion aborts kublk, leaving a recovery device QUIESCED or its CLI
waiting for a daemon notification that will never arrive.
Clear rw_flags when initializing a batch command. The FETCH path sets
its multishot flag explicitly afterwards.
Fixes: cb5a6b308700 ("selftests: ublk: handle UBLK_U_IO_FETCH_IO_CMDS")
Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
---
Tested on next-20261105 with CONFIG_BLK_DEV_UBLK=y in a local QEMU/KVM
VM (4 vCPUs, 4 GiB), using real kublk and fio. With the same diagnostic
kernel and batch null workload, the original binary received -EINVAL
for a multishot COMMIT without buffer selection and its daemon exited,
leaving the device QUIESCED. With this change the daemon remained alive
and the device stayed LIVE before deliberate device deletion.
The four recovery scripts also passed twice with this change and a
separate fix for commits arriving after the quiesce cancellation scan.
tools/testing/selftests/ublk/batch.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/ublk/batch.c b/tools/testing/selftests/ublk/batch.c
index 625a9c32a..fcab2ca9e 100644
--- a/tools/testing/selftests/ublk/batch.c
+++ b/tools/testing/selftests/ublk/batch.c
@@ -241,6 +241,7 @@ static void ublk_init_batch_cmd(struct ublk_thread *t, __u16 q_id,
sqe->fd = 0; /* dev->fds[0] */
sqe->opcode = IORING_OP_URING_CMD;
+ sqe->rw_flags = 0;
sqe->flags = IOSQE_FIXED_FILE;
cmd->q_id = q_id;