From 1a5411cd73840b40737f629ec703b082aed08067 Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Wed, 19 Jul 2023 19:57:49 +0900 Subject: [PATCH] t/zbd: add max_active_zone variable 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 Link: https://lore.kernel.org/r/20230719105756.553146-7-shinichiro.kawasaki@wdc.com Signed-off-by: Vincent Fu --- t/zbd/functions | 12 ++++++++++++ t/zbd/test-zbd-support | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/t/zbd/functions b/t/zbd/functions index fe5b3397..529e7944 100644 --- a/t/zbd/functions +++ b/t/zbd/functions @@ -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 diff --git a/t/zbd/test-zbd-support b/t/zbd/test-zbd-support index a3d37a7d..eed3d00d 100755 --- a/t/zbd/test-zbd-support +++ b/t/zbd/test-zbd-support @@ -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 -- 2.25.1