Skip to content

Commit 2f9a30b

Browse files
Ming Leiaxboe
authored andcommitted
selftests: ublk: add test_stress_05.sh
Add test_stress_05.sh for covering removing device with recovery enabled. io-hang has been observed with the following patch: https://lore.kernel.org/linux-block/20250403-ublk_timeout-v3-1-aa09f76c7451@purestorage.com/ Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20250412023035.2649275-13-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 57e13a2 commit 2f9a30b

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

tools/testing/selftests/ublk/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ TEST_PROGS += test_stress_01.sh
2525
TEST_PROGS += test_stress_02.sh
2626
TEST_PROGS += test_stress_03.sh
2727
TEST_PROGS += test_stress_04.sh
28+
TEST_PROGS += test_stress_05.sh
2829

2930
TEST_GEN_PROGS_EXTENDED = kublk
3031

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
TID="stress_05"
6+
ERR_CODE=0
7+
8+
run_io_and_remove()
9+
{
10+
local size=$1
11+
local dev_id
12+
local dev_pid
13+
shift 1
14+
15+
dev_id=$(_add_ublk_dev "$@")
16+
_check_add_dev $TID $?
17+
18+
[ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)"
19+
20+
fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio \
21+
--rw=readwrite --iodepth=128 --size="${size}" --numjobs=4 \
22+
--runtime=40 --time_based > /dev/null 2>&1 &
23+
sleep 4
24+
25+
dev_pid=$(_get_ublk_daemon_pid "$dev_id")
26+
kill -9 "$dev_pid"
27+
28+
if ! __remove_ublk_dev_return "${dev_id}"; then
29+
echo "delete dev ${dev_id} failed"
30+
return 255
31+
fi
32+
}
33+
34+
ublk_io_and_remove()
35+
{
36+
run_io_and_remove "$@"
37+
ERR_CODE=$?
38+
if [ ${ERR_CODE} -ne 0 ]; then
39+
echo "$TID failure: $*"
40+
_show_result $TID $ERR_CODE
41+
fi
42+
}
43+
44+
_prep_test "stress" "run IO and remove device with recovery enabled"
45+
46+
_create_backfile 0 256M
47+
_create_backfile 1 256M
48+
49+
for reissue in $(seq 0 1); do
50+
ublk_io_and_remove 8G -t null -q 4 -g 1 -r 1 -i "$reissue" &
51+
ublk_io_and_remove 256M -t loop -q 4 -g 1 -r 1 -i "$reissue" "${UBLK_BACKFILES[0]}" &
52+
wait
53+
done
54+
55+
if _have_feature "ZERO_COPY"; then
56+
for reissue in $(seq 0 1); do
57+
ublk_io_and_remove 8G -t null -q 4 -g 1 -z -r 1 -i "$reissue" &
58+
ublk_io_and_remove 256M -t loop -q 4 -g 1 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" &
59+
wait
60+
done
61+
fi
62+
63+
_cleanup_test "stress"
64+
_show_result $TID $ERR_CODE

0 commit comments

Comments
 (0)