Skip to contentSkip to conversation

btrfs-progs: add block-group-tree to the default mkfs/convert features

PATCH Superseded Qu Wenruo 1 participant 5 messages Nov 27, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

cover btrfs-progs: add block-group-tree to the default mkfs/convert features

I was planning to do this during v6.12 but forgot it and now the next LTS kernel release is not that far away, it's finally time to make the switch.

The first patch is to update the existing test cases related to disabling no-holes/free-space-tree, which will lead to mkfs/convert failure as block-group-tree requires those two features.

The second patch is a large page-size specific fix, where on 64K page size systems misc/057 will fail due to subpage mount always enables v2 free space cache, resulting later conversion failure to fst.

The final patch is the one enabling new default block-group-tree feature for mkfs and convert.

Qu Wenruo (3):
btrfs-progs: tests: disable bgt feature for ^no-holes and ^fst runs
btrfs-progs: misc-tests: check if free space tree is enabled after
mount
btrfs-progs: add block-group-tree to the default mkfs features

 Documentation/mkfs.btrfs.rst                           |  2 +-
 common/fsfeatures.c                                    |  2 +-
 common/fsfeatures.h                                    |  3 ++-
 tests/cli-tests/009-btrfstune/test.sh                  |  2 +-
 tests/misc-tests/001-btrfstune-features/test.sh        |  9 +++++----
 tests/misc-tests/057-btrfstune-free-space-tree/test.sh | 10 +++++++++-
 6 files changed, 19 insertions(+), 9 deletions(-)

--
2.52.0

author
#1 lore raw

PATCH 1/3 btrfs-progs: tests: disable bgt feature for ^no-holes and ^fst runs

The no-so-new block-group-tree feature requires both no-holes and free-space-tree features.

For the incoming default block-group-tree feature at mkfs and convert time, this will cause errors and mkfs/convert will reject the run due to missing dependency features.

Change test cases that uses ^no-holes or ^fst to also disable block-group-tree feature to avoid such false alerts.

---
 tests/cli-tests/009-btrfstune/test.sh                  | 2 +-
 tests/misc-tests/001-btrfstune-features/test.sh        | 9 +++++----
 tests/misc-tests/057-btrfstune-free-space-tree/test.sh | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)
tests/cli-tests/009-btrfstune/test.sh +1 -1
index c3d0f0254679..e01190a53070 100755
@@ -20,7 +20,7 @@ run_check "$TOP/btrfstune" -r "$TEST_DEV"
 run_check_mkfs_test_dev -O ^skinny-metadata
 run_check "$TOP/btrfstune" -x "$TEST_DEV"
 
-run_check_mkfs_test_dev -O ^no-holes
+run_check_mkfs_test_dev -O ^no-holes,^block-group-tree
 run_check "$TOP/btrfstune" -n "$TEST_DEV"
 
 run_check_mkfs_test_dev
tests/misc-tests/001-btrfstune-features/test.sh +5 -4
index 081411107aab..ee4235ffb0ef 100755
@@ -25,7 +25,7 @@ test_feature()
 	tuneopt="$2"
 	sbflag="$3"
 
-	run_check_mkfs_test_dev ${mkfsfeatures:+-O ^"$mkfsfeatures"}
+	run_check_mkfs_test_dev ${mkfsfeatures:+-O "$mkfsfeatures"}
 	if run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \
 			grep -q "$sbflag"; then
 		_fail "FAIL: feature $sbflag must not be set on the base image"
@@ -38,7 +38,8 @@ test_feature()
 	run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
 }
 
-test_feature extref -r EXTENDED_IREF
-test_feature skinny-metadata -x SKINNY_METADATA
-test_feature no-holes -n NO_HOLES
+test_feature '^extref' -r EXTENDED_IREF
+test_feature '^skinny-metadata' -x SKINNY_METADATA
+# block group tree feature relies on no-holes, thus have to disable block-group-tree too.
+test_feature '^no-holes,^block-group-tree' -n NO_HOLES
 test_feature '' '-S 1' SEEDING
tests/misc-tests/057-btrfstune-free-space-tree/test.sh +1 -1
index 8d9a858ddc2f..fe5b87a1fd38 100755
@@ -12,7 +12,7 @@ setup_root_helper
 prepare_test_dev
 check_kernel_support_acl
 
-run_check_mkfs_test_dev -O ^free-space-tree
+run_check_mkfs_test_dev -O ^free-space-tree,^block-group-tree
 run_check_mount_test_dev
 populate_fs
 run_check_umount_test_dev
Signature · 1 line
2.52.0
author
#2 lore raw

PATCH 2/3 btrfs-progs: misc-tests: check if free space tree is enabled after mount

In reply to Qu Wenruo

For bs < ps cases, a mount will always enable free-space-tree due to the limitation of v1 space cache.

Test case misc/057 will lead to false failure if the page size is larger than the default 4K sector size.

Add an extra check on free-space-tree after fs population, and skip the test case if so.

---
 tests/misc-tests/057-btrfstune-free-space-tree/test.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/misc-tests/057-btrfstune-free-space-tree/test.sh +8 -0
index fe5b87a1fd38..f4099dd639e7 100755
@@ -17,6 +17,14 @@ run_check_mount_test_dev
 populate_fs
 run_check_umount_test_dev
 
+# Check if the fs has free space tree already. Currently bs < ps mount
+# will always enable free-space-tree (no support for v1 free space cache)
+if run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" |\
+	grep -q "FREE_SPACE_TREE"; then
+	_not_run "free-space-tree is always enabled for page size $(getconf PAGESIZE)"
+fi
+
 run_check $SUDO_HELPER "$TOP/btrfstune" --convert-to-free-space-tree "$TEST_DEV"
 
+
 run_check "$TOP/btrfs" check "$TEST_DEV"
Signature · 1 line
2.52.0
author
#3 lore raw

PATCH 3/3 btrfs-progs: add block-group-tree to the default mkfs features

In reply to Qu Wenruo

The block-group-tree feature is already considered safe since v6.6 kernels, and btrfs-progs have also improved its off-line conversion ability (btrfstune --convert-to|from-block-group-tree).

Now it's time to make bgt feature as the default mkfs features. This affects both mkfs and btrfs-convert.

The target merge window is v6.18.

---
 Documentation/mkfs.btrfs.rst | 2 +-
 common/fsfeatures.c          | 2 +-
 common/fsfeatures.h          | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)
Documentation/mkfs.btrfs.rst +1 -1
index 7734354fd6da..b4e23cc1fb24 100644
@@ -424,7 +424,7 @@ free-space-tree
 .. _mkfs-feature-block-group-tree:
 
 block-group-tree
-        (kernel support since 6.1)
+        (default since btrfs-progs v6.19, kernel support since 6.1)
 
         Enable a dedicated b-tree for block group items, this greatly reduces
         mount time for large filesystems due to better data locality that
common/fsfeatures.c +1 -1
index 69a1b3934099..389d19b4d416 100644
@@ -219,7 +219,7 @@ static const struct btrfs_feature mkfs_features[] = {
 		.sysfs_name	= "block_group_tree",
 		VERSION_TO_STRING2(compat, 6,1),
 		VERSION_TO_STRING2(safe, 6,6),
-		VERSION_NULL(default),
+		VERSION_TO_STRING2(default, 6,19),
 		.desc		= "block group tree, more efficient block group tracking to reduce mount time"
 	},
 #if EXPERIMENTAL
common/fsfeatures.h +2 -1
index 3559076ba5dc..3ae8d2a5eed7 100644
@@ -46,7 +46,8 @@ struct btrfs_mkfs_features {
 
 static const struct btrfs_mkfs_features btrfs_mkfs_default_features = {
 	.compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE |
-			   BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID,
+			   BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID |
+			   BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE,
 	.incompat_flags	 = BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF |
 			   BTRFS_FEATURE_INCOMPAT_NO_HOLES |
 			   BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA,
Signature · 1 line
2.52.0
author
#4 lore raw
In reply to Qu Wenruo
Quoted 12 lines · Qu Wenruo

I was planning to do this during v6.12 but forgot it and now the next LTS kernel release is not that far away, it's finally time to make the switch.

The first patch is to update the existing test cases related to disabling no-holes/free-space-tree, which will lead to mkfs/convert failure as block-group-tree requires those two features.

The second patch is a large page-size specific fix, where on 64K page size systems misc/057 will fail due to subpage mount always enables v2 free space cache, resulting later conversion failure to fst.

Quoted 5 lines

The final patch is the one enabling new default block-group-tree feature for mkfs and convert.

Qu Wenruo (3):
btrfs-progs: tests: disable bgt feature for ^no-holes and ^fst runs

Although we can fix the test case for progs selftests, it will be a much more complex work to address all fstests test cases.

I do not think we will really deprecate explicit holes any time soon, thus those fstests will stay.

I'll update the series to automatically disable bgt feature instead. So that mkfs.btrfs -O ^no-holes can still work as expected (no no-holes nor bgt).

Thanks,
Qu

Quoted 16 lines

btrfs-progs: misc-tests: check if free space tree is enabled after
mount
btrfs-progs: add block-group-tree to the default mkfs features

  Documentation/mkfs.btrfs.rst                           |  2 +-
  common/fsfeatures.c                                    |  2 +-
  common/fsfeatures.h                                    |  3 ++-
  tests/cli-tests/009-btrfstune/test.sh                  |  2 +-
  tests/misc-tests/001-btrfstune-features/test.sh        |  9 +++++----
  tests/misc-tests/057-btrfstune-free-space-tree/test.sh | 10 +++++++++-
  6 files changed, 19 insertions(+), 9 deletions(-)

--
2.52.0