[PATCH 6/7] btrfs/301: Make this test compatible with all block sizes.

Nirjhar Roy (IBM)
2025-07-29T06:24:42Z

With large block sizes like 64k on powerpc with 64k pagesize
the test failed with the following logs:

QA output created by 301
basic accounting
+subvol 256 mismatched usage 33947648 vs 4587520 \
(expected data 4194304 expected meta 393216 diff 29360128)
+subvol 256 mismatched usage 168165376 vs 138805248 \
(expected data 138412032 expected meta 393216 diff 29360128)
+subvol 256 mismatched usage 33947648 vs 4587520 \
(expected data 4194304 expected meta 393216 diff 29360128)
+subvol 256 mismatched usage 33947648 vs 4587520 \
(expected data 4194304 expected meta 393216 diff 29360128)
fallocate: Disk quota exceeded
(Please note that the above ouptut had to be modified a bit since
the number of characters in each line was much greater than the
72 characters.)

The test creates nr_fill files each of size 8k i.e, 2x4k(stored in fill_sz).
Now with 64k blocksize, 8k sized files occupy more than expected
sizes (i.e, 8k) due to internal fragmentation since 1 file
will occupy at least 1 block. Fix this by scaling the file size (fill_sz)
with the blocksize.

Reported-by: Disha Goel <disgoel@linux.ibm.com>
Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
---
tests/btrfs/301 | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/btrfs/301 b/tests/btrfs/301
index 6b59749d..7547ff0e 100755
--- a/tests/btrfs/301
+++ b/tests/btrfs/301
@@ -23,7 +23,13 @@ subv=$SCRATCH_MNT/subv
nested=$SCRATCH_MNT/subv/nested
snap=$SCRATCH_MNT/snap
nr_fill=512
-fill_sz=$((8 * 1024))
+
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+blksz=`_get_block_size $SCRATCH_MNT`
+_scratch_unmount
+fill_sz=$(( 2 * blksz ))
+
total_fill=$(($nr_fill * $fill_sz))
nodesize=$($BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | \
grep nodesize | $AWK_PROG '{print $2}')
--
2.34.1