aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaohiro Aota <naohiro.aota@wdc.com>2023-08-30 11:17:52 +0900
committerZorro Lang <zlang@kernel.org>2023-09-02 03:37:54 +0800
commitc1b325152870579db943aad71e91674994d8c178 (patch)
tree2acd4ee3c8f17b70bf19eca34f574032f4a16945
parent0fc226e7eac1fb6b0989c12930afc7e71665ff5d (diff)
downloadxfstests-dev-c1b325152870579db943aad71e91674994d8c178.tar.gz
btrfs/237: kick reclaim process with a small filesystem
Since commit 3687fcb0752a ("btrfs: zoned: make auto-reclaim less aggressive"), the reclaim process won't run unless the 75% (by default) of the filesystem volume is allocated as block groups. As a result, btrfs/237 won't success when it is run with a large volume. To run the reclaim process, we need to either fill the FS to the desired level, or make a small FS so that the test write can go over the level. Since the current test code expects the FS has only one data block group, filling the FS is both cumbersome and need effort to rewrite the test code. So, we take the latter method. We create a small (16 * zone size) FS. The size is chosen to hold a minimal FS with DUP metadata setup. However, creating a small FS is not enough. With SINGLE metadata setup, we allocate 3 zones (one for each DATA, METADATA and SYSTEM), which is less than 75% of 16 zones. We can tweak the threshold to 51% on regular btrfs kernel config (!CONFIG_BTRFS_DEBUG), but that is still not enough to start the reclaim process. So, this test requires CONFIG_BTRFS_DEBUG to set the threshold to 1%. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rwxr-xr-xtests/btrfs/23721
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/btrfs/237 b/tests/btrfs/237
index 3c660edbe2..367019b602 100755
--- a/tests/btrfs/237
+++ b/tests/btrfs/237
@@ -43,7 +43,16 @@ get_data_bg_physical()
grep -Eo 'offset [[:digit:]]+'| cut -d ' ' -f 2
}
-_scratch_mkfs >/dev/null 2>&1
+sdev="$(_short_dev $SCRATCH_DEV)"
+zone_size=$(($(cat /sys/block/${sdev}/queue/chunk_sectors) << 9))
+fssize=$((zone_size * 16))
+devsize=$(($(_get_device_size $SCRATCH_DEV) * 1024))
+# Create a minimal FS to kick the reclaim process
+if [[ $devsize -gt $fssize ]]; then
+ _scratch_mkfs_sized $fssize >> $seqres.full 2>&1
+else
+ _scratch_mkfs >> $seqres.full 2>&1
+fi
_scratch_mount -o commit=1 # 1s commit time to speed up test
uuid=$($BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV |grep uuid: |\
@@ -59,7 +68,15 @@ start_data_bg_phy=$((start_data_bg_phy >> 9))
size=$(_zone_capacity $start_data_bg_phy)
reclaim_threshold=75
-echo $reclaim_threshold > /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold
+if [[ -f /sys/fs/btrfs/"$uuid"/allocation/data/bg_reclaim_threshold ]]; then
+ fs_fill=1
+ echo $fs_fill > /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold ||
+ _notrun "Need CONFIG_BTRFS_DEBUG to lower the reclaim threshold"
+ echo $reclaim_threshold > /sys/fs/btrfs/"$uuid"/allocation/data/bg_reclaim_threshold
+else
+ echo $reclaim_threshold > /sys/fs/btrfs/"$uuid"/bg_reclaim_threshold
+fi
+
fill_percent=$((reclaim_threshold + 2))
rest_percent=$((90 - fill_percent)) # make sure we're not creating a new BG
fill_size=$((size * fill_percent / 100))