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