t/zbd: Add -w option to ensure no open zone before write tests
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 13 Oct 2021 06:09:03 +0000 (15:09 +0900)
committerJens Axboe <axboe@kernel.dk>
Sun, 17 Oct 2021 13:00:36 +0000 (07:00 -0600)
The commit b34eb155e4a6 ("t/zbd: Reset all zones before test when max
open zones is specified") introduced -o max_open_zones option to the
script t/zbd/test-zbd-support. It passes max_open_zones value to fio and
resets all zones of the test target device before each test case run
with write operation. This zone reset by the script ensures that no zone
out of the IO range is in open status and the write operation do not
exceed the max_open_zones limit.

On the other hand, since commit d2f442bc0bd5 ("ioengines: add
get_max_open_zones zoned block device operation"), fio automatically
fetches the max_open_zones value. So it is no longer required to pass
the max_open_zones value from the script to fio. To simplify the script
usage, introduce -w option which does not require max_open_zones value.
This option just resets zones before test cases with write operation.

Of note is that fio itself resets the zones exceeding max_open_zones
limit since the commit 954217b90191 ("zbd: Initialize open zones list
referring zone status at fio start"), but it just resets zones within
the fio IO range. Still zone reset by the test script is required for
zones out of IO range. Zone reset out of IO range by fio is not
implemented since it may cause unexpected data erasure.

Suggested-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
Link: https://lore.kernel.org/r/20211013060903.166543-6-shinichiro.kawasaki@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/zbd/test-zbd-support

index 4ee46de35f4f33adf128d6ee233a20bcba48cac0..7e2fff00dac6adc4cc8bc08b7423ab9b7081ab3f 100755 (executable)
@@ -12,6 +12,7 @@ usage() {
        echo -e "\t-v Run fio with valgrind --read-var-info option"
        echo -e "\t-l Test with libzbc ioengine"
        echo -e "\t-r Reset all zones before test start"
+       echo -e "\t-w Reset all zones before executing each write test case"
        echo -e "\t-o <max_open_zones> Run fio with max_open_zones limit"
        echo -e "\t-t <test #> Run only a single test case with specified number"
        echo -e "\t-q Quit the test run after any failed test"
@@ -182,13 +183,14 @@ 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.
+# Prepare for write test by resetting zones. When reset_before_write or
+# 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 limit specified as the option or obtained from sysfs.
 prep_write() {
-       [[ -n "${max_open_zones_opt}" && -n "${is_zbd}" ]] &&
-               reset_zone "${dev}" -1
+       [[ -n "${reset_before_write}" || -n "${max_open_zones_opt}" ]] &&
+               [[ -n "${is_zbd}" ]] && reset_zone "${dev}" -1
 }
 
 SKIP_TESTCASE=255
@@ -1247,6 +1249,7 @@ SECONDS=0
 tests=()
 dynamic_analyzer=()
 reset_all_zones=
+reset_before_write=
 use_libzbc=
 zbd_debug=
 max_open_zones_opt=
@@ -1261,6 +1264,7 @@ while [ "${1#-}" != "$1" ]; do
        shift;;
     -l) use_libzbc=1; shift;;
     -r) reset_all_zones=1; shift;;
+    -w) reset_before_write=1; shift;;
     -t) tests+=("$2"); shift; shift;;
     -o) max_open_zones_opt="${2}"; shift; shift;;
     -v) dynamic_analyzer=(valgrind "--read-var-info=yes");