ublk: misc improvement in driver and selftests
Subsystems (3)
v2 cover ublk: misc improvement in driver and selftests
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%)Signature · 1 line
2.47.0
PATCH v2 1/9 ublk: check list membership before cancelling batch fetch command
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.
--- drivers/block/ublk_drv.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/block/ublk_drv.c +13 -3
@@ -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) {
Signature · 1 line
2.47.0
PATCH v2 2/9 ublk: add UBLK_F_NO_AUTO_PART_SCAN feature flag
In reply to Ming LeiAdd 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).
--- drivers/block/ublk_drv.c | 14 ++++++++++---- include/uapi/linux/ublk_cmd.h | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/block/ublk_drv.c +10 -4
@@ -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) {
include/uapi/linux/ublk_cmd.h +3 -0
@@ -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
Signature · 1 line
2.47.0
PATCH v2 3/9 selftests: ublk: derive TID automatically from script name
In reply to Ming LeiAdd 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.
--- 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(-)
tools/testing/selftests/ublk/test_batch_01.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="batch_01" ERR_CODE=0 if ! _have_feature "BATCH_IO"; then
tools/testing/selftests/ublk/test_batch_02.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="batch_02" ERR_CODE=0 if ! _have_feature "BATCH_IO"; then
tools/testing/selftests/ublk/test_batch_03.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="batch_03" ERR_CODE=0 if ! _have_feature "BATCH_IO"; then
tools/testing/selftests/ublk/test_common.sh +5 -0
@@ -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() {
tools/testing/selftests/ublk/test_generic_01.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_01" ERR_CODE=0 if ! _have_program bpftrace; then
tools/testing/selftests/ublk/test_generic_02.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_02" ERR_CODE=0 if ! _have_program bpftrace; then
tools/testing/selftests/ublk/test_generic_03.sh +0 -1
@@ -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"
tools/testing/selftests/ublk/test_generic_04.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_04" ERR_CODE=0 ublk_run_recover_test()
tools/testing/selftests/ublk/test_generic_05.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_05" ERR_CODE=0 ublk_run_recover_test()
tools/testing/selftests/ublk/test_generic_06.sh +0 -1
@@ -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"
tools/testing/selftests/ublk/test_generic_07.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_07" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_generic_08.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_08" ERR_CODE=0 if ! _have_feature "AUTO_BUF_REG"; then
tools/testing/selftests/ublk/test_generic_09.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_09" ERR_CODE=0 if ! _have_feature "AUTO_BUF_REG"; then
tools/testing/selftests/ublk/test_generic_10.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_10" ERR_CODE=0 if ! _have_feature "UPDATE_SIZE"; then
tools/testing/selftests/ublk/test_generic_11.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_11" ERR_CODE=0 ublk_run_quiesce_recover()
tools/testing/selftests/ublk/test_generic_12.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_12" ERR_CODE=0 if ! _have_program bpftrace; then
tools/testing/selftests/ublk/test_generic_13.sh +0 -1
@@ -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"
tools/testing/selftests/ublk/test_generic_14.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_14" ERR_CODE=0 ublk_run_recover_test()
tools/testing/selftests/ublk/test_generic_15.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_15" ERR_CODE=0 _test_partition_scan_no_hang()
tools/testing/selftests/ublk/test_generic_16.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="generic_16" ERR_CODE=0 _prep_test "null" "stop --safe command"
tools/testing/selftests/ublk/test_loop_01.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="loop_01" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_loop_02.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="loop_02" ERR_CODE=0 _prep_test "loop" "mkfs & mount & umount"
tools/testing/selftests/ublk/test_loop_03.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="loop_03" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_loop_04.sh +0 -1
@@ -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"
tools/testing/selftests/ublk/test_loop_05.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="loop_05" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_loop_06.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="loop_06" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_loop_07.sh +0 -1
@@ -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"
tools/testing/selftests/ublk/test_loop_08.sh +0 -1
@@ -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"
tools/testing/selftests/ublk/test_null_01.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="null_01" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_null_02.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="null_02" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_null_03.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="null_03" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_null_04.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID=null_04 _prep_test "null" "integrity params"
tools/testing/selftests/ublk/test_stress_01.sh +0 -1
@@ -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()
tools/testing/selftests/ublk/test_stress_02.sh +0 -1
@@ -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
tools/testing/selftests/ublk/test_stress_03.sh +0 -1
@@ -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()
tools/testing/selftests/ublk/test_stress_04.sh +0 -1
@@ -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()
tools/testing/selftests/ublk/test_stress_05.sh +0 -1
@@ -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
tools/testing/selftests/ublk/test_stress_06.sh +0 -1
@@ -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()
tools/testing/selftests/ublk/test_stress_07.sh +0 -1
@@ -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()
tools/testing/selftests/ublk/test_stress_08.sh +0 -1
@@ -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()
tools/testing/selftests/ublk/test_stress_09.sh +0 -1
@@ -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()
tools/testing/selftests/ublk/test_stripe_01.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="stripe_01" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_stripe_02.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="stripe_02" ERR_CODE=0 _prep_test "stripe" "mkfs & mount & umount"
tools/testing/selftests/ublk/test_stripe_03.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="stripe_03" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_stripe_04.sh +0 -1
@@ -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"
tools/testing/selftests/ublk/test_stripe_05.sh +0 -1
@@ -3,7 +3,6 @@ . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh -TID="stripe_05" ERR_CODE=0 if ! _have_program fio; then
tools/testing/selftests/ublk/test_stripe_06.sh +0 -1
@@ -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"
Signature · 1 line
2.47.0
PATCH v2 4/9 selftests: ublk: add selftest for UBLK_F_NO_AUTO_PART_SCAN
In reply to Ming LeiAdd 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.
--- 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
tools/testing/selftests/ublk/Makefile +2 -0
@@ -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
tools/testing/selftests/ublk/kublk.c +5 -1
@@ -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 '?' :/*
tools/testing/selftests/ublk/kublk.h +2 -1
@@ -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;
tools/testing/selftests/ublk/test_part_01.sh new file +104 -0
104 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH v2 5/9 selftests: ublk: rename test_generic_15 to test_part_02
In reply to Ming LeiThis test exercises partition scanning behavior, so move it to the test_part_* group for consistency.
---
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%)tools/testing/selftests/ublk/Makefile +1 -1
@@ -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
tools/testing/selftests/ublk/test_part_02.sh renamed from tools/testing/selftests/ublk/test_generic_15.sh +0 -0
Signature · 1 line
2.47.0
PATCH v2 6/9 selftests: ublk: refactor test_null_04 into separate functions
In reply to Ming LeiEncapsulate 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.
--- tools/testing/selftests/ublk/test_null_04.sh | 248 +++++++------------ 1 file changed, 94 insertions(+), 154 deletions(-)
tools/testing/selftests/ublk/test_null_04.sh +94 -154
@@ -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
Signature · 1 line
2.47.0
PATCH v2 7/9 selftests: ublk: disable partition scan for integrity tests
In reply to Ming LeiThe 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.
--- tools/testing/selftests/ublk/test_null_04.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/ublk/test_null_04.sh +4 -4
@@ -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 &&
Signature · 1 line
2.47.0
PATCH v2 8/9 selftests: ublk: mark each test start and end time in dmesg
In reply to Ming LeiFrom: Alexander Atanasov <[email protected]>
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.
(switch to date +%F %T)
--- tools/testing/selftests/ublk/test_common.sh | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/ublk/test_common.sh +2 -0
@@ -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()
Signature · 1 line
2.47.0
PATCH v2 9/9 selftests: ublk: move test temp files into a sub directory
In reply to Ming LeiFrom: Alexander Atanasov <[email protected]>
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
--- tools/testing/selftests/ublk/test_common.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/testing/selftests/ublk/test_common.sh +8 -3
@@ -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
Signature · 1 line
2.47.0
Re: [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory
Hi Alexander,
Quoted 57 lines · Ming Lei
From: Alexander Atanasov <[email protected]>
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 makerun_tests
and
TMPDIR=/mnt/scratch ./test_generic_01.sh
will place test directory under/mnt/scratchSigned-off-by Alexander Atanasov <[email protected]>--- tools/testing/selftests/ublk/test_common.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tools/testing/selftests/ublk/test_common.sh +6
-3@@ -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 }
tools/testing/selftests/ublk/test_common.sh UBLK_PROG=$(_ublk_test_top_dir)/kublk · line 415
Quoted 8 lines
tools/testing/selftests/ublk/test_common.sh +2
-0@@ -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?
tools/testing/selftests/ublk/test_common.sh +4 -7
@@ -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
Re: [PATCH V2 9/9] selftests: ublk: move test temp files into a sub directory
Hi Lei,
Quoted 70 lines · Ming Lei
Hi Alexander,
Quoted 11 lines · Ming Lei
From: Alexander Atanasov <[email protected]>
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 makerun_tests
and
TMPDIR=/mnt/scratch ./test_generic_01.sh
will place test directory under/mnt/scratchSigned-off-by Alexander Atanasov <[email protected]>Quoted 8 lines
---
tools/testing/selftests/ublk/test_common.sh| 11 ++++++++---1 file changed, 8 insertions(+), 3 deletions(-)[snip]
+export
UBLK_TEST_DIRI feel this patch can be simplified in the following way, what do you think of the change?
tools/testing/selftests/ublk/test_common.sh +4
-5@@ -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
Quoted 8 lines
UBLK_TEST_QUIET=1
UBLK_TEST_SHOW_RESULT=1
UBLK_BACKFILES=()
-UBLK_TEST_DIR=${TMPDIR:-.}
exportUBLK_PROG
exportUBLK_TEST_QUIET
exportUBLK_TEST_SHOW_RESULT
-exportUBLK_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
Quoted 16 lines · 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_SCANfor disabling partition scanning during adding disk.The other patches improves ublk selftests:
- renametest_generic_15totest_part_02
- refactortest_null_04into 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
Quoted 1 line
[...]
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: 2feca79ef8df5505b87c00812b9ba263b92c64edBest regards,
Signature · 1 line
Jens Axboe