linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Janecek <janecek@ucw.cz>
To: linux-btrfs@vger.kernel.org
Subject: [RFC PATCH 3/3] btrfs-progs: add '--background' option for '--full-balance'
Date: Wed, 8 Apr 2020 15:15:28 +0200	[thread overview]
Message-ID: <20200408131527.GD19101@jkm> (raw)

Add the '--background' option to 'btrfs balance --full-balance'
(without the 'start').
---
 cmds/balance.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/cmds/balance.c b/cmds/balance.c
index 3d4deb27..506016ba 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -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);
-- 
2.26.0


                 reply	other threads:[~2020-04-08 13:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200408131527.GD19101@jkm \
    --to=janecek@ucw.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).