btrfs-progs: remove old syntax of 'balance /path'

There was a support for a short syntax of 'btrfs balance' that accepted
a path where normally would be the mandatory subcommand. This was a
heuristic and nowadays everybody should be using the
'btrfs balance action' syntax. The warning was in place for a year, it's
time to remove the short syntax completely.

Issue: #517
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-10-24 21:31:18 +02:00
parent c9ebef41ec
commit f7fb93f1ac
2 changed files with 1 additions and 37 deletions

View File

@ -36,7 +36,6 @@
static const char * const balance_cmd_group_usage[] = {
"btrfs balance <command> [options] <path>",
"btrfs balance <path> (deprecated, use 'btrfs balance start')",
NULL
};
@ -862,37 +861,4 @@ static const struct cmd_group balance_cmd_group = {
}
};
static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
{
bool old_syntax = true;
/*
* Exclude all valid subcommands from being potentially confused as path
* for the obsolete syntax: btrfs balance <path>
*/
if (argc == 2) {
for (int i = 0; balance_cmd_group.commands[i] != NULL; i++) {
if (strcmp(argv[1], balance_cmd_group.commands[i]->token) == 0) {
old_syntax = false;
break;
}
}
} else {
old_syntax = false;
}
if (old_syntax) {
struct btrfs_ioctl_balance_args args;
warning("deprecated syntax, please use 'btrfs balance start'");
memset(&args, 0, sizeof(args));
args.flags |= BTRFS_BALANCE_TYPE_MASK;
/* No enqueueing supported for the obsolete syntax */
return do_balance(argv[1], &args, 0, false);
}
return handle_command_group(cmd, argc, argv);
}
DEFINE_COMMAND(balance, "balance", cmd_balance, NULL, &balance_cmd_group, 0);
DEFINE_GROUP_COMMAND_TOKEN(balance);

View File

@ -15,8 +15,6 @@ run_check_mount_test_dev
run_check $SUDO_HELPER "$TOP/btrfs" balance start --full-balance "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" balance start "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" balance --full-balance "$TEST_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" balance "$TEST_MNT"
# grep below can't use -q else this could lead to SIGPIPE
run_check_stdout $SUDO_HELPER "$TOP/btrfs" balance start --background "$TEST_MNT" |