* [PATCH V2 0/9] ublk: misc improvement in driver and selftests
@ 2026-01-29 16:19 Ming Lei
2026-01-29 16:19 ` [PATCH V2 1/9] ublk: check list membership before cancelling batch fetch command Ming Lei
` (9 more replies)
0 siblings, 10 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
The 1st patch improves fetch command removal and canceling, which is
reported as risk from AI.
The 2nd patch adds UBLK_F_NO_AUTO_PART_SCAN for disabling partition
scanning during adding disk.
The other patches improves ublk selftests:
- rename test_generic_15 to test_part_02
- refactor test_null_04 into separate functions and simplifying
implementations
- kill IO verify failure in null/integrity tests by not scanning partition
- mark each test start and end in dmesg log
- move all temp files/dir into single directory, and allow user to
override default temp dir
- derive TID automatically from script name
V2:
- add `selftests: ublk: move test temp files into a sub directory` for
avoiding conflict
- avoid wq schedule for UBLK_F_NO_AUTO_PART_SCAN(Caleb Sander Mateos)
- avoid sed in retrieving TID (Alexander Atanasov)
- commit log typo fix on 2nd patch(Alexander Atanasov)
- more ublk selftests improvement:
- rename test_generic_15 to test_part_02
- refactor test_null_04 into separate functions and simplifying implementations
- kill IO failure in null/integrity tests by not scanning partition
Alexander Atanasov (2):
selftests: ublk: mark each test start and end time in dmesg
selftests: ublk: move test temp files into a sub directory
Ming Lei (7):
ublk: check list membership before cancelling batch fetch command
ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag
selftests: ublk: derive TID automatically from script name
selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN
selftests: ublk: rename test_generic_15 to test_part_02
selftests: ublk: refactor test_null_04 into separate functions
selftests: ublk: disable partition scan for integrity tests
drivers/block/ublk_drv.c | 30 ++-
include/uapi/linux/ublk_cmd.h | 3 +
tools/testing/selftests/ublk/Makefile | 4 +-
tools/testing/selftests/ublk/kublk.c | 6 +-
tools/testing/selftests/ublk/kublk.h | 3 +-
tools/testing/selftests/ublk/test_batch_01.sh | 1 -
tools/testing/selftests/ublk/test_batch_02.sh | 1 -
tools/testing/selftests/ublk/test_batch_03.sh | 1 -
tools/testing/selftests/ublk/test_common.sh | 18 +-
.../testing/selftests/ublk/test_generic_01.sh | 1 -
.../testing/selftests/ublk/test_generic_02.sh | 1 -
.../testing/selftests/ublk/test_generic_03.sh | 1 -
.../testing/selftests/ublk/test_generic_04.sh | 1 -
.../testing/selftests/ublk/test_generic_05.sh | 1 -
.../testing/selftests/ublk/test_generic_06.sh | 1 -
.../testing/selftests/ublk/test_generic_07.sh | 1 -
.../testing/selftests/ublk/test_generic_08.sh | 1 -
.../testing/selftests/ublk/test_generic_09.sh | 1 -
.../testing/selftests/ublk/test_generic_10.sh | 1 -
.../testing/selftests/ublk/test_generic_11.sh | 1 -
.../testing/selftests/ublk/test_generic_12.sh | 1 -
.../testing/selftests/ublk/test_generic_13.sh | 1 -
.../testing/selftests/ublk/test_generic_14.sh | 1 -
.../testing/selftests/ublk/test_generic_16.sh | 1 -
tools/testing/selftests/ublk/test_loop_01.sh | 1 -
tools/testing/selftests/ublk/test_loop_02.sh | 1 -
tools/testing/selftests/ublk/test_loop_03.sh | 1 -
tools/testing/selftests/ublk/test_loop_04.sh | 1 -
tools/testing/selftests/ublk/test_loop_05.sh | 1 -
tools/testing/selftests/ublk/test_loop_06.sh | 1 -
tools/testing/selftests/ublk/test_loop_07.sh | 1 -
tools/testing/selftests/ublk/test_loop_08.sh | 1 -
tools/testing/selftests/ublk/test_null_01.sh | 1 -
tools/testing/selftests/ublk/test_null_02.sh | 1 -
tools/testing/selftests/ublk/test_null_03.sh | 1 -
tools/testing/selftests/ublk/test_null_04.sh | 249 +++++++-----------
tools/testing/selftests/ublk/test_part_01.sh | 104 ++++++++
.../{test_generic_15.sh => test_part_02.sh} | 1 -
.../testing/selftests/ublk/test_stress_01.sh | 1 -
.../testing/selftests/ublk/test_stress_02.sh | 1 -
.../testing/selftests/ublk/test_stress_03.sh | 1 -
.../testing/selftests/ublk/test_stress_04.sh | 1 -
.../testing/selftests/ublk/test_stress_05.sh | 1 -
.../testing/selftests/ublk/test_stress_06.sh | 1 -
.../testing/selftests/ublk/test_stress_07.sh | 1 -
.../testing/selftests/ublk/test_stress_08.sh | 1 -
.../testing/selftests/ublk/test_stress_09.sh | 1 -
.../testing/selftests/ublk/test_stripe_01.sh | 1 -
.../testing/selftests/ublk/test_stripe_02.sh | 1 -
.../testing/selftests/ublk/test_stripe_03.sh | 1 -
.../testing/selftests/ublk/test_stripe_04.sh | 1 -
.../testing/selftests/ublk/test_stripe_05.sh | 1 -
.../testing/selftests/ublk/test_stripe_06.sh | 1 -
53 files changed, 249 insertions(+), 213 deletions(-)
create mode 100755 tools/testing/selftests/ublk/test_part_01.sh
rename tools/testing/selftests/ublk/{test_generic_15.sh => test_part_02.sh} (99%)
--
2.47.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH V2 1/9] ublk: check list membership before cancelling batch fetch command
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 2/9] ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag Ming Lei
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
Add !list_empty(&fcmd->node) check in ublk_batch_cancel_cmd() to ensure
the fcmd hasn't already been removed from the list. Once an fcmd is
removed from the list, it's considered claimed by whoever removed it
and will be freed by that path.
Meantime switch to list_del_init() for deleting it from list.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/ublk_drv.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 8a5a6ba29a1d..94470a2ec05e 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -738,7 +738,7 @@ static void ublk_batch_deinit_fetch_buf(struct ublk_queue *ubq,
int res)
{
spin_lock(&ubq->evts_lock);
- list_del(&fcmd->node);
+ list_del_init(&fcmd->node);
WARN_ON_ONCE(fcmd != ubq->active_fcmd);
__ublk_release_fcmd(ubq);
spin_unlock(&ubq->evts_lock);
@@ -2693,6 +2693,16 @@ static void ublk_cancel_cmd(struct ublk_queue *ubq, unsigned tag,
io_uring_cmd_done(io->cmd, UBLK_IO_RES_ABORT, issue_flags);
}
+/*
+ * Cancel a batch fetch command if it hasn't been claimed by another path.
+ *
+ * An fcmd can only be cancelled if:
+ * 1. It's not the active_fcmd (which is currently being processed)
+ * 2. It's still on the list (!list_empty check) - once removed from the list,
+ * the fcmd is considered claimed and will be freed by whoever removed it
+ *
+ * Use list_del_init() so subsequent list_empty() checks work correctly.
+ */
static void ublk_batch_cancel_cmd(struct ublk_queue *ubq,
struct ublk_batch_fetch_cmd *fcmd,
unsigned int issue_flags)
@@ -2700,9 +2710,9 @@ static void ublk_batch_cancel_cmd(struct ublk_queue *ubq,
bool done;
spin_lock(&ubq->evts_lock);
- done = (READ_ONCE(ubq->active_fcmd) != fcmd);
+ done = (READ_ONCE(ubq->active_fcmd) != fcmd) && !list_empty(&fcmd->node);
if (done)
- list_del(&fcmd->node);
+ list_del_init(&fcmd->node);
spin_unlock(&ubq->evts_lock);
if (done) {
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 2/9] ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
2026-01-29 16:19 ` [PATCH V2 1/9] ublk: check list membership before cancelling batch fetch command Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 3/9] selftests: ublk: derive TID automatically from script name Ming Lei
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei,
Yoav Cohen
Add a new feature flag UBLK_F_NO_AUTO_PART_SCAN to allow users to suppress
automatic partition scanning when starting a ublk device.
This is useful for some cases in which user don't want to scan
partitions.
Users still can manually trigger partition scanning later when appropriate
using standard tools (e.g., partprobe, blockdev --rereadpt).
Reported-by: Yoav Cohen <yoav@nvidia.com>
Link: https://lore.kernel.org/linux-block/DM4PR12MB63280C5637917C071C2F0D65A9A8A@DM4PR12MB6328.namprd12.prod.outlook.com/
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/ublk_drv.c | 14 ++++++++++----
include/uapi/linux/ublk_cmd.h | 3 +++
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 94470a2ec05e..aa9ea39249b0 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -80,7 +80,8 @@
| UBLK_F_BUF_REG_OFF_DAEMON \
| (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) ? UBLK_F_INTEGRITY : 0) \
| UBLK_F_SAFE_STOP_DEV \
- | UBLK_F_BATCH_IO)
+ | UBLK_F_BATCH_IO \
+ | UBLK_F_NO_AUTO_PART_SCAN)
#define UBLK_F_ALL_RECOVERY_FLAGS (UBLK_F_USER_RECOVERY \
| UBLK_F_USER_RECOVERY_REISSUE \
@@ -4430,9 +4431,14 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,
set_bit(UB_STATE_USED, &ub->state);
- /* Schedule async partition scan for trusted daemons */
- if (!ub->unprivileged_daemons)
- schedule_work(&ub->partition_scan_work);
+ /* Skip partition scan if disabled by user */
+ if (ub->dev_info.flags & UBLK_F_NO_AUTO_PART_SCAN) {
+ clear_bit(GD_SUPPRESS_PART_SCAN, &disk->state);
+ } else {
+ /* Schedule async partition scan for trusted daemons */
+ if (!ub->unprivileged_daemons)
+ schedule_work(&ub->partition_scan_work);
+ }
out_put_cdev:
if (ret) {
diff --git a/include/uapi/linux/ublk_cmd.h b/include/uapi/linux/ublk_cmd.h
index 743d31491387..a88876756805 100644
--- a/include/uapi/linux/ublk_cmd.h
+++ b/include/uapi/linux/ublk_cmd.h
@@ -367,6 +367,9 @@
*/
#define UBLK_F_SAFE_STOP_DEV (1ULL << 17)
+/* Disable automatic partition scanning when device is started */
+#define UBLK_F_NO_AUTO_PART_SCAN (1ULL << 18)
+
/* device state */
#define UBLK_S_DEV_DEAD 0
#define UBLK_S_DEV_LIVE 1
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 3/9] selftests: ublk: derive TID automatically from script name
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
2026-01-29 16:19 ` [PATCH V2 1/9] ublk: check list membership before cancelling batch fetch command Ming Lei
2026-01-29 16:19 ` [PATCH V2 2/9] ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 4/9] selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN Ming Lei
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
Add automatic TID derivation in test_common.sh based on the script
filename. The TID is extracted by stripping the "test_" prefix and
".sh" suffix from the script name (e.g., test_loop_01.sh -> loop_01).
This removes the need for each test script to manually define TID,
reducing boilerplate and preventing potential mismatches between
the script name and TID. Scripts can still override TID after
sourcing test_common.sh if needed.
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tools/testing/selftests/ublk/test_batch_01.sh | 1 -
tools/testing/selftests/ublk/test_batch_02.sh | 1 -
tools/testing/selftests/ublk/test_batch_03.sh | 1 -
tools/testing/selftests/ublk/test_common.sh | 5 +++++
tools/testing/selftests/ublk/test_generic_01.sh | 1 -
tools/testing/selftests/ublk/test_generic_02.sh | 1 -
tools/testing/selftests/ublk/test_generic_03.sh | 1 -
tools/testing/selftests/ublk/test_generic_04.sh | 1 -
tools/testing/selftests/ublk/test_generic_05.sh | 1 -
tools/testing/selftests/ublk/test_generic_06.sh | 1 -
tools/testing/selftests/ublk/test_generic_07.sh | 1 -
tools/testing/selftests/ublk/test_generic_08.sh | 1 -
tools/testing/selftests/ublk/test_generic_09.sh | 1 -
tools/testing/selftests/ublk/test_generic_10.sh | 1 -
tools/testing/selftests/ublk/test_generic_11.sh | 1 -
tools/testing/selftests/ublk/test_generic_12.sh | 1 -
tools/testing/selftests/ublk/test_generic_13.sh | 1 -
tools/testing/selftests/ublk/test_generic_14.sh | 1 -
tools/testing/selftests/ublk/test_generic_15.sh | 1 -
tools/testing/selftests/ublk/test_generic_16.sh | 1 -
tools/testing/selftests/ublk/test_loop_01.sh | 1 -
tools/testing/selftests/ublk/test_loop_02.sh | 1 -
tools/testing/selftests/ublk/test_loop_03.sh | 1 -
tools/testing/selftests/ublk/test_loop_04.sh | 1 -
tools/testing/selftests/ublk/test_loop_05.sh | 1 -
tools/testing/selftests/ublk/test_loop_06.sh | 1 -
tools/testing/selftests/ublk/test_loop_07.sh | 1 -
tools/testing/selftests/ublk/test_loop_08.sh | 1 -
tools/testing/selftests/ublk/test_null_01.sh | 1 -
tools/testing/selftests/ublk/test_null_02.sh | 1 -
tools/testing/selftests/ublk/test_null_03.sh | 1 -
tools/testing/selftests/ublk/test_null_04.sh | 1 -
tools/testing/selftests/ublk/test_stress_01.sh | 1 -
tools/testing/selftests/ublk/test_stress_02.sh | 1 -
tools/testing/selftests/ublk/test_stress_03.sh | 1 -
tools/testing/selftests/ublk/test_stress_04.sh | 1 -
tools/testing/selftests/ublk/test_stress_05.sh | 1 -
tools/testing/selftests/ublk/test_stress_06.sh | 1 -
tools/testing/selftests/ublk/test_stress_07.sh | 1 -
tools/testing/selftests/ublk/test_stress_08.sh | 1 -
tools/testing/selftests/ublk/test_stress_09.sh | 1 -
tools/testing/selftests/ublk/test_stripe_01.sh | 1 -
tools/testing/selftests/ublk/test_stripe_02.sh | 1 -
tools/testing/selftests/ublk/test_stripe_03.sh | 1 -
tools/testing/selftests/ublk/test_stripe_04.sh | 1 -
tools/testing/selftests/ublk/test_stripe_05.sh | 1 -
tools/testing/selftests/ublk/test_stripe_06.sh | 1 -
47 files changed, 5 insertions(+), 46 deletions(-)
diff --git a/tools/testing/selftests/ublk/test_batch_01.sh b/tools/testing/selftests/ublk/test_batch_01.sh
index 9fa9fff5c62f..a18fb39af8be 100755
--- a/tools/testing/selftests/ublk/test_batch_01.sh
+++ b/tools/testing/selftests/ublk/test_batch_01.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="batch_01"
ERR_CODE=0
if ! _have_feature "BATCH_IO"; then
diff --git a/tools/testing/selftests/ublk/test_batch_02.sh b/tools/testing/selftests/ublk/test_batch_02.sh
index b477f91359e1..7ca384d11987 100755
--- a/tools/testing/selftests/ublk/test_batch_02.sh
+++ b/tools/testing/selftests/ublk/test_batch_02.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="batch_02"
ERR_CODE=0
if ! _have_feature "BATCH_IO"; then
diff --git a/tools/testing/selftests/ublk/test_batch_03.sh b/tools/testing/selftests/ublk/test_batch_03.sh
index 13a2b3d3a1b9..aca9cf144b55 100755
--- a/tools/testing/selftests/ublk/test_batch_03.sh
+++ b/tools/testing/selftests/ublk/test_batch_03.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="batch_03"
ERR_CODE=0
if ! _have_feature "BATCH_IO"; then
diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh
index 7ff6ce79d62c..bbe031c94a29 100755
--- a/tools/testing/selftests/ublk/test_common.sh
+++ b/tools/testing/selftests/ublk/test_common.sh
@@ -1,6 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
+# Derive TID from script name: test_<type>_<num>.sh -> <type>_<num>
+# Can be overridden in test script after sourcing this file
+TID=$(basename "$0" .sh)
+TID=${TID#test_}
+
UBLK_SKIP_CODE=4
_have_program() {
diff --git a/tools/testing/selftests/ublk/test_generic_01.sh b/tools/testing/selftests/ublk/test_generic_01.sh
index 21a31cd5491a..26cf3c7ceeb5 100755
--- a/tools/testing/selftests/ublk/test_generic_01.sh
+++ b/tools/testing/selftests/ublk/test_generic_01.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_01"
ERR_CODE=0
if ! _have_program bpftrace; then
diff --git a/tools/testing/selftests/ublk/test_generic_02.sh b/tools/testing/selftests/ublk/test_generic_02.sh
index 12920768b1a0..1d4b1d6e059c 100755
--- a/tools/testing/selftests/ublk/test_generic_02.sh
+++ b/tools/testing/selftests/ublk/test_generic_02.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_02"
ERR_CODE=0
if ! _have_program bpftrace; then
diff --git a/tools/testing/selftests/ublk/test_generic_03.sh b/tools/testing/selftests/ublk/test_generic_03.sh
index b551aa76cb0d..8934ea926762 100755
--- a/tools/testing/selftests/ublk/test_generic_03.sh
+++ b/tools/testing/selftests/ublk/test_generic_03.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_03"
ERR_CODE=0
_prep_test "null" "check dma & segment limits for zero copy"
diff --git a/tools/testing/selftests/ublk/test_generic_04.sh b/tools/testing/selftests/ublk/test_generic_04.sh
index be2292822bbe..2672f9c40fa8 100755
--- a/tools/testing/selftests/ublk/test_generic_04.sh
+++ b/tools/testing/selftests/ublk/test_generic_04.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_04"
ERR_CODE=0
ublk_run_recover_test()
diff --git a/tools/testing/selftests/ublk/test_generic_05.sh b/tools/testing/selftests/ublk/test_generic_05.sh
index 9b7f71c16d82..bda5064bc31f 100755
--- a/tools/testing/selftests/ublk/test_generic_05.sh
+++ b/tools/testing/selftests/ublk/test_generic_05.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_05"
ERR_CODE=0
ublk_run_recover_test()
diff --git a/tools/testing/selftests/ublk/test_generic_06.sh b/tools/testing/selftests/ublk/test_generic_06.sh
index fd42062b7b76..14a05054fcd8 100755
--- a/tools/testing/selftests/ublk/test_generic_06.sh
+++ b/tools/testing/selftests/ublk/test_generic_06.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_06"
ERR_CODE=0
_prep_test "fault_inject" "fast cleanup when all I/Os of one hctx are in server"
diff --git a/tools/testing/selftests/ublk/test_generic_07.sh b/tools/testing/selftests/ublk/test_generic_07.sh
index cba86451fa5e..8dcfd8978f50 100755
--- a/tools/testing/selftests/ublk/test_generic_07.sh
+++ b/tools/testing/selftests/ublk/test_generic_07.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_07"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_generic_08.sh b/tools/testing/selftests/ublk/test_generic_08.sh
index b222f3a77e12..ce88c31d6b9c 100755
--- a/tools/testing/selftests/ublk/test_generic_08.sh
+++ b/tools/testing/selftests/ublk/test_generic_08.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_08"
ERR_CODE=0
if ! _have_feature "AUTO_BUF_REG"; then
diff --git a/tools/testing/selftests/ublk/test_generic_09.sh b/tools/testing/selftests/ublk/test_generic_09.sh
index bb6f77ca5522..744d0cdaa242 100755
--- a/tools/testing/selftests/ublk/test_generic_09.sh
+++ b/tools/testing/selftests/ublk/test_generic_09.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_09"
ERR_CODE=0
if ! _have_feature "AUTO_BUF_REG"; then
diff --git a/tools/testing/selftests/ublk/test_generic_10.sh b/tools/testing/selftests/ublk/test_generic_10.sh
index abc11c3d416b..4b4293b9081f 100755
--- a/tools/testing/selftests/ublk/test_generic_10.sh
+++ b/tools/testing/selftests/ublk/test_generic_10.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_10"
ERR_CODE=0
if ! _have_feature "UPDATE_SIZE"; then
diff --git a/tools/testing/selftests/ublk/test_generic_11.sh b/tools/testing/selftests/ublk/test_generic_11.sh
index d1f973c8c645..e0dc0b8fe5d6 100755
--- a/tools/testing/selftests/ublk/test_generic_11.sh
+++ b/tools/testing/selftests/ublk/test_generic_11.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_11"
ERR_CODE=0
ublk_run_quiesce_recover()
diff --git a/tools/testing/selftests/ublk/test_generic_12.sh b/tools/testing/selftests/ublk/test_generic_12.sh
index b4046201b4d9..54b81ddfe9f9 100755
--- a/tools/testing/selftests/ublk/test_generic_12.sh
+++ b/tools/testing/selftests/ublk/test_generic_12.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_12"
ERR_CODE=0
if ! _have_program bpftrace; then
diff --git a/tools/testing/selftests/ublk/test_generic_13.sh b/tools/testing/selftests/ublk/test_generic_13.sh
index b7aa90b1cb74..922115aa14f4 100755
--- a/tools/testing/selftests/ublk/test_generic_13.sh
+++ b/tools/testing/selftests/ublk/test_generic_13.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_13"
ERR_CODE=0
_prep_test "null" "check that feature list is complete"
diff --git a/tools/testing/selftests/ublk/test_generic_14.sh b/tools/testing/selftests/ublk/test_generic_14.sh
index cd9b44b97c24..178443394ca5 100755
--- a/tools/testing/selftests/ublk/test_generic_14.sh
+++ b/tools/testing/selftests/ublk/test_generic_14.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_14"
ERR_CODE=0
ublk_run_recover_test()
diff --git a/tools/testing/selftests/ublk/test_generic_15.sh b/tools/testing/selftests/ublk/test_generic_15.sh
index 76379362e0a2..727d0f4610d6 100755
--- a/tools/testing/selftests/ublk/test_generic_15.sh
+++ b/tools/testing/selftests/ublk/test_generic_15.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_15"
ERR_CODE=0
_test_partition_scan_no_hang()
diff --git a/tools/testing/selftests/ublk/test_generic_16.sh b/tools/testing/selftests/ublk/test_generic_16.sh
index e08af7b685c9..42e8d2e16ec9 100755
--- a/tools/testing/selftests/ublk/test_generic_16.sh
+++ b/tools/testing/selftests/ublk/test_generic_16.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="generic_16"
ERR_CODE=0
_prep_test "null" "stop --safe command"
diff --git a/tools/testing/selftests/ublk/test_loop_01.sh b/tools/testing/selftests/ublk/test_loop_01.sh
index 833fa0dbc700..338a235fd82a 100755
--- a/tools/testing/selftests/ublk/test_loop_01.sh
+++ b/tools/testing/selftests/ublk/test_loop_01.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="loop_01"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_loop_02.sh b/tools/testing/selftests/ublk/test_loop_02.sh
index 874568b3646b..04c52454e2ec 100755
--- a/tools/testing/selftests/ublk/test_loop_02.sh
+++ b/tools/testing/selftests/ublk/test_loop_02.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="loop_02"
ERR_CODE=0
_prep_test "loop" "mkfs & mount & umount"
diff --git a/tools/testing/selftests/ublk/test_loop_03.sh b/tools/testing/selftests/ublk/test_loop_03.sh
index c30f797c6429..6e8f649fe93d 100755
--- a/tools/testing/selftests/ublk/test_loop_03.sh
+++ b/tools/testing/selftests/ublk/test_loop_03.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="loop_03"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_loop_04.sh b/tools/testing/selftests/ublk/test_loop_04.sh
index b01d75b3214d..9f6774ec0de6 100755
--- a/tools/testing/selftests/ublk/test_loop_04.sh
+++ b/tools/testing/selftests/ublk/test_loop_04.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="loop_04"
ERR_CODE=0
_prep_test "loop" "mkfs & mount & umount with zero copy"
diff --git a/tools/testing/selftests/ublk/test_loop_05.sh b/tools/testing/selftests/ublk/test_loop_05.sh
index de2141533074..2b8d99e007be 100755
--- a/tools/testing/selftests/ublk/test_loop_05.sh
+++ b/tools/testing/selftests/ublk/test_loop_05.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="loop_05"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_loop_06.sh b/tools/testing/selftests/ublk/test_loop_06.sh
index 1d1a8a725502..e73f6f4844db 100755
--- a/tools/testing/selftests/ublk/test_loop_06.sh
+++ b/tools/testing/selftests/ublk/test_loop_06.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="loop_06"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_loop_07.sh b/tools/testing/selftests/ublk/test_loop_07.sh
index 493f3fb611a5..264d20e7c530 100755
--- a/tools/testing/selftests/ublk/test_loop_07.sh
+++ b/tools/testing/selftests/ublk/test_loop_07.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="loop_07"
ERR_CODE=0
_prep_test "loop" "mkfs & mount & umount with user copy"
diff --git a/tools/testing/selftests/ublk/test_loop_08.sh b/tools/testing/selftests/ublk/test_loop_08.sh
index ca289cfb2ad4..2caa7ba748fb 100755
--- a/tools/testing/selftests/ublk/test_loop_08.sh
+++ b/tools/testing/selftests/ublk/test_loop_08.sh
@@ -13,7 +13,6 @@ if [[ "$fio_version" =~ fio-[0-9]+\.[0-9]+$ ]]; then
exit $UBLK_SKIP_CODE
fi
-TID=loop_08
_prep_test "loop" "end-to-end integrity"
diff --git a/tools/testing/selftests/ublk/test_null_01.sh b/tools/testing/selftests/ublk/test_null_01.sh
index c2cb8f7a09fe..eebce8076530 100755
--- a/tools/testing/selftests/ublk/test_null_01.sh
+++ b/tools/testing/selftests/ublk/test_null_01.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="null_01"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_null_02.sh b/tools/testing/selftests/ublk/test_null_02.sh
index 8accd35beb55..654bdff39664 100755
--- a/tools/testing/selftests/ublk/test_null_02.sh
+++ b/tools/testing/selftests/ublk/test_null_02.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="null_02"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_null_03.sh b/tools/testing/selftests/ublk/test_null_03.sh
index 0051067b4686..29cd09f06672 100755
--- a/tools/testing/selftests/ublk/test_null_03.sh
+++ b/tools/testing/selftests/ublk/test_null_03.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="null_03"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_null_04.sh b/tools/testing/selftests/ublk/test_null_04.sh
index 0b0719ea33a3..7491b8c17f00 100755
--- a/tools/testing/selftests/ublk/test_null_04.sh
+++ b/tools/testing/selftests/ublk/test_null_04.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID=null_04
_prep_test "null" "integrity params"
diff --git a/tools/testing/selftests/ublk/test_stress_01.sh b/tools/testing/selftests/ublk/test_stress_01.sh
index 7d3150f057d4..a9322ce496e9 100755
--- a/tools/testing/selftests/ublk/test_stress_01.sh
+++ b/tools/testing/selftests/ublk/test_stress_01.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_01"
ERR_CODE=0
ublk_io_and_remove()
diff --git a/tools/testing/selftests/ublk/test_stress_02.sh b/tools/testing/selftests/ublk/test_stress_02.sh
index 4bdd921081e5..6c114194f9c9 100755
--- a/tools/testing/selftests/ublk/test_stress_02.sh
+++ b/tools/testing/selftests/ublk/test_stress_02.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_02"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_stress_03.sh b/tools/testing/selftests/ublk/test_stress_03.sh
index 3ed4c9b2d8c0..4e81ca0db758 100755
--- a/tools/testing/selftests/ublk/test_stress_03.sh
+++ b/tools/testing/selftests/ublk/test_stress_03.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_03"
ERR_CODE=0
ublk_io_and_remove()
diff --git a/tools/testing/selftests/ublk/test_stress_04.sh b/tools/testing/selftests/ublk/test_stress_04.sh
index efa8dc33234b..6c6f44b172bc 100755
--- a/tools/testing/selftests/ublk/test_stress_04.sh
+++ b/tools/testing/selftests/ublk/test_stress_04.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_04"
ERR_CODE=0
ublk_io_and_kill_daemon()
diff --git a/tools/testing/selftests/ublk/test_stress_05.sh b/tools/testing/selftests/ublk/test_stress_05.sh
index 68a194144302..7e9324de2030 100755
--- a/tools/testing/selftests/ublk/test_stress_05.sh
+++ b/tools/testing/selftests/ublk/test_stress_05.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_05"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_stress_06.sh b/tools/testing/selftests/ublk/test_stress_06.sh
index 37188ec2e1f7..c72e5d0b14be 100755
--- a/tools/testing/selftests/ublk/test_stress_06.sh
+++ b/tools/testing/selftests/ublk/test_stress_06.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_06"
ERR_CODE=0
ublk_io_and_remove()
diff --git a/tools/testing/selftests/ublk/test_stress_07.sh b/tools/testing/selftests/ublk/test_stress_07.sh
index fb061fc26d36..04c2764d5238 100755
--- a/tools/testing/selftests/ublk/test_stress_07.sh
+++ b/tools/testing/selftests/ublk/test_stress_07.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_07"
ERR_CODE=0
ublk_io_and_kill_daemon()
diff --git a/tools/testing/selftests/ublk/test_stress_08.sh b/tools/testing/selftests/ublk/test_stress_08.sh
index 9abb50ee3d00..37f7d204879a 100755
--- a/tools/testing/selftests/ublk/test_stress_08.sh
+++ b/tools/testing/selftests/ublk/test_stress_08.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_08"
ERR_CODE=0
ublk_io_and_remove()
diff --git a/tools/testing/selftests/ublk/test_stress_09.sh b/tools/testing/selftests/ublk/test_stress_09.sh
index 87b92b0a2410..53c1e3b2ab30 100755
--- a/tools/testing/selftests/ublk/test_stress_09.sh
+++ b/tools/testing/selftests/ublk/test_stress_09.sh
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stress_09"
ERR_CODE=0
ublk_io_and_kill_daemon()
diff --git a/tools/testing/selftests/ublk/test_stripe_01.sh b/tools/testing/selftests/ublk/test_stripe_01.sh
index 4e4f0fdf3c9b..3bc821aadad8 100755
--- a/tools/testing/selftests/ublk/test_stripe_01.sh
+++ b/tools/testing/selftests/ublk/test_stripe_01.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stripe_01"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_stripe_02.sh b/tools/testing/selftests/ublk/test_stripe_02.sh
index 5820ab2efba4..4a7d2b21a6bf 100755
--- a/tools/testing/selftests/ublk/test_stripe_02.sh
+++ b/tools/testing/selftests/ublk/test_stripe_02.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stripe_02"
ERR_CODE=0
_prep_test "stripe" "mkfs & mount & umount"
diff --git a/tools/testing/selftests/ublk/test_stripe_03.sh b/tools/testing/selftests/ublk/test_stripe_03.sh
index 20b977e27814..a1c159d54e53 100755
--- a/tools/testing/selftests/ublk/test_stripe_03.sh
+++ b/tools/testing/selftests/ublk/test_stripe_03.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stripe_03"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_stripe_04.sh b/tools/testing/selftests/ublk/test_stripe_04.sh
index 1b51ed2f1d84..0c30bd6c2b3b 100755
--- a/tools/testing/selftests/ublk/test_stripe_04.sh
+++ b/tools/testing/selftests/ublk/test_stripe_04.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stripe_04"
ERR_CODE=0
_prep_test "stripe" "mkfs & mount & umount on zero copy"
diff --git a/tools/testing/selftests/ublk/test_stripe_05.sh b/tools/testing/selftests/ublk/test_stripe_05.sh
index 05d71951d710..6ddfa88ad226 100755
--- a/tools/testing/selftests/ublk/test_stripe_05.sh
+++ b/tools/testing/selftests/ublk/test_stripe_05.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stripe_05"
ERR_CODE=0
if ! _have_program fio; then
diff --git a/tools/testing/selftests/ublk/test_stripe_06.sh b/tools/testing/selftests/ublk/test_stripe_06.sh
index d06cac7626e2..a2c7bf4cc613 100755
--- a/tools/testing/selftests/ublk/test_stripe_06.sh
+++ b/tools/testing/selftests/ublk/test_stripe_06.sh
@@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
-TID="stripe_06"
ERR_CODE=0
_prep_test "stripe" "mkfs & mount & umount on user copy"
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 4/9] selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
` (2 preceding siblings ...)
2026-01-29 16:19 ` [PATCH V2 3/9] selftests: ublk: derive TID automatically from script name Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 5/9] selftests: ublk: rename test_generic_15 to test_part_02 Ming Lei
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
Add test_part_01.sh to test the UBLK_F_NO_AUTO_PART_SCAN feature
flag which allows suppressing automatic partition scanning during
device startup while still allowing manual partition probing.
The test verifies:
- Normal behavior: partitions are auto-detected without the flag
- With flag: partitions are not auto-detected during START_DEV
- Manual scan: blockdev --rereadpt works with the flag
Also update kublk tool to support --no_auto_part_scan option and
recognize the feature flag.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tools/testing/selftests/ublk/Makefile | 2 +
tools/testing/selftests/ublk/kublk.c | 6 +-
tools/testing/selftests/ublk/kublk.h | 3 +-
tools/testing/selftests/ublk/test_part_01.sh | 104 +++++++++++++++++++
4 files changed, 113 insertions(+), 2 deletions(-)
create mode 100755 tools/testing/selftests/ublk/test_part_01.sh
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index e39a6f871fcc..bc5bd7d1381d 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -48,6 +48,8 @@ TEST_PROGS += test_stripe_04.sh
TEST_PROGS += test_stripe_05.sh
TEST_PROGS += test_stripe_06.sh
+TEST_PROGS += test_part_01.sh
+
TEST_PROGS += test_stress_01.sh
TEST_PROGS += test_stress_02.sh
TEST_PROGS += test_stress_03.sh
diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
index 2da37557e1a9..e8279c4acc40 100644
--- a/tools/testing/selftests/ublk/kublk.c
+++ b/tools/testing/selftests/ublk/kublk.c
@@ -1615,6 +1615,7 @@ static int cmd_dev_get_features(void)
FEAT_NAME(UBLK_F_INTEGRITY),
FEAT_NAME(UBLK_F_SAFE_STOP_DEV),
FEAT_NAME(UBLK_F_BATCH_IO),
+ FEAT_NAME(UBLK_F_NO_AUTO_PART_SCAN),
};
struct ublk_dev *dev;
__u64 features = 0;
@@ -1712,7 +1713,7 @@ static void __cmd_create_help(char *exe, bool recovery)
printf("\t[--nthreads threads] [--per_io_tasks]\n");
printf("\t[--integrity_capable] [--integrity_reftag] [--metadata_size SIZE] "
"[--pi_offset OFFSET] [--csum_type ip|t10dif|nvme] [--tag_size SIZE]\n");
- printf("\t[--batch|-b]\n");
+ printf("\t[--batch|-b] [--no_auto_part_scan]\n");
printf("\t[target options] [backfile1] [backfile2] ...\n");
printf("\tdefault: nr_queues=2(max 32), depth=128(max 1024), dev_id=-1(auto allocation)\n");
printf("\tdefault: nthreads=nr_queues");
@@ -1786,6 +1787,7 @@ int main(int argc, char *argv[])
{ "tag_size", 1, NULL, 0 },
{ "safe", 0, NULL, 0 },
{ "batch", 0, NULL, 'b'},
+ { "no_auto_part_scan", 0, NULL, 0 },
{ 0, 0, 0, 0 }
};
const struct ublk_tgt_ops *ops = NULL;
@@ -1898,6 +1900,8 @@ int main(int argc, char *argv[])
ctx.tag_size = strtoul(optarg, NULL, 0);
if (!strcmp(longopts[option_idx].name, "safe"))
ctx.safe_stop = 1;
+ if (!strcmp(longopts[option_idx].name, "no_auto_part_scan"))
+ ctx.flags |= UBLK_F_NO_AUTO_PART_SCAN;
break;
case '?':
/*
diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h
index ca97deb5e208..1faeccaaecae 100644
--- a/tools/testing/selftests/ublk/kublk.h
+++ b/tools/testing/selftests/ublk/kublk.h
@@ -78,12 +78,13 @@ struct dev_ctx {
unsigned int auto_zc_fallback:1;
unsigned int per_io_tasks:1;
unsigned int no_ublk_fixed_fd:1;
+ unsigned int safe_stop:1;
+ unsigned int no_auto_part_scan:1;
__u32 integrity_flags;
__u8 metadata_size;
__u8 pi_offset;
__u8 csum_type;
__u8 tag_size;
- unsigned int safe_stop:1;
int _evtfd;
int _shmid;
diff --git a/tools/testing/selftests/ublk/test_part_01.sh b/tools/testing/selftests/ublk/test_part_01.sh
new file mode 100755
index 000000000000..8028f6e4b3a5
--- /dev/null
+++ b/tools/testing/selftests/ublk/test_part_01.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
+
+ERR_CODE=0
+
+format_backing_file()
+{
+ local backing_file=$1
+
+ # Create ublk device to write partition table
+ local tmp_dev=$(_add_ublk_dev -t loop "${backing_file}")
+ [ $? -ne 0 ] && return 1
+
+ # Write partition table with sfdisk
+ sfdisk /dev/ublkb"${tmp_dev}" > /dev/null 2>&1 <<EOF
+label: dos
+start=2048, size=100MiB, type=83
+start=206848, size=100MiB, type=83
+EOF
+ local ret=$?
+
+ "${UBLK_PROG}" del -n "${tmp_dev}"
+
+ return $ret
+}
+
+test_auto_part_scan()
+{
+ local backing_file=$1
+
+ # Create device WITHOUT --no_auto_part_scan
+ local dev_id=$(_add_ublk_dev -t loop "${backing_file}")
+ [ $? -ne 0 ] && return 1
+
+ udevadm settle
+
+ # Partitions should be auto-detected
+ if [ ! -e /dev/ublkb"${dev_id}"p1 ] || [ ! -e /dev/ublkb"${dev_id}"p2 ]; then
+ "${UBLK_PROG}" del -n "${dev_id}"
+ return 1
+ fi
+
+ "${UBLK_PROG}" del -n "${dev_id}"
+ return 0
+}
+
+test_no_auto_part_scan()
+{
+ local backing_file=$1
+
+ # Create device WITH --no_auto_part_scan
+ local dev_id=$(_add_ublk_dev -t loop --no_auto_part_scan "${backing_file}")
+ [ $? -ne 0 ] && return 1
+
+ udevadm settle
+
+ # Partitions should NOT be auto-detected
+ if [ -e /dev/ublkb"${dev_id}"p1 ]; then
+ "${UBLK_PROG}" del -n "${dev_id}"
+ return 1
+ fi
+
+ # Manual scan should work
+ blockdev --rereadpt /dev/ublkb"${dev_id}" > /dev/null 2>&1
+ udevadm settle
+
+ if [ ! -e /dev/ublkb"${dev_id}"p1 ] || [ ! -e /dev/ublkb"${dev_id}"p2 ]; then
+ "${UBLK_PROG}" del -n "${dev_id}"
+ return 1
+ fi
+
+ "${UBLK_PROG}" del -n "${dev_id}"
+ return 0
+}
+
+if ! _have_program sfdisk || ! _have_program blockdev; then
+ exit "$UBLK_SKIP_CODE"
+fi
+
+_prep_test "generic" "test UBLK_F_NO_AUTO_PART_SCAN"
+
+if ! _have_feature "UBLK_F_NO_AUTO_PART_SCAN"; then
+ _cleanup_test "generic"
+ exit "$UBLK_SKIP_CODE"
+fi
+
+
+# Create and format backing file with partition table
+_create_backfile 0 256M
+format_backing_file "${UBLK_BACKFILES[0]}"
+[ $? -ne 0 ] && ERR_CODE=255
+
+# Test normal auto partition scan
+[ "$ERR_CODE" -eq 0 ] && test_auto_part_scan "${UBLK_BACKFILES[0]}"
+[ $? -ne 0 ] && ERR_CODE=255
+
+# Test no auto partition scan with manual scan
+[ "$ERR_CODE" -eq 0 ] && test_no_auto_part_scan "${UBLK_BACKFILES[0]}"
+[ $? -ne 0 ] && ERR_CODE=255
+
+_cleanup_test "generic"
+_show_result $TID $ERR_CODE
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 5/9] selftests: ublk: rename test_generic_15 to test_part_02
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
` (3 preceding siblings ...)
2026-01-29 16:19 ` [PATCH V2 4/9] selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 6/9] selftests: ublk: refactor test_null_04 into separate functions Ming Lei
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
This test exercises partition scanning behavior, so move it to
the test_part_* group for consistency.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tools/testing/selftests/ublk/Makefile | 2 +-
.../selftests/ublk/{test_generic_15.sh => test_part_02.sh} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename tools/testing/selftests/ublk/{test_generic_15.sh => test_part_02.sh} (100%)
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index bc5bd7d1381d..ca8588ed962c 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -22,7 +22,6 @@ TEST_PROGS += test_generic_11.sh
TEST_PROGS += test_generic_12.sh
TEST_PROGS += test_generic_13.sh
TEST_PROGS += test_generic_14.sh
-TEST_PROGS += test_generic_15.sh
TEST_PROGS += test_generic_16.sh
TEST_PROGS += test_batch_01.sh
@@ -49,6 +48,7 @@ TEST_PROGS += test_stripe_05.sh
TEST_PROGS += test_stripe_06.sh
TEST_PROGS += test_part_01.sh
+TEST_PROGS += test_part_02.sh
TEST_PROGS += test_stress_01.sh
TEST_PROGS += test_stress_02.sh
diff --git a/tools/testing/selftests/ublk/test_generic_15.sh b/tools/testing/selftests/ublk/test_part_02.sh
similarity index 100%
rename from tools/testing/selftests/ublk/test_generic_15.sh
rename to tools/testing/selftests/ublk/test_part_02.sh
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 6/9] selftests: ublk: refactor test_null_04 into separate functions
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
` (4 preceding siblings ...)
2026-01-29 16:19 ` [PATCH V2 5/9] selftests: ublk: rename test_generic_15 to test_part_02 Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 7/9] selftests: ublk: disable partition scan for integrity tests Ming Lei
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
Encapsulate each test case in its own function that creates the
device, runs checks, and deletes only that device. This avoids
calling _cleanup_test multiple times.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tools/testing/selftests/ublk/test_null_04.sh | 248 +++++++------------
1 file changed, 94 insertions(+), 154 deletions(-)
diff --git a/tools/testing/selftests/ublk/test_null_04.sh b/tools/testing/selftests/ublk/test_null_04.sh
index 7491b8c17f00..22328e0f3925 100755
--- a/tools/testing/selftests/ublk/test_null_04.sh
+++ b/tools/testing/selftests/ublk/test_null_04.sh
@@ -3,163 +3,103 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
+ERR_CODE=0
-_prep_test "null" "integrity params"
+_check_value() {
+ local name=$1
+ local actual=$2
+ local expected=$3
-dev_id=$(_add_ublk_dev -t null -u --metadata_size 8)
-_check_add_dev $TID $?
-metadata_size=$(_get_metadata_size "$dev_id" metadata_size)
-if [ "$metadata_size" != 8 ]; then
- echo "metadata_size $metadata_size != 8"
- _show_result $TID 255
-fi
-pi_offset=$(_get_metadata_size "$dev_id" pi_offset)
-if [ "$pi_offset" != 0 ]; then
- echo "pi_offset $pi_offset != 0"
- _show_result $TID 255
-fi
-pi_tuple_size=$(_get_metadata_size "$dev_id" pi_tuple_size)
-if [ "$pi_tuple_size" != 0 ]; then
- echo "pi_tuple_size $pi_tuple_size != 0"
- _show_result $TID 255
-fi
-capable=$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")
-if [ "$capable" != 0 ]; then
- echo "device_is_integrity_capable $capable != 0"
- _show_result $TID 255
-fi
-format=$(cat "/sys/block/ublkb$dev_id/integrity/format")
-if [ "$format" != nop ]; then
- echo "format $format != nop"
- _show_result $TID 255
-fi
-protection_interval_bytes=$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")
-if [ "$protection_interval_bytes" != 512 ]; then
- echo "protection_interval_bytes $protection_interval_bytes != 512"
- _show_result $TID 255
-fi
-tag_size=$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")
-if [ "$tag_size" != 0 ]; then
- echo "tag_size $tag_size != 0"
- _show_result $TID 255
-fi
-_cleanup_test
+ if [ "$actual" != "$expected" ]; then
+ echo "$name $actual != $expected"
+ ERR_CODE=255
+ return 1
+ fi
+ return 0
+}
-dev_id=$(_add_ublk_dev -t null -u --integrity_capable --metadata_size 64 --pi_offset 56 --csum_type ip)
-_check_add_dev $TID $?
-metadata_size=$(_get_metadata_size "$dev_id" metadata_size)
-if [ "$metadata_size" != 64 ]; then
- echo "metadata_size $metadata_size != 64"
- _show_result $TID 255
-fi
-pi_offset=$(_get_metadata_size "$dev_id" pi_offset)
-if [ "$pi_offset" != 56 ]; then
- echo "pi_offset $pi_offset != 56"
- _show_result $TID 255
-fi
-pi_tuple_size=$(_get_metadata_size "$dev_id" pi_tuple_size)
-if [ "$pi_tuple_size" != 8 ]; then
- echo "pi_tuple_size $pi_tuple_size != 8"
- _show_result $TID 255
-fi
-capable=$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")
-if [ "$capable" != 1 ]; then
- echo "device_is_integrity_capable $capable != 1"
- _show_result $TID 255
-fi
-format=$(cat "/sys/block/ublkb$dev_id/integrity/format")
-if [ "$format" != T10-DIF-TYPE3-IP ]; then
- echo "format $format != T10-DIF-TYPE3-IP"
- _show_result $TID 255
-fi
-protection_interval_bytes=$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")
-if [ "$protection_interval_bytes" != 512 ]; then
- echo "protection_interval_bytes $protection_interval_bytes != 512"
- _show_result $TID 255
-fi
-tag_size=$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")
-if [ "$tag_size" != 0 ]; then
- echo "tag_size $tag_size != 0"
- _show_result $TID 255
-fi
-_cleanup_test
+_test_metadata_only() {
+ local dev_id
-dev_id=$(_add_ublk_dev -t null -u --integrity_reftag --metadata_size 8 --csum_type t10dif)
-_check_add_dev $TID $?
-metadata_size=$(_get_metadata_size "$dev_id" metadata_size)
-if [ "$metadata_size" != 8 ]; then
- echo "metadata_size $metadata_size != 8"
- _show_result $TID 255
-fi
-pi_offset=$(_get_metadata_size "$dev_id" pi_offset)
-if [ "$pi_offset" != 0 ]; then
- echo "pi_offset $pi_offset != 0"
- _show_result $TID 255
-fi
-pi_tuple_size=$(_get_metadata_size "$dev_id" pi_tuple_size)
-if [ "$pi_tuple_size" != 8 ]; then
- echo "pi_tuple_size $pi_tuple_size != 8"
- _show_result $TID 255
-fi
-capable=$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")
-if [ "$capable" != 0 ]; then
- echo "device_is_integrity_capable $capable != 0"
- _show_result $TID 255
-fi
-format=$(cat "/sys/block/ublkb$dev_id/integrity/format")
-if [ "$format" != T10-DIF-TYPE1-CRC ]; then
- echo "format $format != T10-DIF-TYPE1-CRC"
- _show_result $TID 255
-fi
-protection_interval_bytes=$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")
-if [ "$protection_interval_bytes" != 512 ]; then
- echo "protection_interval_bytes $protection_interval_bytes != 512"
- _show_result $TID 255
-fi
-tag_size=$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")
-if [ "$tag_size" != 0 ]; then
- echo "tag_size $tag_size != 0"
- _show_result $TID 255
-fi
-_cleanup_test
+ dev_id=$(_add_ublk_dev -t null -u --metadata_size 8)
+ _check_add_dev "$TID" $?
-dev_id=$(_add_ublk_dev -t null -u --metadata_size 16 --csum_type nvme --tag_size 8)
-_check_add_dev $TID $?
-metadata_size=$(_get_metadata_size "$dev_id" metadata_size)
-if [ "$metadata_size" != 16 ]; then
- echo "metadata_size $metadata_size != 16"
- _show_result $TID 255
-fi
-pi_offset=$(_get_metadata_size "$dev_id" pi_offset)
-if [ "$pi_offset" != 0 ]; then
- echo "pi_offset $pi_offset != 0"
- _show_result $TID 255
-fi
-pi_tuple_size=$(_get_metadata_size "$dev_id" pi_tuple_size)
-if [ "$pi_tuple_size" != 16 ]; then
- echo "pi_tuple_size $pi_tuple_size != 16"
- _show_result $TID 255
-fi
-capable=$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")
-if [ "$capable" != 0 ]; then
- echo "device_is_integrity_capable $capable != 0"
- _show_result $TID 255
-fi
-format=$(cat "/sys/block/ublkb$dev_id/integrity/format")
-if [ "$format" != EXT-DIF-TYPE3-CRC64 ]; then
- echo "format $format != EXT-DIF-TYPE3-CRC64"
- _show_result $TID 255
-fi
-protection_interval_bytes=$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")
-if [ "$protection_interval_bytes" != 512 ]; then
- echo "protection_interval_bytes $protection_interval_bytes != 512"
- _show_result $TID 255
-fi
-tag_size=$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")
-if [ "$tag_size" != 8 ]; then
- echo "tag_size $tag_size != 8"
- _show_result $TID 255
-fi
-_cleanup_test
+ _check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 8 &&
+ _check_value "pi_offset" "$(_get_metadata_size "$dev_id" pi_offset)" 0 &&
+ _check_value "pi_tuple_size" "$(_get_metadata_size "$dev_id" pi_tuple_size)" 0 &&
+ _check_value "device_is_integrity_capable" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")" 0 &&
+ _check_value "format" "$(cat "/sys/block/ublkb$dev_id/integrity/format")" nop &&
+ _check_value "protection_interval_bytes" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")" 512 &&
+ _check_value "tag_size" "$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")" 0
+
+ ${UBLK_PROG} del -n "${dev_id}"
+}
+
+_test_integrity_capable_ip() {
+ local dev_id
+
+ dev_id=$(_add_ublk_dev -t null -u --integrity_capable --metadata_size 64 --pi_offset 56 --csum_type ip)
+ _check_add_dev "$TID" $?
+
+ _check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 64 &&
+ _check_value "pi_offset" "$(_get_metadata_size "$dev_id" pi_offset)" 56 &&
+ _check_value "pi_tuple_size" "$(_get_metadata_size "$dev_id" pi_tuple_size)" 8 &&
+ _check_value "device_is_integrity_capable" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")" 1 &&
+ _check_value "format" "$(cat "/sys/block/ublkb$dev_id/integrity/format")" T10-DIF-TYPE3-IP &&
+ _check_value "protection_interval_bytes" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")" 512 &&
+ _check_value "tag_size" "$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")" 0
+
+ ${UBLK_PROG} del -n "${dev_id}"
+}
+
+_test_integrity_reftag_t10dif() {
+ local dev_id
-_show_result $TID 0
+ dev_id=$(_add_ublk_dev -t null -u --integrity_reftag --metadata_size 8 --csum_type t10dif)
+ _check_add_dev "$TID" $?
+
+ _check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 8 &&
+ _check_value "pi_offset" "$(_get_metadata_size "$dev_id" pi_offset)" 0 &&
+ _check_value "pi_tuple_size" "$(_get_metadata_size "$dev_id" pi_tuple_size)" 8 &&
+ _check_value "device_is_integrity_capable" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")" 0 &&
+ _check_value "format" "$(cat "/sys/block/ublkb$dev_id/integrity/format")" T10-DIF-TYPE1-CRC &&
+ _check_value "protection_interval_bytes" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")" 512 &&
+ _check_value "tag_size" "$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")" 0
+
+ ${UBLK_PROG} del -n "${dev_id}"
+}
+
+_test_nvme_csum() {
+ local dev_id
+
+ dev_id=$(_add_ublk_dev -t null -u --metadata_size 16 --csum_type nvme --tag_size 8)
+ _check_add_dev "$TID" $?
+
+ _check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 16 &&
+ _check_value "pi_offset" "$(_get_metadata_size "$dev_id" pi_offset)" 0 &&
+ _check_value "pi_tuple_size" "$(_get_metadata_size "$dev_id" pi_tuple_size)" 16 &&
+ _check_value "device_is_integrity_capable" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/device_is_integrity_capable")" 0 &&
+ _check_value "format" "$(cat "/sys/block/ublkb$dev_id/integrity/format")" EXT-DIF-TYPE3-CRC64 &&
+ _check_value "protection_interval_bytes" \
+ "$(cat "/sys/block/ublkb$dev_id/integrity/protection_interval_bytes")" 512 &&
+ _check_value "tag_size" "$(cat "/sys/block/ublkb$dev_id/integrity/tag_size")" 8
+
+ ${UBLK_PROG} del -n "${dev_id}"
+}
+
+_prep_test "null" "integrity params"
+
+_test_metadata_only
+_test_integrity_capable_ip
+_test_integrity_reftag_t10dif
+_test_nvme_csum
+
+_cleanup_test
+_show_result "$TID" $ERR_CODE
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 7/9] selftests: ublk: disable partition scan for integrity tests
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
` (5 preceding siblings ...)
2026-01-29 16:19 ` [PATCH V2 6/9] selftests: ublk: refactor test_null_04 into separate functions Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 8/9] selftests: ublk: mark each test start and end time in dmesg Ming Lei
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
The null target doesn't handle IO, so disable partition scan to avoid IO
failures caused by integrity verification during the kernel's partition
table read.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tools/testing/selftests/ublk/test_null_04.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/ublk/test_null_04.sh b/tools/testing/selftests/ublk/test_null_04.sh
index 22328e0f3925..a5599d38583a 100755
--- a/tools/testing/selftests/ublk/test_null_04.sh
+++ b/tools/testing/selftests/ublk/test_null_04.sh
@@ -21,7 +21,7 @@ _check_value() {
_test_metadata_only() {
local dev_id
- dev_id=$(_add_ublk_dev -t null -u --metadata_size 8)
+ dev_id=$(_add_ublk_dev -t null -u --no_auto_part_scan --metadata_size 8)
_check_add_dev "$TID" $?
_check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 8 &&
@@ -40,7 +40,7 @@ _test_metadata_only() {
_test_integrity_capable_ip() {
local dev_id
- dev_id=$(_add_ublk_dev -t null -u --integrity_capable --metadata_size 64 --pi_offset 56 --csum_type ip)
+ dev_id=$(_add_ublk_dev -t null -u --no_auto_part_scan --integrity_capable --metadata_size 64 --pi_offset 56 --csum_type ip)
_check_add_dev "$TID" $?
_check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 64 &&
@@ -59,7 +59,7 @@ _test_integrity_capable_ip() {
_test_integrity_reftag_t10dif() {
local dev_id
- dev_id=$(_add_ublk_dev -t null -u --integrity_reftag --metadata_size 8 --csum_type t10dif)
+ dev_id=$(_add_ublk_dev -t null -u --no_auto_part_scan --integrity_reftag --metadata_size 8 --csum_type t10dif)
_check_add_dev "$TID" $?
_check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 8 &&
@@ -78,7 +78,7 @@ _test_integrity_reftag_t10dif() {
_test_nvme_csum() {
local dev_id
- dev_id=$(_add_ublk_dev -t null -u --metadata_size 16 --csum_type nvme --tag_size 8)
+ dev_id=$(_add_ublk_dev -t null -u --no_auto_part_scan --metadata_size 16 --csum_type nvme --tag_size 8)
_check_add_dev "$TID" $?
_check_value "metadata_size" "$(_get_metadata_size "$dev_id" metadata_size)" 16 &&
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 8/9] selftests: ublk: mark each test start and end time in dmesg
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
` (6 preceding siblings ...)
2026-01-29 16:19 ` [PATCH V2 7/9] selftests: ublk: disable partition scan for integrity tests Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-29 16:19 ` [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory Ming Lei
2026-01-31 13:49 ` [PATCH V2 0/9] ublk: misc improvement in driver and selftests Jens Axboe
9 siblings, 0 replies; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov, Ming Lei
From: Alexander Atanasov <alex@zazolabs.com>
Log test start and end time in dmesg, so generated log messages
during the test run can be linked to specific test from the test
suite.
Signed-off-by: Alexander Atanasov <alex@zazolabs.com>
(switch to `date +%F %T`)
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tools/testing/selftests/ublk/test_common.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh
index bbe031c94a29..dd4eff97610a 100755
--- a/tools/testing/selftests/ublk/test_common.sh
+++ b/tools/testing/selftests/ublk/test_common.sh
@@ -126,6 +126,7 @@ _prep_test() {
modprobe ublk_drv > /dev/null 2>&1
UBLK_TMP=$(mktemp ublk_test_XXXXX)
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "ublk $type: $*"
+ echo "ublk selftest: $TID starting at $(date '+%F %T')" | tee /dev/kmsg
}
_remove_test_files()
@@ -170,6 +171,7 @@ _cleanup_test() {
"${UBLK_PROG}" del -a
_remove_files
+ echo "ublk selftest: $TID done at $(date '+%F %T')" | tee /dev/kmsg
}
_have_feature()
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
` (7 preceding siblings ...)
2026-01-29 16:19 ` [PATCH V2 8/9] selftests: ublk: mark each test start and end time in dmesg Ming Lei
@ 2026-01-29 16:19 ` Ming Lei
2026-01-31 2:43 ` Ming Lei
2026-01-31 13:49 ` [PATCH V2 0/9] ublk: misc improvement in driver and selftests Jens Axboe
9 siblings, 1 reply; 13+ messages in thread
From: Ming Lei @ 2026-01-29 16:19 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov
From: Alexander Atanasov <alex@zazolabs.com>
Create and use a temporary directory for the files created during
test runs. If TMPDIR environment variable is set use it as a base
for the temporary directory path.
TMPDIR=/mnt/scratch make run_tests
and
TMPDIR=/mnt/scratch ./test_generic_01.sh
will place test directory under /mnt/scratch
Signed-off-by: Alexander Atanasov <alex@zazolabs.com>
---
tools/testing/selftests/ublk/test_common.sh | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh
index dd4eff97610a..21ba51fcc7d7 100755
--- a/tools/testing/selftests/ublk/test_common.sh
+++ b/tools/testing/selftests/ublk/test_common.sh
@@ -48,7 +48,7 @@ _create_backfile() {
old_file="${UBLK_BACKFILES[$index]}"
[ -f "$old_file" ] && rm -f "$old_file"
- new_file=$(mktemp ublk_file_"${new_size}"_XXXXX)
+ new_file=$(mktemp ${UBLK_TEST_DIR}/ublk_file_"${new_size}"_XXXXX)
truncate -s "${new_size}" "${new_file}"
UBLK_BACKFILES["$index"]="$new_file"
}
@@ -65,7 +65,7 @@ _remove_files() {
_create_tmp_dir() {
local my_file;
- my_file=$(mktemp -d ublk_dir_XXXXX)
+ my_file=$(mktemp -d ${UBLK_TEST_DIR}/ublk_dir_XXXXX)
echo "$my_file"
}
@@ -124,7 +124,9 @@ _prep_test() {
local type=$1
shift 1
modprobe ublk_drv > /dev/null 2>&1
- UBLK_TMP=$(mktemp ublk_test_XXXXX)
+ TDIR=$(mktemp -d ${TMPDIR:-.}/ublktest-dir.XXXXXX)
+ export UBLK_TEST_DIR=${TDIR}
+ UBLK_TMP=$(mktemp ${UBLK_TEST_DIR}/ublk_test_XXXXX)
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "ublk $type: $*"
echo "ublk selftest: $TID starting at $(date '+%F %T')" | tee /dev/kmsg
}
@@ -171,6 +173,7 @@ _cleanup_test() {
"${UBLK_PROG}" del -a
_remove_files
+ rmdir ${UBLK_TEST_DIR}
echo "ublk selftest: $TID done at $(date '+%F %T')" | tee /dev/kmsg
}
@@ -405,6 +408,8 @@ UBLK_PROG=$(_ublk_test_top_dir)/kublk
UBLK_TEST_QUIET=1
UBLK_TEST_SHOW_RESULT=1
UBLK_BACKFILES=()
+UBLK_TEST_DIR=${TMPDIR:-.}
export UBLK_PROG
export UBLK_TEST_QUIET
export UBLK_TEST_SHOW_RESULT
+export UBLK_TEST_DIR
--
2.47.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory
2026-01-29 16:19 ` [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory Ming Lei
@ 2026-01-31 2:43 ` Ming Lei
2026-01-31 10:30 ` Alexander Atanasov
0 siblings, 1 reply; 13+ messages in thread
From: Ming Lei @ 2026-01-31 2:43 UTC (permalink / raw)
To: Jens Axboe, linux-block
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov
Hi Alexander,
On Fri, Jan 30, 2026 at 12:19:58AM +0800, Ming Lei wrote:
> From: Alexander Atanasov <alex@zazolabs.com>
>
> Create and use a temporary directory for the files created during
> test runs. If TMPDIR environment variable is set use it as a base
> for the temporary directory path.
> TMPDIR=/mnt/scratch make run_tests
> and
> TMPDIR=/mnt/scratch ./test_generic_01.sh
> will place test directory under /mnt/scratch
>
> Signed-off-by: Alexander Atanasov <alex@zazolabs.com>
> ---
> tools/testing/selftests/ublk/test_common.sh | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh
> index dd4eff97610a..21ba51fcc7d7 100755
> --- a/tools/testing/selftests/ublk/test_common.sh
> +++ b/tools/testing/selftests/ublk/test_common.sh
> @@ -48,7 +48,7 @@ _create_backfile() {
> old_file="${UBLK_BACKFILES[$index]}"
> [ -f "$old_file" ] && rm -f "$old_file"
>
> - new_file=$(mktemp ublk_file_"${new_size}"_XXXXX)
> + new_file=$(mktemp ${UBLK_TEST_DIR}/ublk_file_"${new_size}"_XXXXX)
> truncate -s "${new_size}" "${new_file}"
> UBLK_BACKFILES["$index"]="$new_file"
> }
> @@ -65,7 +65,7 @@ _remove_files() {
> _create_tmp_dir() {
> local my_file;
>
> - my_file=$(mktemp -d ublk_dir_XXXXX)
> + my_file=$(mktemp -d ${UBLK_TEST_DIR}/ublk_dir_XXXXX)
> echo "$my_file"
> }
>
> @@ -124,7 +124,9 @@ _prep_test() {
> local type=$1
> shift 1
> modprobe ublk_drv > /dev/null 2>&1
> - UBLK_TMP=$(mktemp ublk_test_XXXXX)
> + TDIR=$(mktemp -d ${TMPDIR:-.}/ublktest-dir.XXXXXX)
> + export UBLK_TEST_DIR=${TDIR}
> + UBLK_TMP=$(mktemp ${UBLK_TEST_DIR}/ublk_test_XXXXX)
> [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "ublk $type: $*"
> echo "ublk selftest: $TID starting at $(date '+%F %T')" | tee /dev/kmsg
> }
> @@ -171,6 +173,7 @@ _cleanup_test() {
> "${UBLK_PROG}" del -a
>
> _remove_files
> + rmdir ${UBLK_TEST_DIR}
> echo "ublk selftest: $TID done at $(date '+%F %T')" | tee /dev/kmsg
> }
>
> @@ -405,6 +408,8 @@ UBLK_PROG=$(_ublk_test_top_dir)/kublk
> UBLK_TEST_QUIET=1
> UBLK_TEST_SHOW_RESULT=1
> UBLK_BACKFILES=()
> +UBLK_TEST_DIR=${TMPDIR:-.}
> export UBLK_PROG
> export UBLK_TEST_QUIET
> export UBLK_TEST_SHOW_RESULT
> +export UBLK_TEST_DIR
I feel this patch can be simplified in the following way, what do you think
of the change?
diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh
index 21ba51fcc7d7..1ee7a898e6bf 100755
--- a/tools/testing/selftests/ublk/test_common.sh
+++ b/tools/testing/selftests/ublk/test_common.sh
@@ -48,7 +48,7 @@ _create_backfile() {
old_file="${UBLK_BACKFILES[$index]}"
[ -f "$old_file" ] && rm -f "$old_file"
- new_file=$(mktemp ${UBLK_TEST_DIR}/ublk_file_"${new_size}"_XXXXX)
+ new_file=$(mktemp ${TDIR}/ublk_file_"${new_size}"_XXXXX)
truncate -s "${new_size}" "${new_file}"
UBLK_BACKFILES["$index"]="$new_file"
}
@@ -65,7 +65,7 @@ _remove_files() {
_create_tmp_dir() {
local my_file;
- my_file=$(mktemp -d ${UBLK_TEST_DIR}/ublk_dir_XXXXX)
+ my_file=$(mktemp -d ${TDIR}/ublk_dir_XXXXX)
echo "$my_file"
}
@@ -125,8 +125,7 @@ _prep_test() {
shift 1
modprobe ublk_drv > /dev/null 2>&1
TDIR=$(mktemp -d ${TMPDIR:-.}/ublktest-dir.XXXXXX)
- export UBLK_TEST_DIR=${TDIR}
- UBLK_TMP=$(mktemp ${UBLK_TEST_DIR}/ublk_test_XXXXX)
+ UBLK_TMP=$(mktemp ${TDIR}/ublk_test_XXXXX)
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "ublk $type: $*"
echo "ublk selftest: $TID starting at $(date '+%F %T')" | tee /dev/kmsg
}
@@ -173,7 +172,7 @@ _cleanup_test() {
"${UBLK_PROG}" del -a
_remove_files
- rmdir ${UBLK_TEST_DIR}
+ rmdir ${TDIR}
echo "ublk selftest: $TID done at $(date '+%F %T')" | tee /dev/kmsg
}
@@ -408,8 +407,6 @@ UBLK_PROG=$(_ublk_test_top_dir)/kublk
UBLK_TEST_QUIET=1
UBLK_TEST_SHOW_RESULT=1
UBLK_BACKFILES=()
-UBLK_TEST_DIR=${TMPDIR:-.}
export UBLK_PROG
export UBLK_TEST_QUIET
export UBLK_TEST_SHOW_RESULT
-export UBLK_TEST_DIR
Thanks,
Ming
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory
2026-01-31 2:43 ` Ming Lei
@ 2026-01-31 10:30 ` Alexander Atanasov
0 siblings, 0 replies; 13+ messages in thread
From: Alexander Atanasov @ 2026-01-31 10:30 UTC (permalink / raw)
To: Ming Lei; +Cc: Jens Axboe, linux-block, Caleb Sander Mateos, Uday Shankar
Hi Lei,
> On 31 Jan 2026, at 4:43, Ming Lei <ming.lei@redhat.com> wrote:
>
> Hi Alexander,
>
> On Fri, Jan 30, 2026 at 12:19:58AM +0800, Ming Lei wrote:
>> From: Alexander Atanasov <alex@zazolabs.com>
>>
>> Create and use a temporary directory for the files created during
>> test runs. If TMPDIR environment variable is set use it as a base
>> for the temporary directory path.
>> TMPDIR=/mnt/scratch make run_tests
>> and
>> TMPDIR=/mnt/scratch ./test_generic_01.sh
>> will place test directory under /mnt/scratch
>>
>> Signed-off-by: Alexander Atanasov <alex@zazolabs.com>
>> ---
>> tools/testing/selftests/ublk/test_common.sh | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> [snip]
>> +export UBLK_TEST_DIR
>
> I feel this patch can be simplified in the following way, what do you think
> of the change?
>
> diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh
> index 21ba51fcc7d7..1ee7a898e6bf 100755
> --- a/tools/testing/selftests/ublk/test_common.sh
> +++ b/tools/testing/selftests/ublk/test_common.sh
> @@ -48,7 +48,7 @@ _create_backfile() {
> old_file="${UBLK_BACKFILES[$index]}"
> [ -f "$old_file" ] && rm -f "$old_file"
>
> - new_file=$(mktemp ${UBLK_TEST_DIR}/ublk_file_"${new_size}"_XXXXX)
> + new_file=$(mktemp ${TDIR}/ublk_file_"${new_size}"_XXXXX)
> truncate -s "${new_size}" "${new_file}"
> UBLK_BACKFILES["$index"]="$new_file"
> }
> @@ -65,7 +65,7 @@ _remove_files() {
> _create_tmp_dir() {
> local my_file;
>
> - my_file=$(mktemp -d ${UBLK_TEST_DIR}/ublk_dir_XXXXX)
> + my_file=$(mktemp -d ${TDIR}/ublk_dir_XXXXX)
> echo "$my_file"
> }
>
> @@ -125,8 +125,7 @@ _prep_test() {
> shift 1
> modprobe ublk_drv > /dev/null 2>&1
> TDIR=$(mktemp -d ${TMPDIR:-.}/ublktest-dir.XXXXXX)
> - export UBLK_TEST_DIR=${TDIR}
> - UBLK_TMP=$(mktemp ${UBLK_TEST_DIR}/ublk_test_XXXXX)
> + UBLK_TMP=$(mktemp ${TDIR}/ublk_test_XXXXX)
> [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "ublk $type: $*"
> echo "ublk selftest: $TID starting at $(date '+%F %T')" | tee /dev/kmsg
> }
> @@ -173,7 +172,7 @@ _cleanup_test() {
> "${UBLK_PROG}" del -a
>
> _remove_files
> - rmdir ${UBLK_TEST_DIR}
> + rmdir ${TDIR}
> echo "ublk selftest: $TID done at $(date '+%F %T')" | tee /dev/kmsg
> }
>
> @@ -408,8 +407,6 @@ UBLK_PROG=$(_ublk_test_top_dir)/kublk
> UBLK_TEST_QUIET=1
> UBLK_TEST_SHOW_RESULT=1
> UBLK_BACKFILES=()
> -UBLK_TEST_DIR=${TMPDIR:-.}
> export UBLK_PROG
> export UBLK_TEST_QUIET
> export UBLK_TEST_SHOW_RESULT
> -export UBLK_TEST_DIR
I think removing the exports at the end is good - every
test will have to go through _prep_test().
But keeping the longer name - UBLK_TEST_DIR vs
TDIR is better since it can be used inside the tests.
UBLK_TEST_DIR is more descriptive than TDIR.
have fun,
alex
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH V2 0/9] ublk: misc improvement in driver and selftests
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
` (8 preceding siblings ...)
2026-01-29 16:19 ` [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory Ming Lei
@ 2026-01-31 13:49 ` Jens Axboe
9 siblings, 0 replies; 13+ messages in thread
From: Jens Axboe @ 2026-01-31 13:49 UTC (permalink / raw)
To: linux-block, Ming Lei
Cc: Caleb Sander Mateos, Uday Shankar, Alexander Atanasov
On Fri, 30 Jan 2026 00:19:49 +0800, Ming Lei wrote:
> The 1st patch improves fetch command removal and canceling, which is
> reported as risk from AI.
>
> The 2nd patch adds UBLK_F_NO_AUTO_PART_SCAN for disabling partition
> scanning during adding disk.
>
> The other patches improves ublk selftests:
> - rename test_generic_15 to test_part_02
> - refactor test_null_04 into separate functions and simplifying
> implementations
> - kill IO verify failure in null/integrity tests by not scanning partition
> - mark each test start and end in dmesg log
> - move all temp files/dir into single directory, and allow user to
> override default temp dir
> - derive TID automatically from script name
>
> [...]
Applied, thanks!
[1/9] ublk: check list membership before cancelling batch fetch command
commit: 66d3af8d5d678d221776a1886baec8d78293592c
[2/9] ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag
commit: 8443e2087e7002fa25984faad6bbf5f63b280645
[3/9] selftests: ublk: derive TID automatically from script name
commit: 3a4d8bed0b47543b2dfce0b1d714b40d68ff2f7e
[4/9] selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN
commit: e07a2039b6d4ae3acf8ae39b86be449b7fa18d4a
[5/9] selftests: ublk: rename test_generic_15 to test_part_02
commit: 7a30d3dfea4a455d1109d5258fe332f2157071ba
[6/9] selftests: ublk: refactor test_null_04 into separate functions
commit: 130975353b1548d76aa9790a4ac7e74bd2a37221
[7/9] selftests: ublk: disable partition scan for integrity tests
commit: 76334de7da404c385e18efb3640ed60ca77a899f
[8/9] selftests: ublk: mark each test start and end time in dmesg
commit: 4e0d293af9e37c735aec574c1e69ed71f81f94b2
[9/9] selftests: ublk: move test temp files into a sub directory
commit: 2feca79ef8df5505b87c00812b9ba263b92c64ed
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-01-31 13:49 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-29 16:19 [PATCH V2 0/9] ublk: misc improvement in driver and selftests Ming Lei
2026-01-29 16:19 ` [PATCH V2 1/9] ublk: check list membership before cancelling batch fetch command Ming Lei
2026-01-29 16:19 ` [PATCH V2 2/9] ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag Ming Lei
2026-01-29 16:19 ` [PATCH V2 3/9] selftests: ublk: derive TID automatically from script name Ming Lei
2026-01-29 16:19 ` [PATCH V2 4/9] selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN Ming Lei
2026-01-29 16:19 ` [PATCH V2 5/9] selftests: ublk: rename test_generic_15 to test_part_02 Ming Lei
2026-01-29 16:19 ` [PATCH V2 6/9] selftests: ublk: refactor test_null_04 into separate functions Ming Lei
2026-01-29 16:19 ` [PATCH V2 7/9] selftests: ublk: disable partition scan for integrity tests Ming Lei
2026-01-29 16:19 ` [PATCH V2 8/9] selftests: ublk: mark each test start and end time in dmesg Ming Lei
2026-01-29 16:19 ` [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory Ming Lei
2026-01-31 2:43 ` Ming Lei
2026-01-31 10:30 ` Alexander Atanasov
2026-01-31 13:49 ` [PATCH V2 0/9] ublk: misc improvement in driver and selftests Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox