From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 5/7] btrfs-progs: cmds/tune: add set support for seeding device
Date: Tue, 5 Sep 2023 15:51:47 +0800 [thread overview]
Message-ID: <4b517844b96bab15e8c446da25fe24e6ec4cf2ce.1693900169.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1693900169.git.wqu@suse.com>
With the new "btrfs tune set" command, seeding device support can be
added just like all other features.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Makefile | 2 +-
cmds/tune.c | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 45d64129352c..b502336d7441 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 tune/convert-bgt.o
+ check/clear-cache.o tune/convert-bgt.o tune/seeding.o
libbtrfs_objects = \
kernel-lib/rbtree.o \
diff --git a/cmds/tune.c b/cmds/tune.c
index 76ad9ebfc39e..195d0a235fc8 100644
--- a/cmds/tune.c
+++ b/cmds/tune.c
@@ -19,6 +19,7 @@
#include "cmds/commands.h"
#include "check/clear-cache.h"
#include "common/help.h"
+#include "common/utils.h"
#include "common/fsfeatures.h"
#include "kernel-shared/messages.h"
#include "kernel-shared/disk-io.h"
@@ -30,6 +31,7 @@ static const char * const cmd_tune_set_usage[] = {
"btrfs tune set <feature> [<device>]",
"Set/enable specified feature for the unmounted filesystem",
"",
+ OPTLINE("-f", "force dangerous operations."),
HELPINFO_INSERT_GLOBALS,
HELPINFO_INSERT_VERBOSE,
NULL,
@@ -77,6 +79,13 @@ static const struct btrfs_feature set_features[] = {
VERSION_NULL(safe),
VERSION_NULL(default),
.desc = "block group tree to reduce mount time"
+ }, {
+ .name = "seed",
+ .sysfs_name = NULL,
+ VERSION_TO_STRING3(compat, 2,6,29),
+ VERSION_NULL(safe),
+ VERSION_NULL(default),
+ .desc = "seeding device support"
},
/* Keep this one last */
{
@@ -190,15 +199,19 @@ static int cmd_tune_set(const struct cmd_struct *cmd, int argc, char **argv)
struct open_ctree_args oca = { 0 };
char *feature;
char *path;
+ bool force = false;
int ret = 0;
optind = 0;
while (1) {
- int c = getopt(argc, argv, "");
+ int c = getopt(argc, argv, "f");
if (c < 0)
break;
switch (c) {
+ case 'f':
+ force = true;
+ break;
default:
usage_unknown_option(cmd, argv);
}
@@ -279,6 +292,26 @@ 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, "seed")) {
+ if (btrfs_fs_incompat(fs_info, METADATA_UUID)) {
+ error("SEED flag cannot be changed on a metadata-uuid changed fs");
+ ret = -EINVAL;
+ goto out;
+ }
+ if (!force) {
+ warning(
+"this is dangerous, clearing the seeding flag may cause the derived device not to be mountable!");
+ ret = ask_user("We are going to clear the seeding flag, are you sure?");
+ if (!ret) {
+ error("clear seeding flag canceled");
+ ret = -EINVAL;
+ goto out;
+ }
+ }
+
+ ret = update_seeding_flag(fs_info->tree_root, path, 1, force);
+ goto out;
+ }
out:
if (fs_info)
--
2.42.0
next prev 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 ` [PATCH 4/7] btrfs-progs: cmds/tune: add set support for block-group-tree feature Qu Wenruo
2023-09-05 7:51 ` Qu Wenruo [this message]
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=4b517844b96bab15e8c446da25fe24e6ec4cf2ce.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).