linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naohiro Aota <Naohiro.Aota@wdc.com>
To: Zorro Lang <zlang@redhat.com>
Cc: "fstests@vger.kernel.org" <fstests@vger.kernel.org>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] common: introduce zone_capacity() to return a zone capacity
Date: Fri, 30 Sep 2022 06:19:28 +0000	[thread overview]
Message-ID: <20220930061926.pdej5mnfunj37sow@naota-xeon> (raw)
In-Reply-To: <20220929051507.aonami57xnhnixan@zlang-mailbox>

On Thu, Sep 29, 2022 at 01:15:07PM +0800, Zorro Lang wrote:
> On Thu, Sep 29, 2022 at 01:19:24PM +0900, Naohiro Aota wrote:
> > Introduce _zone_capacity() to return a zone capacity of the given address
> > in the given device (optional). Move _filter_blkzone_report() for it, and
> > rewrite btrfs/237 with it.
> > 
> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> > ---
> >  common/filter   | 13 -------------
> >  common/zoned    | 28 ++++++++++++++++++++++++++++
> >  tests/btrfs/237 |  8 ++------
> >  3 files changed, 30 insertions(+), 19 deletions(-)
> >  create mode 100644 common/zoned
> > 
> > diff --git a/common/filter b/common/filter
> > index 28dea64662dc..ac5c93422567 100644
> > --- a/common/filter
> > +++ b/common/filter
> > @@ -651,18 +651,5 @@ _filter_bash()
> >  	sed -e "s/^bash: line 1: /bash: /"
> >  }
> >  
> > -#
> > -# blkzone report added zone capacity to be printed from v2.37.
> > -# This filter will add an extra column 'cap' with the same value of
> > -# 'len'(zone size) for blkzone version < 2.37
> > -#
> > -# Before: start: 0x000100000, len 0x040000, wptr 0x000000 ..
> > -# After: start: 0x000100000, len 0x040000, cap 0x040000, wptr 0x000000 ..
> > -_filter_blkzone_report()
> > -{
> > -	$AWK_PROG -F "," 'BEGIN{OFS=",";} $3 !~ /cap/ {$2=$2","$2;} {print;}' |\
> > -	sed -e 's/len/cap/2'
> > -}
> > -
> >  # make sure this script returns success
> >  /bin/true
> > diff --git a/common/zoned b/common/zoned
> > new file mode 100644
> > index 000000000000..d1bc60f784a1
> > --- /dev/null
> > +++ b/common/zoned
> > @@ -0,0 +1,28 @@
> > +#
> > +# Common zoned block device specific functions
> > +#
> > +
> > +#
> > +# blkzone report added zone capacity to be printed from v2.37.
> > +# This filter will add an extra column 'cap' with the same value of
> > +# 'len'(zone size) for blkzone version < 2.37
> > +#
> > +# Before: start: 0x000100000, len 0x040000, wptr 0x000000 ..
> > +# After: start: 0x000100000, len 0x040000, cap 0x040000, wptr 0x000000 ..
> > +_filter_blkzone_report()
> > +{
> > +	$AWK_PROG -F "," 'BEGIN{OFS=",";} $3 !~ /cap/ {$2=$2","$2;} {print;}' |\
> > +	sed -e 's/len/cap/2'
> > +}
> > +
> > +_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
> 
> I'm a little surprised this line doesn't report error :) Anyway, it should be
> common/zoned as above. Others look good to me. With this fix, you can add:

Oops, I forgot to run this one. Thank you for catching this.

> Reviewed-by: Zorro Lang <zlang@redhat.com>
> 
> >  
> >  # 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
> > 
> 

  reply	other threads:[~2022-09-30  6:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29  4:19 [PATCH v2 0/2] btrfs: test active zone tracking Naohiro Aota
2022-09-29  4:19 ` [PATCH v2 1/2] common: introduce zone_capacity() to return a zone capacity Naohiro Aota
2022-09-29  5:15   ` Zorro Lang
2022-09-30  6:19     ` Naohiro Aota [this message]
2022-09-29  4:19 ` [PATCH v2 2/2] btrfs: test active zone tracking Naohiro Aota
2022-09-29  6:01   ` Zorro Lang
2022-09-29 12:04     ` David Sterba
2022-09-29 14:06       ` Zorro Lang
2022-09-30  6:21         ` Naohiro Aota
2022-09-30  6:29     ` Naohiro Aota

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220930061926.pdej5mnfunj37sow@naota-xeon \
    --to=naohiro.aota@wdc.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zlang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).