Introduce _zone_capacity() to return a zone capacity of the given address in the given device (optional). Rewrite btrfs/237 with it. Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx> --- common/zbd | 17 +++++++++++++++++ tests/btrfs/237 | 8 ++------ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 common/zbd diff --git a/common/zbd b/common/zbd new file mode 100644 index 000000000000..329bb7be6b7b --- /dev/null +++ b/common/zbd @@ -0,0 +1,17 @@ +# +# Common zoned block device specific functions +# + +. common/filter + +_zone_capacity() { + local phy=$1 + local dev=$2 + + [ -z "$dev" ] && dev=$SCRATCH_DEV + + size=$($BLKZONE_PROG report -o $phy -l 1 $dev |\ + _filter_blkzone_report |\ + grep -Po "cap 0x[[:xdigit:]]+" | cut -d ' ' -f 2) + echo $((size << 9)) +} diff --git a/tests/btrfs/237 b/tests/btrfs/237 index bc6522e2200a..101094b5ce70 100755 --- a/tests/btrfs/237 +++ b/tests/btrfs/237 @@ -13,7 +13,7 @@ _begin_fstest auto quick zone balance # Import common functions. -. ./common/filter +. ./common/zbd # real QA test starts here @@ -56,11 +56,7 @@ fi start_data_bg_phy=$(get_data_bg_physical) start_data_bg_phy=$((start_data_bg_phy >> 9)) - -size=$($BLKZONE_PROG report -o $start_data_bg_phy -l 1 $SCRATCH_DEV |\ - _filter_blkzone_report |\ - grep -Po "cap 0x[[:xdigit:]]+" | cut -d ' ' -f 2) -size=$((size << 9)) +size=$(_zone_capacity $start_data_bg_phy) reclaim_threshold=75 echo $reclaim_threshold > /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold -- 2.37.3