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