On Thu, Sep 22, 2022 at 02:54:58PM +0900, Naohiro Aota wrote: > 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 I don't like this abbreviation :-P If others don't open this file and read the comment in it, they nearly no chance to guess what's this file for. > @@ -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)) > +} Do you have more zone related helpers are going to provide? If only this single one helper, I think it's not worth adding a new common file. You can put it into common/rc simply, as there're already several *zone* related helpers in it. We can pick up these *zone* related function into a separate include file in one day we feel it's time (too many related helpers, and better to be maintained individually). Thanks, Zorro > 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 >