[PATCH] btrfs/237: kick reclaim process with a small filesystem

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



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@xxxxxxx>
---
 tests/btrfs/237 | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/tests/btrfs/237 b/tests/btrfs/237
index 3c660edbe27d..367019b6025d 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))
-- 
2.42.0




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux