Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: ublk: add more tests for covering MQ

Add test test_generic_02.sh for covering IO dispatch order in case of MQ.

Especially we just support ->queue_rqs() which may affect IO dispatch
order.

Add test_loop_05.sh and test_stripe_03.sh for covering MQ.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250327095123.179113-11-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ming Lei and committed by
Jens Axboe
8c778614 daabfb50

+132 -33
+3
tools/testing/selftests/ublk/Makefile
··· 4 4 LDLIBS += -lpthread -lm -luring 5 5 6 6 TEST_PROGS := test_generic_01.sh 7 + TEST_PROGS += test_generic_02.sh 7 8 8 9 TEST_PROGS += test_null_01.sh 9 10 TEST_PROGS += test_null_02.sh ··· 12 11 TEST_PROGS += test_loop_02.sh 13 12 TEST_PROGS += test_loop_03.sh 14 13 TEST_PROGS += test_loop_04.sh 14 + TEST_PROGS += test_loop_05.sh 15 15 TEST_PROGS += test_stripe_01.sh 16 16 TEST_PROGS += test_stripe_02.sh 17 + TEST_PROGS += test_stripe_03.sh 17 18 18 19 TEST_PROGS += test_stress_01.sh 19 20 TEST_PROGS += test_stress_02.sh
+6
tools/testing/selftests/ublk/test_common.sh
··· 23 23 echo $(( (major & 0xfff) << 20 | (minor & 0xfffff) )) 24 24 } 25 25 26 + _run_fio_verify_io() { 27 + fio --name=verify --rw=randwrite --direct=1 --ioengine=libaio \ 28 + --bs=8k --iodepth=32 --verify=crc32c --do_verify=1 \ 29 + --verify_state_save=0 "$@" > /dev/null 30 + } 31 + 26 32 _create_backfile() { 27 33 local my_size=$1 28 34 local my_file
+44
tools/testing/selftests/ublk/test_generic_02.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 + 6 + TID="generic_02" 7 + ERR_CODE=0 8 + 9 + if ! _have_program bpftrace; then 10 + exit "$UBLK_SKIP_CODE" 11 + fi 12 + 13 + _prep_test "null" "sequential io order for MQ" 14 + 15 + dev_id=$(_add_ublk_dev -t null -q 2) 16 + _check_add_dev $TID $? 17 + 18 + dev_t=$(_get_disk_dev_t "$dev_id") 19 + bpftrace trace/seq_io.bt "$dev_t" "W" 1 > "$UBLK_TMP" 2>&1 & 20 + btrace_pid=$! 21 + sleep 2 22 + 23 + if ! kill -0 "$btrace_pid" > /dev/null 2>&1; then 24 + _cleanup_test "null" 25 + exit "$UBLK_SKIP_CODE" 26 + fi 27 + 28 + # run fio over this ublk disk 29 + fio --name=write_seq \ 30 + --filename=/dev/ublkb"${dev_id}" \ 31 + --ioengine=libaio --iodepth=16 \ 32 + --rw=write \ 33 + --size=512M \ 34 + --direct=1 \ 35 + --bs=4k > /dev/null 2>&1 36 + ERR_CODE=$? 37 + kill "$btrace_pid" 38 + wait 39 + if grep -q "io_out_of_order" "$UBLK_TMP"; then 40 + cat "$UBLK_TMP" 41 + ERR_CODE=255 42 + fi 43 + _cleanup_test "null" 44 + _show_result $TID $ERR_CODE
+5 -9
tools/testing/selftests/ublk/test_loop_01.sh
··· 6 6 TID="loop_01" 7 7 ERR_CODE=0 8 8 9 + if ! _have_program fio; then 10 + exit "$UBLK_SKIP_CODE" 11 + fi 12 + 9 13 _prep_test "loop" "write and verify test" 10 14 11 15 backfile_0=$(_create_backfile 256M) ··· 18 14 _check_add_dev $TID $? "${backfile_0}" 19 15 20 16 # run fio over the ublk disk 21 - fio --name=write_and_verify \ 22 - --filename=/dev/ublkb"${dev_id}" \ 23 - --ioengine=libaio --iodepth=16 \ 24 - --rw=write \ 25 - --size=256M \ 26 - --direct=1 \ 27 - --verify=crc32c \ 28 - --do_verify=1 \ 29 - --bs=4k > /dev/null 2>&1 17 + _run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M 30 18 ERR_CODE=$? 31 19 32 20 _cleanup_test "loop"
+5 -9
tools/testing/selftests/ublk/test_loop_03.sh
··· 6 6 TID="loop_03" 7 7 ERR_CODE=0 8 8 9 + if ! _have_program fio; then 10 + exit "$UBLK_SKIP_CODE" 11 + fi 12 + 9 13 _prep_test "loop" "write and verify over zero copy" 10 14 11 15 backfile_0=$(_create_backfile 256M) ··· 17 13 _check_add_dev $TID $? "$backfile_0" 18 14 19 15 # run fio over the ublk disk 20 - fio --name=write_and_verify \ 21 - --filename=/dev/ublkb"${dev_id}" \ 22 - --ioengine=libaio --iodepth=64 \ 23 - --rw=write \ 24 - --size=256M \ 25 - --direct=1 \ 26 - --verify=crc32c \ 27 - --do_verify=1 \ 28 - --bs=4k > /dev/null 2>&1 16 + _run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M 29 17 ERR_CODE=$? 30 18 31 19 _cleanup_test "loop"
+28
tools/testing/selftests/ublk/test_loop_05.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 + 6 + TID="loop_05" 7 + ERR_CODE=0 8 + 9 + if ! _have_program fio; then 10 + exit "$UBLK_SKIP_CODE" 11 + fi 12 + 13 + _prep_test "loop" "write and verify test" 14 + 15 + backfile_0=$(_create_backfile 256M) 16 + 17 + dev_id=$(_add_ublk_dev -q 2 -t loop "$backfile_0") 18 + _check_add_dev $TID $? "${backfile_0}" 19 + 20 + # run fio over the ublk disk 21 + _run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M 22 + ERR_CODE=$? 23 + 24 + _cleanup_test "loop" 25 + 26 + _remove_backfile "$backfile_0" 27 + 28 + _show_result $TID $ERR_CODE
+3 -3
tools/testing/selftests/ublk/test_stress_01.sh
··· 27 27 28 28 _prep_test "stress" "run IO and remove device" 29 29 30 - ublk_io_and_remove 8G -t null 30 + ublk_io_and_remove 8G -t null -q 4 31 31 ERR_CODE=$? 32 32 if [ ${ERR_CODE} -ne 0 ]; then 33 33 _show_result $TID $ERR_CODE 34 34 fi 35 35 36 36 BACK_FILE=$(_create_backfile 256M) 37 - ublk_io_and_remove 256M -t loop "${BACK_FILE}" 37 + ublk_io_and_remove 256M -t loop -q 4 "${BACK_FILE}" 38 38 ERR_CODE=$? 39 39 if [ ${ERR_CODE} -ne 0 ]; then 40 40 _show_result $TID $ERR_CODE 41 41 fi 42 42 43 - ublk_io_and_remove 256M -t loop -z "${BACK_FILE}" 43 + ublk_io_and_remove 256M -t loop -q 4 -z "${BACK_FILE}" 44 44 ERR_CODE=$? 45 45 _cleanup_test "stress" 46 46 _remove_backfile "${BACK_FILE}"
+3 -3
tools/testing/selftests/ublk/test_stress_02.sh
··· 27 27 28 28 _prep_test "stress" "run IO and kill ublk server" 29 29 30 - ublk_io_and_kill_daemon 8G -t null 30 + ublk_io_and_kill_daemon 8G -t null -q 4 31 31 ERR_CODE=$? 32 32 if [ ${ERR_CODE} -ne 0 ]; then 33 33 _show_result $TID $ERR_CODE 34 34 fi 35 35 36 36 BACK_FILE=$(_create_backfile 256M) 37 - ublk_io_and_kill_daemon 256M -t loop "${BACK_FILE}" 37 + ublk_io_and_kill_daemon 256M -t loop -q 4 "${BACK_FILE}" 38 38 ERR_CODE=$? 39 39 if [ ${ERR_CODE} -ne 0 ]; then 40 40 _show_result $TID $ERR_CODE 41 41 fi 42 42 43 - ublk_io_and_kill_daemon 256M -t loop -z "${BACK_FILE}" 43 + ublk_io_and_kill_daemon 256M -t loop -q 4 -z "${BACK_FILE}" 44 44 ERR_CODE=$? 45 45 _cleanup_test "stress" 46 46 _remove_backfile "${BACK_FILE}"
+5 -9
tools/testing/selftests/ublk/test_stripe_01.sh
··· 6 6 TID="stripe_01" 7 7 ERR_CODE=0 8 8 9 + if ! _have_program fio; then 10 + exit "$UBLK_SKIP_CODE" 11 + fi 12 + 9 13 _prep_test "stripe" "write and verify test" 10 14 11 15 backfile_0=$(_create_backfile 256M) ··· 19 15 _check_add_dev $TID $? "${backfile_0}" 20 16 21 17 # run fio over the ublk disk 22 - fio --name=write_and_verify \ 23 - --filename=/dev/ublkb"${dev_id}" \ 24 - --ioengine=libaio --iodepth=32 \ 25 - --rw=write \ 26 - --size=512M \ 27 - --direct=1 \ 28 - --verify=crc32c \ 29 - --do_verify=1 \ 30 - --bs=4k > /dev/null 2>&1 18 + _run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=512M 31 19 ERR_CODE=$? 32 20 33 21 _cleanup_test "stripe"
+30
tools/testing/selftests/ublk/test_stripe_03.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 + 6 + TID="stripe_03" 7 + ERR_CODE=0 8 + 9 + if ! _have_program fio; then 10 + exit "$UBLK_SKIP_CODE" 11 + fi 12 + 13 + _prep_test "stripe" "write and verify test" 14 + 15 + backfile_0=$(_create_backfile 256M) 16 + backfile_1=$(_create_backfile 256M) 17 + 18 + dev_id=$(_add_ublk_dev -q 2 -t stripe "$backfile_0" "$backfile_1") 19 + _check_add_dev $TID $? "${backfile_0}" 20 + 21 + # run fio over the ublk disk 22 + _run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=512M 23 + ERR_CODE=$? 24 + 25 + _cleanup_test "stripe" 26 + 27 + _remove_backfile "$backfile_0" 28 + _remove_backfile "$backfile_1" 29 + 30 + _show_result $TID $ERR_CODE