@@ -939,11 +939,38 @@ static DEFINE_SIMPLE_COMMAND(balance_status, "status");
static int cmd_balance_full(const struct cmd_struct *cmd, int argc, char **argv)
{
struct btrfs_ioctl_balance_args args;
+ unsigned start_flags = BALANCE_START_NOWARN;
memset(&args, 0, sizeof(args));
args.flags |= BTRFS_BALANCE_TYPE_MASK;
- return do_balance(argv[1], &args, BALANCE_START_NOWARN);
+ optind = 0;
+ while (1) {
+ enum { GETOPT_VAL_BACKGROUND = 256 };
+ static const struct option longopts[] = {
+ { "background", no_argument, NULL,
+ GETOPT_VAL_BACKGROUND },
+ { "bg", no_argument, NULL, GETOPT_VAL_BACKGROUND },
+ { NULL, 0, NULL, 0 }
+ };
+
+ int opt = getopt_long(argc, argv, "", longopts, NULL);
+ if (opt < 0)
+ break;
+
+ switch (opt) {
+ case GETOPT_VAL_BACKGROUND:
+ start_flags |= BALANCE_START_BACKGROUND;
+ break;
+ default:
+ usage_unknown_option(cmd, argv);
+ }
+ }
+
+ if (check_argc_exact(argc - optind, 1))
+ return 1;
+
+ return do_balance(argv[optind], &args, start_flags);
}
static DEFINE_COMMAND(balance_full, "--full-balance", cmd_balance_full,
NULL, NULL, CMD_HIDDEN);