btrfs: reject fs block size larger than 4K
PATCH 1/1 btrfs: reject fs block size larger than 4K
[BUG]
When running the experimental block size > page support, the test case btrfs/192 fails with the following error:
FSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 6.17.0-rc4-custom+ #287 SMP PREEMPT_DYNAMIC Thu Sep 18 16:42:54 ACST 2025 MKFS_OPTIONS -- -s 8k /dev/mapper/test-scratch1
MOUNT_OPTIONS -- /dev/mapper/test-scratch1 /mnt/scratch
btrfs/192 436s ... [failed, exit status 1]- output mismatch (see /home/adam/xfstests/results//btrfs/192.out.bad)
--- tests/btrfs/192.out 2022-05-11 11:25:30.746666664 +0930
+++ /home/adam/xfstests/results//btrfs/192.out.bad 2025-09-18 18:34:10.511152624 +0930
@@ -1,2 +1,2 @@
QA output created by 192
-Silence is golden
+ERROR: illegal nodesize 4096 (smaller than 8192)
...
(Run 'diff -u /home/adam/xfstests/tests/btrfs/192.out /home/adam/xfstests/results//btrfs/192.out.bad' to see the entire diff)
Please note that, btrfs bs > ps is still under development. This is only an early run to expose false alerts.
[CAUSE]
The test case explicitly requires 4K nodesize to bump up tree size.
However if we use fs block size larger than 4K, the node size 4K will be smaller than a block, causing mkfs failure, as block size is the minimal unit for both data and metadata, thus node size smaller than block size is illege.
[FIX]
Before calling mkfs on the log-writes dm device, do a simple mkfs and mount of the scratch device, to verify the block size.
If the block size is larger than 4k, skip the test case.
--- tests/btrfs/192 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
tests/btrfs/192 +9 -3
@@ -34,9 +34,15 @@ _require_log_writes _require_scratch _require_attrs -# We require a 4K nodesize to ensure the test isn't too slow -if [ $(_get_page_size) -ne 4096 ]; then - _notrun "This test doesn't support non-4K page size yet" +_scratch_mkfs > /dev/null +_scratch_mount +blksz=$(_get_block_size $SCRATCH_MNT) +_scratch_unmount + +# We need 4K nodesize, and if block size is larger than that mkfs will +# fail. So reject any block size larger than 4K. +if [ $blksz -gt 4096 ]; then + _notrun "This test requires block size 4096, has $blksz" fi runtime=30
Signature · 1 line
2.51.0