Skip to contentSkip to conversation

btrfs/306: skip the run if block size is not 4K

PATCH In review Qu Wenruo 2 participants 2 messages Sep 18, 2025 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs/306: skip the run if block size is not 4K

[FALSE ALERT]
When running btrfs with block size larger than 4K (e.g. 8K in this case), the test case will fail like this:

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/306 1s ... - output mismatch (see /home/adam/xfstests/results//btrfs/306.out.bad)
--- tests/btrfs/306.out 2024-07-15 16:17:42.639999997 +0930
+++ /home/adam/xfstests/results//btrfs/306.out.bad 2025-09-18 18:44:16.075000000 +0930
@@ -14,7 +14,7 @@
chunk uuid <UUID>
item 0 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 16
stripe 0 devid 1 physical XXXXXXXXX
- item 1 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 16
+ item 1 key (XXXXXX RAID_STRIPE 8192) itemoff XXXXX itemsize 16
stripe 0 devid 2 physical XXXXXXXXX
total bytes XXXXXXXX
...
(Run 'diff -u /home/adam/xfstests/tests/btrfs/306.out /home/adam/xfstests/results//btrfs/306.out.bad' to see the entire diff)

In the above case it's the experimental support of block size larger than page size.
The feature is still under development.

[CAUSE]
That test case requires 4K block size, but it has no way to control that, as QA runners can specify MKFS_OPTIONS="-s 8k", to override the default block size.

Normally this is impossible as on x86_64 the only supported block size is 4K, already the minimal block size of btrfs. So there is no way to use other block size in that test case.

However with the experiemental bs > ps support, even on x86_64 it's possible to use 8K block size, and that breaks the 4K block size assumption of the test case.

[FIX]
Add a quick scratch mkfs, and grab the block size of the resulted fs. If the block size is not 4K, skip the run.

Since we're here, also remove the page size check, since we have subpage block size support for a while, and replace it with a more accurate supported sectorsize check.

This more accurate sectorsize support now allows aarch64 (64K page size) to run btrfs/306 successfully, improving the subpage bs support coverage.

---
 tests/btrfs/306 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/btrfs/306 +6 -1
index b47c446b..879f67b4 100755
@@ -21,8 +21,13 @@ _require_btrfs_fs_feature "raid_stripe_tree"
 _require_btrfs_fs_feature "free_space_tree"
 _require_btrfs_free_space_tree
 _require_btrfs_no_compress
+_require_btrfs_support_sectorsize 4096
 
-test $(_get_page_size) -eq 4096 || _notrun "this tests requires 4k pagesize"
+_scratch_mkfs >> /dev/null
+blksz=$(_scratch_btrfs_sectorsize)
+if [ $blksz -ne 4096 ]; then
+	_notrun "this tests require blocksize 4096, has $blksz"
+fi
 
 test_4k_write_64koff()
 {
Signature · 1 line
2.51.0
#1 lore raw
Quoted 33 lines · Qu Wenruo

[FALSE ALERT]
When running btrfs with block size larger than 4K (e.g. 8K in this case), the test case will fail like this:

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/306 1s ... - output mismatch (see /home/adam/xfstests/results//btrfs/306.out.bad)
--- tests/btrfs/306.out 2024-07-15 16:17:42.639999997 +0930
+++ /home/adam/xfstests/results//btrfs/306.out.bad 2025-09-18 18:44:16.075000000 +0930
@@ -14,7 +14,7 @@
chunk uuid <UUID>
item 0 key (XXXXXX RAID_STRIPE 65536) itemoff XXXXX itemsize 16
stripe 0 devid 1 physical XXXXXXXXX
- item 1 key (XXXXXX RAID_STRIPE 4096) itemoff XXXXX itemsize 16
+ item 1 key (XXXXXX RAID_STRIPE 8192) itemoff XXXXX itemsize 16
stripe 0 devid 2 physical XXXXXXXXX
total bytes XXXXXXXX
...
(Run 'diff -u /home/adam/xfstests/tests/btrfs/306.out /home/adam/xfstests/results//btrfs/306.out.bad' to see the entire diff)

In the above case it's the experimental support of block size larger than page size.
The feature is still under development.

[CAUSE]
That test case requires 4K block size, but it has no way to control that, as QA runners can specify MKFS_OPTIONS="-s 8k", to override the default block size.

Quoted 5 lines

Normally this is impossible as on x86_64 the only supported block size is 4K, already the minimal block size of btrfs. So there is no way to use other block size in that test case.

However with the experiemental bs > ps support, even on x86_64 it's

type in experimental

Quoted 5 lines

possible to use 8K block size, and that breaks the 4K block size assumption of the test case.

[FIX]
Add a quick scratch mkfs, and grab the block size of the resulted fs.

resulted -> resulting

Quoted 20 lines

If the block size is not 4K, skip the run.

Since we're here, also remove the page size check, since we have subpage block size support for a while, and replace it with a more accurate supported sectorsize check.

This more accurate sectorsize support now allows aarch64 (64K page size) to run btrfs/306 successfully, improving the subpage bs support coverage.

---
 tests/btrfs/306 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/btrfs/306 +0 -0
index b47c446b..879f67b4 100755
@@ -21,8 +21,13 @@ _require_btrfs_fs_feature "raid_stripe_tree"
 _require_btrfs_fs_feature "free_space_tree"

tests/btrfs/306 _require_btrfs_fs_feature "raid_stripe_tree" · line 30

Quoted 10 lines
tests/btrfs/306 +6 -1
 _require_btrfs_free_space_tree
 _require_btrfs_no_compress
+_require_btrfs_support_sectorsize 4096
 
-test $(_get_page_size) -eq 4096 || _notrun "this tests requires 4k pagesize"
+_scratch_mkfs >> /dev/null
+blksz=$(_scratch_btrfs_sectorsize)
+if [ $blksz -ne 4096 ]; then
+       _notrun "this tests require blocksize 4096, has $blksz"
+fi

should be "this test requires a block size of 4096 bytes, have $blocksize"

So at least 3 of the raid stripe tree tests, from btrfs/304,305,306 require the same exact fix, why not combine all the fixes in a single patch?
You've sent patches for the other two that do exactly the same.

Thanks.

Quoted 8 lines
tests/btrfs/306 +0 -1
 test_4k_write_64koff()
 {
 
--

2.51.0