mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-27 16:42:17 +00:00
btrfs-progs: balance convert: add a warning and countdown for RAID56 conversion
Similar to the mkfs warning, add a warning to btrfs balance convert options, with a countdown to allow the user to have time to cancel the operation. Issue: #265 Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
73487311e9
commit
1ed5db8db4
@ -526,6 +526,7 @@ static int cmd_balance_start(const struct cmd_struct *cmd,
|
||||
int background = 0;
|
||||
bool enqueue = false;
|
||||
unsigned start_flags = 0;
|
||||
bool warned = false;
|
||||
int i;
|
||||
|
||||
memset(&args, 0, sizeof(args));
|
||||
@ -632,11 +633,37 @@ static int cmd_balance_start(const struct cmd_struct *cmd,
|
||||
|
||||
/* soft makes sense only when convert for corresponding type is set */
|
||||
for (i = 0; ptrs[i]; i++) {
|
||||
int delay = 10;
|
||||
|
||||
if ((ptrs[i]->flags & BTRFS_BALANCE_ARGS_SOFT) &&
|
||||
!(ptrs[i]->flags & BTRFS_BALANCE_ARGS_CONVERT)) {
|
||||
error("'soft' option can be used only when converting profiles");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(ptrs[i]->flags & BTRFS_BALANCE_ARGS_CONVERT))
|
||||
continue;
|
||||
|
||||
if (!(ptrs[i]->flags & (BTRFS_BLOCK_GROUP_RAID6 |
|
||||
BTRFS_BLOCK_GROUP_RAID5)))
|
||||
continue;
|
||||
|
||||
if (warned)
|
||||
continue;
|
||||
|
||||
warned = true;
|
||||
printf("WARNING:\n\n");
|
||||
printf("\tRAID5/6 support has known problems and is strongly discouraged\n");
|
||||
printf("\tto be used besides testing or evaluation. It is recommended that\n");
|
||||
printf("\tyou use one of the other RAID profiles.\n");
|
||||
printf("\tThe operation will continue in %d seconds.\n", delay);
|
||||
printf("\tUse Ctrl-C to stop.\n");
|
||||
while (delay) {
|
||||
printf("%2d", delay--);
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
}
|
||||
printf("\nStarting conversion to RAID5/6.\n");
|
||||
}
|
||||
|
||||
if (!(start_flags & BALANCE_START_FILTERS) && !(start_flags & BALANCE_START_NOWARN)) {
|
||||
|
Loading…
Reference in New Issue
Block a user