#!/bin/bash # SPDX-License-Identifier: MIT or GPL-2.0-only . common/fio_common . common/loop_common . common/qcow2_common . common/nbd_common echo -e "\trun fio with dev recovery, type 1:" echo -e "\t(1)kill all ubq_deamon, (2)recover with new ubq_daemon, (3)delete dev" BS=4k RW=rw JOBS=4 QUEUES=2 RT=$TRUNTIME*2 LOOPS=1 URING_COMP=1 NEED_GET_DATA=1 RECOVERY=1 RECOVERY_REISSUE=0 ublk_run_recover_test() { local type=$1 local file=`_create_image $type "null" 256M` if [ "$type" == "null" ]; then local backing="" elif [ "$type" == "nbd" ]; then local backing="--host 127.0.0.1" else local backing="-f $file" fi if [ "$type" == "qcow2" ]; then QUEUES=1 else QUEUES=2 fi for CNT in `seq $LOOPS`; do export T_TYPE_PARAMS="-t $type -q $QUEUES -u $URING_COMP -g $NEED_GET_DATA -r $RECOVERY -i $RECOVERY_REISSUE $backing" DEV=`__create_ublk_dev` echo -e "\trun fio with killing $DEV(ublk add $T_TYPE_PARAMS) queue daemon $CNT" __run_fio_libaio $DEV $BS $RW $JOBS $RT > /dev/null 2 >& 1 & sleep 2 pid=`__ublk_get_pid $DEV` kill -9 $pid sleep 2 secs=0 while [ $secs -lt 10 ]; do state=`__ublk_get_dev_state $DEV 0` [ "$state" == "QUIESCED" ] && break sleep 1 let secs++ done secs=0 while [ $secs -lt 10 ]; do RES=`__recover_ublk_dev $DEV` [ $RES -eq 0 ] && break sleep 1 let secs++ done if [ $RES -ne 0 ]; then echo -e "\trecover $DEV failed" fi sleep 2 RES=`__remove_ublk_dev_return $DEV` if [ $RES -ne 0 ]; then echo -e "\tdelete $DEV failed" break fi wait sleep 3 done _remove_image ${type} $file } for TGT in $ALL_TGTS; do for RECOVERY_REISSUE in `seq 0 1`; do ublk_run_recover_test $TGT done done