]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs/237: kick reclaim process with a small filesystem
authorNaohiro Aota <naohiro.aota@wdc.com>
Wed, 30 Aug 2023 02:17:52 +0000 (11:17 +0900)
committerZorro Lang <zlang@kernel.org>
Fri, 1 Sep 2023 19:37:54 +0000 (03:37 +0800)
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>
tests/btrfs/237

index 3c660edbe27d3b281e75f3188cd6fbe75a50984d..367019b6025d2567263dd102dcca27ffe8c86eb5 100755 (executable)
@@ -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))