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

selftests: ublk: run stress tests in parallel

Run stress tests in parallel, meantime add shell local function to
simplify the two stress tests.

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

authored by

Ming Lei and committed by
Jens Axboe
bb2cabf2 573840ab

+63 -49
+33 -1
tools/testing/selftests/ublk/test_common.sh
··· 230 230 local kill_server=$3 231 231 232 232 fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio \ 233 - --rw=readwrite --iodepth=64 --size="${size}" --numjobs=4 \ 233 + --rw=readwrite --iodepth=256 --size="${size}" --numjobs=4 \ 234 234 --runtime=20 --time_based > /dev/null 2>&1 & 235 235 sleep 2 236 236 if [ "${kill_server}" = "yes" ]; then ··· 246 246 return 255 247 247 fi 248 248 wait 249 + } 250 + 251 + run_io_and_remove() 252 + { 253 + local size=$1 254 + local dev_id 255 + shift 1 256 + 257 + dev_id=$(_add_ublk_dev "$@") 258 + _check_add_dev "$TID" $? 259 + 260 + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)" 261 + if ! __run_io_and_remove "$dev_id" "${size}" "no"; then 262 + echo "/dev/ublkc$dev_id isn't removed" 263 + exit 255 264 + fi 265 + } 266 + 267 + run_io_and_kill_daemon() 268 + { 269 + local size=$1 270 + local dev_id 271 + shift 1 272 + 273 + dev_id=$(_add_ublk_dev "$@") 274 + _check_add_dev "$TID" $? 275 + 276 + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs kill ublk server(ublk add $*)" 277 + if ! __run_io_and_remove "$dev_id" "${size}" "yes"; then 278 + echo "/dev/ublkc$dev_id isn't removed res ${res}" 279 + exit 255 280 + fi 249 281 } 250 282 251 283 _ublk_test_top_dir()
+15 -24
tools/testing/selftests/ublk/test_stress_01.sh
··· 7 7 8 8 ublk_io_and_remove() 9 9 { 10 - local size=$1 11 - local dev_id 12 - shift 1 13 - 14 - dev_id=$(_add_ublk_dev "$@") 15 - _check_add_dev $TID $? 16 - 17 - [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)" 18 - if ! __run_io_and_remove "$dev_id" "${size}" "no"; then 19 - echo "/dev/ublkc$dev_id isn't removed" 20 - exit 255 10 + run_io_and_remove "$@" 11 + ERR_CODE=$? 12 + if [ ${ERR_CODE} -ne 0 ]; then 13 + echo "$TID failure: $*" 14 + _show_result $TID $ERR_CODE 21 15 fi 22 16 } 23 17 18 + if ! _have_program fio; then 19 + exit "$UBLK_SKIP_CODE" 20 + fi 21 + 24 22 _prep_test "stress" "run IO and remove device" 25 23 26 - ublk_io_and_remove 8G -t null -q 4 27 - ERR_CODE=$? 28 - if [ ${ERR_CODE} -ne 0 ]; then 29 - _show_result $TID $ERR_CODE 30 - fi 31 - 32 24 _create_backfile 0 256M 25 + _create_backfile 1 128M 26 + _create_backfile 2 128M 33 27 34 - ublk_io_and_remove 256M -t loop -q 4 "${UBLK_BACKFILES[0]}" 35 - ERR_CODE=$? 36 - if [ ${ERR_CODE} -ne 0 ]; then 37 - _show_result $TID $ERR_CODE 38 - fi 28 + ublk_io_and_remove 8G -t null -q 4 & 29 + ublk_io_and_remove 256M -t loop -q 4 "${UBLK_BACKFILES[0]}" & 30 + ublk_io_and_remove 256M -t stripe -q 4 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & 31 + wait 39 32 40 - ublk_io_and_remove 256M -t loop -q 4 -z "${UBLK_BACKFILES[0]}" 41 - ERR_CODE=$? 42 33 _cleanup_test "stress" 43 34 _show_result $TID $ERR_CODE
+15 -24
tools/testing/selftests/ublk/test_stress_02.sh
··· 5 5 TID="stress_02" 6 6 ERR_CODE=0 7 7 8 + if ! _have_program fio; then 9 + exit "$UBLK_SKIP_CODE" 10 + fi 11 + 8 12 ublk_io_and_kill_daemon() 9 13 { 10 - local size=$1 11 - local dev_id 12 - shift 1 13 - 14 - dev_id=$(_add_ublk_dev "$@") 15 - _check_add_dev $TID $? 16 - 17 - [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs kill ublk server(ublk add $*)" 18 - if ! __run_io_and_remove "$dev_id" "${size}" "yes"; then 19 - echo "/dev/ublkc$dev_id isn't removed res ${res}" 20 - exit 255 14 + run_io_and_kill_daemon "$@" 15 + ERR_CODE=$? 16 + if [ ${ERR_CODE} -ne 0 ]; then 17 + echo "$TID failure: $*" 18 + _show_result $TID $ERR_CODE 21 19 fi 22 20 } 23 21 24 22 _prep_test "stress" "run IO and kill ublk server" 25 23 26 - ublk_io_and_kill_daemon 8G -t null -q 4 27 - ERR_CODE=$? 28 - if [ ${ERR_CODE} -ne 0 ]; then 29 - _show_result $TID $ERR_CODE 30 - fi 31 - 32 24 _create_backfile 0 256M 25 + _create_backfile 1 128M 26 + _create_backfile 2 128M 33 27 34 - ublk_io_and_kill_daemon 256M -t loop -q 4 "${UBLK_BACKFILES[0]}" 35 - ERR_CODE=$? 36 - if [ ${ERR_CODE} -ne 0 ]; then 37 - _show_result $TID $ERR_CODE 38 - fi 28 + ublk_io_and_kill_daemon 8G -t null -q 4 & 29 + ublk_io_and_kill_daemon 256M -t loop -q 4 "${UBLK_BACKFILES[0]}" & 30 + ublk_io_and_kill_daemon 256M -t stripe -q 4 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & 31 + wait 39 32 40 - ublk_io_and_kill_daemon 256M -t loop -q 4 -z "${UBLK_BACKFILES[0]}" 41 - ERR_CODE=$? 42 33 _cleanup_test "stress" 43 34 _show_result $TID $ERR_CODE