forked from Mirrors/btrfs-progs
btrfs-progs: btrfstune: force to set seeding flags
Now we can use -f with -S option when setting seeding flags or clearing seeding flags Reported-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com> [updated docs] Signed-off-by: David Sterba <dsterba@suse.cz>master
parent
188e79e2fc
commit
f66d17814b
|
@ -25,7 +25,8 @@ Enable extended inode refs.
|
||||||
-x::
|
-x::
|
||||||
Enable skinny metadata extent refs.
|
Enable skinny metadata extent refs.
|
||||||
-f::
|
-f::
|
||||||
Allow dangerous changes, e.g. clear the seeding flag
|
Allow dangerous changes, e.g. clear the seeding flag. Make sure that you are
|
||||||
|
aware of the dangers.
|
||||||
|
|
||||||
When mounting the new device, btrfs will check whether the seeding flag is set
|
When mounting the new device, btrfs will check whether the seeding flag is set
|
||||||
when try to open seeding device. If the user clears the seeding flag of the
|
when try to open seeding device. If the user clears the seeding flag of the
|
||||||
|
|
10
btrfstune.c
10
btrfstune.c
|
@ -33,6 +33,7 @@
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
static char *device;
|
static char *device;
|
||||||
|
static int force = 0;
|
||||||
|
|
||||||
static int update_seeding_flag(struct btrfs_root *root, int set_flag)
|
static int update_seeding_flag(struct btrfs_root *root, int set_flag)
|
||||||
{
|
{
|
||||||
|
@ -44,8 +45,10 @@ static int update_seeding_flag(struct btrfs_root *root, int set_flag)
|
||||||
super_flags = btrfs_super_flags(disk_super);
|
super_flags = btrfs_super_flags(disk_super);
|
||||||
if (set_flag) {
|
if (set_flag) {
|
||||||
if (super_flags & BTRFS_SUPER_FLAG_SEEDING) {
|
if (super_flags & BTRFS_SUPER_FLAG_SEEDING) {
|
||||||
fprintf(stderr, "seeding flag is already set on %s\n",
|
if (force)
|
||||||
device);
|
return 0;
|
||||||
|
else
|
||||||
|
fprintf(stderr, "seeding flag is already set on %s\n", device);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
super_flags |= BTRFS_SUPER_FLAG_SEEDING;
|
super_flags |= BTRFS_SUPER_FLAG_SEEDING;
|
||||||
|
@ -104,7 +107,7 @@ static void print_usage(void)
|
||||||
fprintf(stderr, "\t-S value\tpositive value will enable seeding, zero to disable, negative is not allowed\n");
|
fprintf(stderr, "\t-S value\tpositive value will enable seeding, zero to disable, negative is not allowed\n");
|
||||||
fprintf(stderr, "\t-r \t\tenable extended inode refs\n");
|
fprintf(stderr, "\t-r \t\tenable extended inode refs\n");
|
||||||
fprintf(stderr, "\t-x \t\tenable skinny metadata extent refs\n");
|
fprintf(stderr, "\t-x \t\tenable skinny metadata extent refs\n");
|
||||||
fprintf(stderr, "\t-f \t\tforce to clear flags, make sure that you are aware of the dangers\n");
|
fprintf(stderr, "\t-f \t\tforce to set or clear flags, make sure that you are aware of the dangers\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -116,7 +119,6 @@ int main(int argc, char *argv[])
|
||||||
int seeding_flag = 0;
|
int seeding_flag = 0;
|
||||||
u64 seeding_value = 0;
|
u64 seeding_value = 0;
|
||||||
int skinny_flag = 0;
|
int skinny_flag = 0;
|
||||||
int force = 0;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
|
Loading…
Reference in New Issue