From b34eb155e4a6a05dbe43b0f7342a8118d09fdc7c Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Tue, 1 Sep 2020 17:20:05 +0900 Subject: [PATCH] t/zbd: Reset all zones before test when max open zones is specified When the test target device has maximum open zones limit, the zones in test target region may not be opened up to the limit, because the zones out of the test target region may have open zones. To ensure that the test target zones can be opened up to the limit, reset all zones of the test target device before the test cases with write work load starts. Introduce the helper function prep_write() to check if all zone reset is required and do the reset. Also remove unnecessary reset_zone calls for test case #29 and #48. These are no longer required by virtue of the improvement in zbd_setup_files() to set up zones to meet max_open_zones limit. Signed-off-by: Shin'ichiro Kawasaki Reviewed-by: Dmitry Fomichev Signed-off-by: Jens Axboe --- t/zbd/test-zbd-support | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/t/zbd/test-zbd-support b/t/zbd/test-zbd-support index c21d6aad..248423bb 100755 --- a/t/zbd/test-zbd-support +++ b/t/zbd/test-zbd-support @@ -181,6 +181,15 @@ run_fio_on_seq() { run_one_fio_job "${opts[@]}" "$@" } +# Prepare for write test by resetting zones. When max_open_zones option is +# specified, reset all zones of the test target to ensure that zones out of the +# test target range do not have open zones. This allows the write test to the +# target range to be able to open zones up to max_open_zones. +prep_write() { + [[ -n "${max_open_zones_opt}" && -n "${is_zbd}" ]] && + reset_zone "${dev}" -1 +} + # Check whether buffered writes are refused. test1() { run_fio --name=job1 --filename="$dev" --rw=write --direct=0 --bs=4K \ @@ -252,6 +261,7 @@ test4() { test5() { local size off capacity + prep_write off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 4 $off $dev) size=$((4 * zone_size)) @@ -267,6 +277,7 @@ test5() { test6() { local size off capacity + prep_write off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 4 $off $dev) size=$((4 * zone_size)) @@ -285,6 +296,7 @@ test7() { local size=$((zone_size)) local off capacity + prep_write off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 1 $off $dev) run_fio_on_seq "$(ioengine "libaio")" --iodepth=1 --rw=randwrite \ @@ -299,6 +311,7 @@ test7() { test8() { local size off capacity + prep_write size=$((4 * zone_size)) off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 4 $off $dev) @@ -319,6 +332,7 @@ test9() { return 0 fi + prep_write size=$((4 * zone_size)) run_fio_on_seq --ioengine=sg \ --iodepth=1 --rw=randwrite --bs=16K \ @@ -337,6 +351,7 @@ test10() { return 0 fi + prep_write size=$((4 * zone_size)) run_fio_on_seq --ioengine=sg \ --iodepth=64 --rw=randwrite --bs=16K \ @@ -350,6 +365,7 @@ test10() { test11() { local size off capacity + prep_write size=$((4 * zone_size)) off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 4 $off $dev) @@ -364,6 +380,7 @@ test11() { test12() { local size off capacity + prep_write size=$((8 * zone_size)) off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 8 $off $dev) @@ -378,6 +395,7 @@ test12() { test13() { local size off capacity + prep_write size=$((8 * zone_size)) off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 8 $off $dev) @@ -393,6 +411,7 @@ test13() { test14() { local size + prep_write size=$((16 * 2**20)) # 20 MB if [ $size -gt $((first_sequential_zone_sector * 512)) ]; then echo "$dev does not have enough sequential zones" \ @@ -417,6 +436,7 @@ test15() { reset_zone "$dev" $((first_sequential_zone_sector + i*sectors_per_zone)) done + prep_write w_off=$(((first_sequential_zone_sector + 2 * sectors_per_zone) * 512)) w_size=$((2 * zone_size)) w_capacity=$(total_zone_capacity 2 $w_off $dev) @@ -441,6 +461,7 @@ test16() { reset_zone "$dev" $((first_sequential_zone_sector + i*sectors_per_zone)) done + prep_write w_off=$(((first_sequential_zone_sector + 2 * sectors_per_zone) * 512)) w_size=$((2 * zone_size)) w_capacity=$(total_zone_capacity 2 $w_off $dev) @@ -463,6 +484,7 @@ test17() { if [ -n "$is_zbd" ]; then reset_zone "$dev" $((off / 512)) || return $? fi + prep_write run_one_fio_job "$(ioengine "libaio")" --iodepth=8 --rw=randrw --bs=4K \ --zonemode=zbd --zonesize="${zone_size}" \ --offset=$off --loops=2 --norandommap=1\ @@ -516,6 +538,7 @@ test24() { local bs loops=9 size=$((zone_size)) local off capacity + prep_write off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 1 $off $dev) @@ -538,6 +561,7 @@ test25() { [ -n "$is_zbd" ] && reset_zone "$dev" $((first_sequential_zone_sector + i*sectors_per_zone)) done + prep_write for ((i=0;i<16;i++)); do opts+=("--name=job$i" "--filename=$dev" "--thread=1" "--direct=1") opts+=("--offset=$((first_sequential_zone_sector*512 + zone_size*i))") @@ -552,6 +576,7 @@ write_to_first_seq_zone() { local loops=4 r local off capacity + prep_write off=$((first_sequential_zone_sector * 512)) capacity=$(total_zone_capacity 1 $off $dev) @@ -581,6 +606,7 @@ test28() { off=$((first_sequential_zone_sector * 512 + 64 * zone_size)) [ -n "$is_zbd" ] && reset_zone "$dev" $((off / 512)) + prep_write opts=("--debug=zbd") capacity=$(total_zone_capacity 1 $off $dev) for ((i=0;i> "${logfile}.${test_number}" 2>&1 && return 1 @@ -865,7 +903,7 @@ test48() { off=$((first_sequential_zone_sector * 512 + 64 * zone_size)) size=$((16*zone_size)) - [ -n "$is_zbd" ] && reset_zone "$dev" $((off / 512)) + prep_write opts=("--aux-path=/tmp" "--allow_file_create=0" "--significant_figures=10") opts+=("--debug=zbd") opts+=("$(ioengine "libaio")" "--rw=randwrite" "--direct=1") -- 2.25.1