From 00080a1eb135a91e46ff17ea630512d142124708 Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Wed, 19 Jul 2023 19:57:48 +0900 Subject: [PATCH] t/zbd: add close_zone helper function Add a helper function which sets the specified zone in closed condition. Signed-off-by: Shin'ichiro Kawasaki Link: https://lore.kernel.org/r/20230719105756.553146-6-shinichiro.kawasaki@wdc.com Signed-off-by: Vincent Fu --- t/zbd/functions | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/t/zbd/functions b/t/zbd/functions index 9a6d6999..fe5b3397 100644 --- a/t/zbd/functions +++ b/t/zbd/functions @@ -4,6 +4,7 @@ blkzone=$(type -p blkzone 2>/dev/null) sg_inq=$(type -p sg_inq 2>/dev/null) zbc_report_zones=$(type -p zbc_report_zones 2>/dev/null) zbc_reset_zone=$(type -p zbc_reset_zone 2>/dev/null) +zbc_close_zone=$(type -p zbc_close_zone 2>/dev/null) zbc_info=$(type -p zbc_info 2>/dev/null) if [ -z "${blkzone}" ] && { [ -z "${zbc_report_zones}" ] || [ -z "${zbc_reset_zone}" ]; }; then @@ -304,6 +305,18 @@ reset_zone() { fi } +# Close the zone on device $1 at offset $2. The offset must be specified in +# units of 512 byte sectors. +close_zone() { + local dev=$1 offset=$2 + + if [ -n "${blkzone}" ] && [ -z "${use_libzbc}" ]; then + ${blkzone} close -o "${offset}" -c 1 "$dev" + else + ${zbc_close_zone} -sector "$dev" "${offset}" >/dev/null + fi +} + # Extract the number of bytes that have been transferred from a line like # READ: bw=6847KiB/s (7011kB/s), 6847KiB/s-6847KiB/s (7011kB/s-7011kB/s), io=257MiB (269MB), run=38406-38406msec fio_io() { -- 2.25.1