btrfs: reject fs block size larger than 4K
PATCH v2 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.
And since we're here, remove the out-of-date page size check, as btrfs has subpage block size support for a while.
Instead use a more accurate supported sector size check.
---
Changelog:
v2:
- Add the commit message on why we can remove the page size check
- Use _scratch_btrfs_sectorsize() so we do not need to mount/unmount scratch device
- Add the missing _require_btrfs_support_sectorsize call
--- tests/btrfs/192 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tests/btrfs/192 +8 -3
@@ -33,10 +33,15 @@ _require_btrfs_mkfs_feature "no-holes" _require_log_writes _require_scratch _require_attrs +_require_btrfs_support_sectorsize 4096 -# 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 +blksz=$(_scratch_btrfs_sectorsize $SCRATCH_MNT) + +# 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
Quoted 46 lines · Qu Wenruo
[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/scratchbtrfs/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.bad2025-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.
And since we're here, remove the out-of-date page size check, as btrfs has subpage block size support for a while.
Instead use a more accurate supported sector size check.Signed-off-by Qu Wenruo <[email protected]>---
Changelog:
v2:
- Add the commit message on why we can remove the page size check
Quoted 5 lines
- Use
_scratch_btrfs_sectorsize()so we do not need to mount/unmount scratch device- Add the missing
_require_btrfs_support_sectorsizecall
---
Hi Qu,
As this patch only changes btrfs/192, so the subject is better to be "btrfs/192: ....", due to "btrfs: ..." makes me think it changes lots of btrfs cases, or it's a new btrfs case :)
Thanks for you fix many issues about "btrfs 4k sector and block size", I saw you keep sending more patches about that, I think you're working on this thing recently. Could you please put this patch and others "btrfs/304~306" patches or more if you have in one patcheset. Then I'll know you've done all you want, and I can merge them together :)
Thanks,
Zorro
Quoted 30 lines
tests/btrfs/192 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tests/btrfs/192 +8
-3@@ -33,10 +33,15 @@ _require_btrfs_mkfs_feature "no-holes" _require_log_writes _require_scratch _require_attrs +_require_btrfs_support_sectorsize 4096 -# 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 +blksz=$(_scratch_btrfs_sectorsize $SCRATCH_MNT) + +# 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=30Signature · 1 line
2.51.0
Quoted 53 lines · Zorro Lang
Quoted 46 lines · Qu Wenruo
[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/scratchbtrfs/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.bad2025-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.
And since we're here, remove the out-of-date page size check, as btrfs has subpage block size support for a while.
Instead use a more accurate supported sector size check.Signed-off-by Qu Wenruo <[email protected]>---
Changelog:
v2:
- Add the commit message on why we can remove the page size checkQuoted 5 lines
- Use
_scratch_btrfs_sectorsize()so we do not need to mount/unmount scratch device- Add the missing
_require_btrfs_support_sectorsizecall
---
Quoted 7 lines
Hi Qu,
As this patch only changes btrfs/192, so the subject is better to be "btrfs/192: ....", due to "btrfs: ..." makes me think it changes lots of btrfs cases, or it's a new btrfs case :)
Thanks for you fix many issues about "btrfs 4k sector and block size",
BTW, the term "sector size" is a btrfs specific terminology, it is the same meaning of "block size" of all the other filesystems.
And this has caused confusion in the past, so I'm trying to spread the usage of "block size" to align us to other filesystems.
But since the mkfs option is still --sectorsize, and dump-super is still using "sectorsize", the confusion is still here.
On the long run we're going to replace sector size with block size, but it's not going to happen in one day. (I tried a huge patch to do all the rename, but it's not merged).
Quoted 4 lines
I saw you keep sending more patches about that, I think you're working on this thing recently. Could you please put this patch and others "btrfs/304~306" patches or more if you have in one patcheset. Then I'll know you've done all you want, and I can merge them together :)
All my bad, I just started fixing the failures one by one, and until reached btrfs/305 I noticed the pattern.
I'll group them into one patchset. And for closely related test case like btrfs/30[456], I'll merge them into one, as they share the same fix.
Sorry for the email bombarding.
Thanks,
Qu
Quoted 37 lines
Thanks,
ZorroQuoted 30 lines
tests/btrfs/192 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)tests/btrfs/192 +8
-3@@ -33,10 +33,15 @@ _require_btrfs_mkfs_feature "no-holes" _require_log_writes _require_scratch _require_attrs +_require_btrfs_support_sectorsize 4096 -# 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 +blksz=$(_scratch_btrfs_sectorsize $SCRATCH_MNT) + +# 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=30Signature · 1 line
2.51.0