@@ -241,7 +241,7 @@ cmds_objects = cmds/subvolume.o cmds/subvolume-list.o \
cmds/inspect-dump-super.o cmds/inspect-tree-stats.o cmds/filesystem-du.o \
cmds/reflink.o cmds/tune.o \
mkfs/common.o check/mode-common.o check/mode-lowmem.o \
- check/clear-cache.o
+ check/clear-cache.o tune/convert-bgt.o
libbtrfs_objects = \
kernel-lib/rbtree.o \
@@ -24,6 +24,7 @@
#include "kernel-shared/disk-io.h"
#include "kernel-shared/transaction.h"
#include "kernel-shared/free-space-tree.h"
+#include "tune/tune.h"
static const char * const cmd_tune_set_usage[] = {
"btrfs tune set <feature> [<device>]",
@@ -68,6 +69,14 @@ static const struct btrfs_feature set_features[] = {
VERSION_TO_STRING2(safe, 4,9),
VERSION_TO_STRING2(default, 5,15),
.desc = "free space tree (space_cache=v2)"
+ }, {
+ .name = "block-group-tree",
+ .compat_ro_flag = BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE,
+ .sysfs_name = "block_group_tree",
+ VERSION_TO_STRING2(compat, 6,1),
+ VERSION_NULL(safe),
+ VERSION_NULL(default),
+ .desc = "block group tree to reduce mount time"
},
/* Keep this one last */
{
@@ -254,6 +263,22 @@ static int cmd_tune_set(const struct cmd_struct *cmd, int argc, char **argv)
error("failed to convert the filesystem to free-space-tree feature");
goto out;
}
+ if (!strcmp(feature, "block-group-tree")) {
+ if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE)) {
+ error("filesystem already has block-group-tree feature");
+ ret = -EINVAL;
+ goto out;
+ }
+ if (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID)) {
+ error("the filesystem doesn't have free-space-tree feature, please enable it first");
+ ret = -EINVAL;
+ goto out;
+ }
+ ret = convert_to_bg_tree(fs_info);
+ if (ret < 0)
+ error("failed to convert the filesystem to free-space-tree feature");
+ goto out;
+ }
out:
if (fs_info)
Most of the code is reusing the existing code from btrfs-tune, only needs to add extra linkage dependency on tune/convert-bgt.o. Signed-off-by: Qu Wenruo <wqu@suse.com> --- Makefile | 2 +- cmds/tune.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-)