Skip to content

Commit 8c77861

Browse files
Ming Leiaxboe
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent daabfb5 commit 8c77861

File tree

10 files changed

+132
-33
lines changed

10 files changed

+132
-33
lines changed

tools/testing/selftests/ublk/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)
44
LDLIBS += -lpthread -lm -luring
55

66
TEST_PROGS := test_generic_01.sh
7+
TEST_PROGS += test_generic_02.sh
78

89
TEST_PROGS += test_null_01.sh
910
TEST_PROGS += test_null_02.sh
1011
TEST_PROGS += test_loop_01.sh
1112
TEST_PROGS += test_loop_02.sh
1213
TEST_PROGS += test_loop_03.sh
1314
TEST_PROGS += test_loop_04.sh
15+
TEST_PROGS += test_loop_05.sh
1416
TEST_PROGS += test_stripe_01.sh
1517
TEST_PROGS += test_stripe_02.sh
18+
TEST_PROGS += test_stripe_03.sh
1619

1720
TEST_PROGS += test_stress_01.sh
1821
TEST_PROGS += test_stress_02.sh

tools/testing/selftests/ublk/test_common.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ _get_disk_dev_t() {
2323
echo $(( (major & 0xfff) << 20 | (minor & 0xfffff) ))
2424
}
2525

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+
2632
_create_backfile() {
2733
local my_size=$1
2834
local my_file
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

tools/testing/selftests/ublk/test_loop_01.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
TID="loop_01"
77
ERR_CODE=0
88

9+
if ! _have_program fio; then
10+
exit "$UBLK_SKIP_CODE"
11+
fi
12+
913
_prep_test "loop" "write and verify test"
1014

1115
backfile_0=$(_create_backfile 256M)
@@ -14,15 +18,7 @@ dev_id=$(_add_ublk_dev -t loop "$backfile_0")
1418
_check_add_dev $TID $? "${backfile_0}"
1519

1620
# run fio over the ublk disk
17-
fio --name=write_and_verify \
18-
--filename=/dev/ublkb"${dev_id}" \
19-
--ioengine=libaio --iodepth=16 \
20-
--rw=write \
21-
--size=256M \
22-
--direct=1 \
23-
--verify=crc32c \
24-
--do_verify=1 \
25-
--bs=4k > /dev/null 2>&1
21+
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M
2622
ERR_CODE=$?
2723

2824
_cleanup_test "loop"

tools/testing/selftests/ublk/test_loop_03.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@
66
TID="loop_03"
77
ERR_CODE=0
88

9+
if ! _have_program fio; then
10+
exit "$UBLK_SKIP_CODE"
11+
fi
12+
913
_prep_test "loop" "write and verify over zero copy"
1014

1115
backfile_0=$(_create_backfile 256M)
1216
dev_id=$(_add_ublk_dev -t loop -z "$backfile_0")
1317
_check_add_dev $TID $? "$backfile_0"
1418

1519
# run fio over the ublk disk
16-
fio --name=write_and_verify \
17-
--filename=/dev/ublkb"${dev_id}" \
18-
--ioengine=libaio --iodepth=64 \
19-
--rw=write \
20-
--size=256M \
21-
--direct=1 \
22-
--verify=crc32c \
23-
--do_verify=1 \
24-
--bs=4k > /dev/null 2>&1
20+
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M
2521
ERR_CODE=$?
2622

2723
_cleanup_test "loop"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

tools/testing/selftests/ublk/test_stress_01.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ ublk_io_and_remove()
2727

2828
_prep_test "stress" "run IO and remove device"
2929

30-
ublk_io_and_remove 8G -t null
30+
ublk_io_and_remove 8G -t null -q 4
3131
ERR_CODE=$?
3232
if [ ${ERR_CODE} -ne 0 ]; then
3333
_show_result $TID $ERR_CODE
3434
fi
3535

3636
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}"
3838
ERR_CODE=$?
3939
if [ ${ERR_CODE} -ne 0 ]; then
4040
_show_result $TID $ERR_CODE
4141
fi
4242

43-
ublk_io_and_remove 256M -t loop -z "${BACK_FILE}"
43+
ublk_io_and_remove 256M -t loop -q 4 -z "${BACK_FILE}"
4444
ERR_CODE=$?
4545
_cleanup_test "stress"
4646
_remove_backfile "${BACK_FILE}"

tools/testing/selftests/ublk/test_stress_02.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ ublk_io_and_kill_daemon()
2727

2828
_prep_test "stress" "run IO and kill ublk server"
2929

30-
ublk_io_and_kill_daemon 8G -t null
30+
ublk_io_and_kill_daemon 8G -t null -q 4
3131
ERR_CODE=$?
3232
if [ ${ERR_CODE} -ne 0 ]; then
3333
_show_result $TID $ERR_CODE
3434
fi
3535

3636
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}"
3838
ERR_CODE=$?
3939
if [ ${ERR_CODE} -ne 0 ]; then
4040
_show_result $TID $ERR_CODE
4141
fi
4242

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}"
4444
ERR_CODE=$?
4545
_cleanup_test "stress"
4646
_remove_backfile "${BACK_FILE}"

tools/testing/selftests/ublk/test_stripe_01.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
TID="stripe_01"
77
ERR_CODE=0
88

9+
if ! _have_program fio; then
10+
exit "$UBLK_SKIP_CODE"
11+
fi
12+
913
_prep_test "stripe" "write and verify test"
1014

1115
backfile_0=$(_create_backfile 256M)
@@ -15,15 +19,7 @@ dev_id=$(_add_ublk_dev -t stripe "$backfile_0" "$backfile_1")
1519
_check_add_dev $TID $? "${backfile_0}"
1620

1721
# run fio over the ublk disk
18-
fio --name=write_and_verify \
19-
--filename=/dev/ublkb"${dev_id}" \
20-
--ioengine=libaio --iodepth=32 \
21-
--rw=write \
22-
--size=512M \
23-
--direct=1 \
24-
--verify=crc32c \
25-
--do_verify=1 \
26-
--bs=4k > /dev/null 2>&1
22+
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=512M
2723
ERR_CODE=$?
2824

2925
_cleanup_test "stripe"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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

0 commit comments

Comments
 (0)