Skip to contentSkip to conversation

btrfs: test active zone tracking

PATCH In review Naohiro Aota 2 participants 4 messages Oct 5, 2022 – Oct 7, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

v3 cover btrfs: test active zone tracking

This series adds a test for checking if an active zone tracking feature of btrfs's zoned mode. The first patch introduces _zone_capacity() helper to get the zone capacity of a specified zone. It rewrites btrfs/237 with the helper and use the helper in a newly added test btrfs/292.

Changes:
- v3:
- Fix import of common/zoned in btrfs/237.
- Use _fixed_by_kernel_commit.
- Cleanup background dd processes.
- Rework error handling.
- Fix indent.
- v2:
- Rename to common/zoned.
- Move _filter_blkzone_report() as well to common/zoned.
- Drop _require_fio as it was already unnecessary.

Naohiro Aota (2):
common: introduce zone_capacity() to return a zone capacity
btrfs: test active zone tracking

 common/filter       |  13 ----
 common/zoned        |  39 ++++++++++++
 tests/btrfs/237     |   8 +--
 tests/btrfs/292     | 143 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/292.out |   2 +
 5 files changed, 186 insertions(+), 19 deletions(-)
 create mode 100644 common/zoned
 create mode 100755 tests/btrfs/292
 create mode 100644 tests/btrfs/292.out
Signature · 1 line
2.38.0
#1 lore raw

PATCH v3 1/2 common: introduce zone_capacity() to return a zone capacity

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.

---
 common/filter   | 13 -------------
 common/zoned    | 28 ++++++++++++++++++++++++++++
 tests/btrfs/237 |  8 ++------
 3 files changed, 30 insertions(+), 19 deletions(-)
 create mode 100644 common/zoned
common/filter +0 -13
index 6433a30e53c2..3e3fea7ea02e 100644
@@ -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
common/zoned new file +28 -0
new file mode 100644
index 000000000000..d1bc60f784a1
@@ -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))
+}
tests/btrfs/237 +2 -6
index bc6522e2200a..733ce9c8bd8e 100755
@@ -13,7 +13,7 @@
 _begin_fstest auto quick zone balance
 
 # Import common functions.
-. ./common/filter
+. ./common/zoned
 
 # 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
Signature · 1 line
2.38.0
#2 lore raw

PATCH v3 2/2 btrfs: test active zone tracking

In reply to Naohiro Aota

A ZNS device limits the number of active zones, which is the number of zones can be written at the same time. To deal with the limit, btrfs's zoned mode tracks which zone (corresponds to a block group on the SINGLE profile) is active, and finish a zone if necessary.

This test checks if the active zone tracking and the finishing of zones works properly. First, it fills <number of max active zones> zones mostly. And, run some data/metadata stress workload to force btrfs to use a new zone.

This test fails on an older kernel (e.g, 5.18.2) like below.

btrfs/292
[failed, exit status 1]- output mismatch (see /host/btrfs/292.out.bad)

    --- tests/btrfs/292.out     2022-09-15 07:52:18.000000000 +0000
    +++ /host/btrfs/292.out.bad 2022-09-15 07:59:14.290967793 +0000
    @@ -1,2 +1,5 @@
     QA output created by 292
    -Silence is golden
    +stress_data_bgs failed
    +stress_data_bgs_2 failed
    +failed: '/bin/btrfs subvolume snapshot /mnt/scratch /mnt/scratch/snap825'
    +(see /host/btrfs/292.full for details)
    ...
    (Run 'diff -u /var/lib/xfstests/tests/btrfs/292.out /host/btrfs/292.out.bad'  to see the entire diff)

The failure is fixed with a series "btrfs: zoned: fix active zone tracking issues" [1] (upstream commits from 65ea1b66482f ("block: add bdev_max_segments() helper") to 2ce543f47843 ("btrfs: zoned: wait until zone is finished when allocation didn't progress")).

[1] https://lore.kernel.org/linux-btrfs/[email protected]/

---
 common/zoned        |  11 ++++
 tests/btrfs/292     | 143 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/292.out |   2 +
 3 files changed, 156 insertions(+)
 create mode 100755 tests/btrfs/292
 create mode 100644 tests/btrfs/292.out
common/zoned +11 -0
index d1bc60f784a1..eed0082a15cf 100644
@@ -15,6 +15,17 @@ _filter_blkzone_report()
 	sed -e 's/len/cap/2'
 }
 
+_require_limited_active_zones() {
+    local dev=$1
+    local sysfs=$(_sysfs_dev ${dev})
+    local attr="${sysfs}/queue/max_active_zones"
+
+    [ -e "${attr}" ] || _notrun "cannot find queue/max_active_zones. Maybe non-zoned device?"
+    if [ $(cat "${attr}") == 0 ]; then
+	_notrun "this test requires limited active zones"
+    fi
+}
+
 _zone_capacity() {
     local phy=$1
     local dev=$2
tests/btrfs/292 new file +143 -0

143 lines not on this page · raw message

tests/btrfs/292.out new file +2 -0
new file mode 100644
index 000000000000..627309d3fbd2
@@ -0,0 +1,2 @@
+QA output created by 292
+Silence is golden
Signature · 1 line
2.38.0
#3 lore raw
In reply to Naohiro Aota
Quoted 4 lines · Naohiro Aota

This series adds a test for checking if an active zone tracking feature of btrfs's zoned mode. The first patch introduces _zone_capacity() helper to get the zone capacity of a specified zone. It rewrites btrfs/237 with the helper and use the helper in a newly added test btrfs/292.

I have no more review points on this version now, will push it in next fstests release, if no objection from others. Thanks!

Quoted 30 lines

Changes:
- v3:
- Fix import of common/zoned in btrfs/237.
- Use _fixed_by_kernel_commit.
- Cleanup background dd processes.
- Rework error handling.
- Fix indent.
- v2:
- Rename to common/zoned.
- Move _filter_blkzone_report() as well to common/zoned.
- Drop _require_fio as it was already unnecessary.

Naohiro Aota (2):
common: introduce zone_capacity() to return a zone capacity
btrfs: test active zone tracking

 common/filter       |  13 ----
 common/zoned        |  39 ++++++++++++
 tests/btrfs/237     |   8 +--
 tests/btrfs/292     | 143 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/292.out |   2 +
 5 files changed, 186 insertions(+), 19 deletions(-)
 create mode 100644 common/zoned
 create mode 100755 tests/btrfs/292
 create mode 100644 tests/btrfs/292.out
Signature · 1 line
2.38.0