linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 4/7] btrfs-progs: cmds/tune: add set support for block-group-tree feature
Date: Tue,  5 Sep 2023 15:51:46 +0800	[thread overview]
Message-ID: <663028b35ff393f8aa88126edba8aa2763a11a22.1693900169.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1693900169.git.wqu@suse.com>

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(-)

diff --git a/Makefile b/Makefile
index 9857daaa42ac..45d64129352c 100644
--- a/Makefile
+++ b/Makefile
@@ -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	\
diff --git a/cmds/tune.c b/cmds/tune.c
index 9906cde393f4..76ad9ebfc39e 100644
--- a/cmds/tune.c
+++ b/cmds/tune.c
@@ -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)
-- 
2.42.0


  parent reply	other threads:[~2023-09-05 16:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05  7:51 [PATCH 0/7] btrfs-progs: cmds/tune: add set/clear features Qu Wenruo
2023-09-05  7:51 ` [PATCH 1/7] btrfs-progs: export btrfs_feature structure Qu Wenruo
2023-09-21  0:32   ` Anand Jain
2023-09-21 21:35     ` Qu Wenruo
2023-09-05  7:51 ` [PATCH 2/7] btrfs-progs: cmds: add "btrfs tune set" subcommand group Qu Wenruo
2023-09-21  0:53   ` Anand Jain
2023-09-21  2:13     ` Qu Wenruo
2023-10-13 17:47     ` David Sterba
2023-10-30  8:26       ` Anand Jain
2023-09-05  7:51 ` [PATCH 3/7] btrfs-progs: cmds/tune: add set support for free-space-tree feature Qu Wenruo
2023-09-05  7:51 ` Qu Wenruo [this message]
2023-09-05  7:51 ` [PATCH 5/7] btrfs-progs: cmds/tune: add set support for seeding device Qu Wenruo
2023-09-05  7:51 ` [PATCH 6/7] btrfs-progs: cmds/tune: add "btrfs tune clear" subcommand Qu Wenruo
2023-09-05  7:51 ` [PATCH 7/7] btrfs-progs: tests/cli: add a test case for "btrfs tune" subcommand Qu Wenruo
2023-09-20 23:03 ` [PATCH 0/7] btrfs-progs: cmds/tune: add set/clear features Qu Wenruo
2023-09-21 22:33 ` waxhead
2023-09-21 22:53   ` Qu Wenruo
2023-10-13 17:55   ` David Sterba
2023-10-13 18:50 ` David Sterba
2023-10-13 20:53   ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=663028b35ff393f8aa88126edba8aa2763a11a22.1693900169.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).