t/zbd: add max_active_zone variable
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 19 Jul 2023 10:57:49 +0000 (19:57 +0900)
committerVincent Fu <vincent.fu@samsung.com>
Thu, 20 Jul 2023 13:52:37 +0000 (09:52 -0400)
To test fio behavior on zoned block devices with max_active_zones limit,
add a global variable which holds the limit value. Also add helper
functions to check max_active_zones limit of the test target devices and
max_active_zones requirement of test cases.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20230719105756.553146-7-shinichiro.kawasaki@wdc.com
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
t/zbd/functions
t/zbd/test-zbd-support

index fe5b3397f5a5688adaa2b9504667ab011100ef13..529e7944a2f8f3fba7f4e642e1bc283cfe7a20f9 100644 (file)
@@ -239,6 +239,18 @@ max_open_zones() {
     fi
 }
 
+# If sysfs provides, get max_active_zones limit of the zoned block device.
+max_active_zones() {
+       local dev=$1
+       local sys_queue="/sys/block/${dev##*/}/queue/"
+
+       if [[ -e "$sys_queue/max_active_zones" ]]; then
+               cat "$sys_queue/max_active_zones"
+               return
+       fi
+       echo 0
+}
+
 # Get minimum block size to write to seq zones. Refer the sysfs attribute
 # zone_write_granularity which shows the valid minimum size regardless of zoned
 # block device type. If the sysfs attribute is not available, refer physical
index a3d37a7d9527a70568f7d7a5beb1dec7bf1a61f4..eed3d00d73cd305187f1b3a578fc38fd31e6e62f 100755 (executable)
@@ -272,6 +272,20 @@ require_max_open_zones() {
        return 0
 }
 
+require_max_active_zones() {
+       local min=${1}
+
+       if ((max_active_zones == 0)); then
+               SKIP_REASON="$dev does not have max_active_zones limit"
+               return 1
+       fi
+       if ((max_active_zones < min)); then
+               SKIP_REASON="max_active_zones of $dev is smaller than $min"
+               return 1
+       fi
+       return 0
+}
+
 # Check whether buffered writes are refused for block devices.
 test1() {
     require_block_dev || return $SKIP_TESTCASE
@@ -1497,6 +1511,7 @@ if [[ -b "$realdev" ]]; then
                        echo "Failed to determine maximum number of open zones"
                        exit 1
                fi
+               max_active_zones=$(max_active_zones "$dev")
                set_io_scheduler "$basename" deadline || exit $?
                if [ -n "$reset_all_zones" ]; then
                        reset_zone "$dev" -1
@@ -1508,6 +1523,7 @@ if [[ -b "$realdev" ]]; then
                zone_size=$(max 65536 "$min_seq_write_size")
                sectors_per_zone=$((zone_size / 512))
                max_open_zones=128
+               max_active_zones=0
                set_io_scheduler "$basename" none || exit $?
                ;;
        esac
@@ -1543,6 +1559,7 @@ elif [[ -c "$realdev" ]]; then
                echo "Failed to determine maximum number of open zones"
                exit 1
        fi
+       max_active_zones=0
        if [ -n "$reset_all_zones" ]; then
                reset_zone "$dev" -1
        fi