From: Yu Kuai While testing throtl manually, it's found there is a deadlock problem, add this regression test. Signed-off-by: Yu Kuai --- tests/throtl/004 | 20 ++++++++++++++++++++ tests/throtl/rc | 11 +++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/throtl/004 b/tests/throtl/004 index d1461b9..05a1c9d 100755 --- a/tests/throtl/004 +++ b/tests/throtl/004 @@ -7,6 +7,7 @@ # commit 8f9e7b65f833 ("block: cancel all throttled bios in del_gendisk()") . tests/throtl/rc +. common/scsi_debug DESCRIPTION="delete disk while IO is throttled" QUICK=1 @@ -14,7 +15,12 @@ QUICK=1 test() { echo "Running ${TEST_NAME}" + if ! _configure_scsi_debug; then + return 1; + fi + if ! _set_up_throtl; then + _exit_scsi_debug return 1; fi @@ -29,6 +35,20 @@ test() { echo 0 > "/sys/kernel/config/nullb/$THROTL_DEV/power" wait $! + echo "$(cat /sys/block/${SCSI_DEBUG_DEVICES[0]}/dev) wbps=$((1024 * 1024))" > \ + "$CGROUP2_DIR/$THROTL_DIR/io.max" + + { + echo "$BASHPID" > "$CGROUP2_DIR/$THROTL_DIR/cgroup.procs" + _throtl_issue_io write 10M 1 ${SCSI_DEBUG_DEVICES[0]} &> /dev/null + } & + + sleep 0.6 + echo 1 > "/sys/block/${SCSI_DEBUG_DEVICES[0]}/device/delete" + wait $! + _clean_up_throtl + _exit_scsi_debug + echo "Test complete" } diff --git a/tests/throtl/rc b/tests/throtl/rc index 327084b..5f9f1d7 100644 --- a/tests/throtl/rc +++ b/tests/throtl/rc @@ -98,13 +98,20 @@ _throtl_issue_io() { local start_time local end_time local elapsed + local testdev + + if [ $# -ge 4 ]; then + testdev=$4 + else + testdev=$THROTL_DEV + fi start_time=$(date +%s.%N) if [ "$1" == "read" ]; then - dd if=/dev/$THROTL_DEV of=/dev/null bs="$2" count="$3" iflag=direct status=none + dd if=/dev/$testdev of=/dev/null bs="$2" count="$3" iflag=direct status=none elif [ "$1" == "write" ]; then - dd of=/dev/$THROTL_DEV if=/dev/zero bs="$2" count="$3" oflag=direct status=none + dd of=/dev/$testdev if=/dev/zero bs="$2" count="$3" oflag=direct status=none fi end_time=$(date +%s.%N) -- 2.39.2