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>
+# 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
# 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
+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
# Check whether buffered writes are refused for block devices.
test1() {
require_block_dev || return $SKIP_TESTCASE
echo "Failed to determine maximum number of open zones"
exit 1
fi
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
set_io_scheduler "$basename" deadline || exit $?
if [ -n "$reset_all_zones" ]; then
reset_zone "$dev" -1
zone_size=$(max 65536 "$min_seq_write_size")
sectors_per_zone=$((zone_size / 512))
max_open_zones=128
zone_size=$(max 65536 "$min_seq_write_size")
sectors_per_zone=$((zone_size / 512))
max_open_zones=128
set_io_scheduler "$basename" none || exit $?
;;
esac
set_io_scheduler "$basename" none || exit $?
;;
esac
echo "Failed to determine maximum number of open zones"
exit 1
fi
echo "Failed to determine maximum number of open zones"
exit 1
fi
if [ -n "$reset_all_zones" ]; then
reset_zone "$dev" -1
fi
if [ -n "$reset_all_zones" ]; then
reset_zone "$dev" -1
fi