t/zbd: update test case 42
[fio.git] / t / zbd / test-zbd-support
index be1296151930f46ea9694cdb9ba580ef60ba335a..57e6d05ea73744858d56ee86341963460c7c0cf6 100755 (executable)
@@ -731,32 +731,28 @@ test30() {
 test31() {
     local bs inc nz off opts size
 
-    prep_write
-    # Start with writing 128 KB to max_open_zones sequential zones.
-    bs=128K
+    [ -n "$is_zbd" ] && reset_zone "$dev" -1
+
+    # As preparation, write 128 KB to sequential write required zones. Limit
+    # write target zones up to max_open_zones to keep test time reasonable.
+    # To distribute the write target zones evenly, skip certain zones for every
+    # write. Utilize zonemode strided for such write patterns.
+    bs=$((128 * 1024))
     nz=$((max_open_zones))
     if [[ $nz -eq 0 ]]; then
        nz=128
     fi
-    # shellcheck disable=SC2017
-    inc=$(((disk_size - (first_sequential_zone_sector * 512)) / (nz * zone_size)
-          * zone_size))
-    if [ "$inc" -eq 0 ]; then
-       require_seq_zones $nz || return $SKIP_TESTCASE
-    fi
-    opts=()
-    for ((off = first_sequential_zone_sector * 512; off < disk_size;
-         off += inc)); do
-       opts+=("--name=$dev" "--filename=$dev" "--offset=$off" "--io_size=$bs")
-       opts+=("--bs=$bs" "--size=$zone_size" "$(ioengine "libaio")")
-       opts+=("--rw=write" "--direct=1" "--thread=1" "--stats=0")
-       opts+=("--zonemode=zbd" "--zonesize=${zone_size}")
-       opts+=(${job_var_opts[@]})
-    done
-    "$(dirname "$0")/../../fio" "${opts[@]}" >> "${logfile}.${test_number}" 2>&1
-    # Next, run the test.
     off=$((first_sequential_zone_sector * 512))
     size=$((disk_size - off))
+    inc=$(((size / nz / zone_size) * zone_size))
+    opts=("--name=$dev" "--filename=$dev" "--rw=write" "--bs=${bs}")
+    opts+=("--offset=$off" "--size=$((inc * nz))" "--io_size=$((bs * nz))")
+    opts+=("--zonemode=strided" "--zonesize=${bs}" "--zonerange=${inc}")
+    opts+=("--direct=1")
+    echo "fio ${opts[@]}" >> "${logfile}.${test_number}"
+    "$(dirname "$0")/../../fio" "${opts[@]}" >> "${logfile}.${test_number}" 2>&1
+
+    # Next, run the test.
     opts=("--name=$dev" "--filename=$dev" "--offset=$off" "--size=$size")
     opts+=("--bs=$bs" "$(ioengine "psync")" "--rw=randread" "--direct=1")
     opts+=("--thread=1" "--time_based" "--runtime=30" "--zonemode=zbd")
@@ -926,7 +922,7 @@ test41() {
 test42() {
     require_regular_block_dev || return $SKIP_TESTCASE
     read_one_block --zonemode=zbd --zonesize=0 |
-       grep -q 'Specifying the zone size is mandatory for regular block devices with --zonemode=zbd'
+       grep -q 'Specifying the zone size is mandatory for regular file/block device with --zonemode=zbd'
 }
 
 # Check whether fio handles --zonesize=1 correctly for regular block devices.
@@ -1201,6 +1197,24 @@ test56() {
                >> "${logfile}.${test_number}" 2>&1 || return $?
 }
 
+# Test that repeated async write job does not cause zone reset during writes
+# in-flight, when the block size is not a divisor of the zone size.
+test57() {
+       local bs off
+
+       require_zbd || return $SKIP_TESTCASE
+
+       bs=$((4096 * 7))
+       off=$((first_sequential_zone_sector * 512))
+
+       run_fio --name=job --filename="${dev}" --rw=randwrite --bs="${bs}" \
+               --offset="${off}" --size=$((4 * zone_size)) --iodepth=256 \
+               "$(ioengine "libaio")" --time_based=1 --runtime=30s \
+               --zonemode=zbd --direct=1 --zonesize="${zone_size}" \
+               ${job_var_opts[@]} \
+               >> "${logfile}.${test_number}" 2>&1 || return $?
+}
+
 SECONDS=0
 tests=()
 dynamic_analyzer=()
@@ -1330,6 +1344,7 @@ fi
 if [[ -n ${max_open_zones_opt} ]]; then
        # Override max_open_zones with the script option value
        max_open_zones="${max_open_zones_opt}"
+       global_var_opts+=("--ignore_zone_limits=1")
        job_var_opts+=("--max_open_zones=${max_open_zones_opt}")
 fi