public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Sidong Yang <realwakka@gmail.com>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Cc: Sidong Yang <realwakka@gmail.com>
Subject: [PATCH] btrfs-progs: balance: print warn mesg in old command
Date: Sun, 31 Oct 2021 02:21:52 +0000	[thread overview]
Message-ID: <20211031022152.41730-1-realwakka@gmail.com> (raw)

This patch makes old balance command to print warn mesg same as in start
command. It makes a function that print warn mesg and commands use that
function.

Issue: #411

Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
 cmds/balance.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/cmds/balance.c b/cmds/balance.c
index 7abc69d9..8d8db8a2 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -303,6 +303,25 @@ enum {
 	BALANCE_START_NOWARN  = 1 << 1
 };
 
+static void print_start_warn_mesg()
+{
+	int delay = 10;
+
+	printf("WARNING:\n\n");
+	printf("\tFull balance without filters requested. This operation is very\n");
+	printf("\tintense and takes potentially very long. It is recommended to\n");
+	printf("\tuse the balance filters to narrow down the scope of balance.\n");
+	printf("\tUse 'btrfs balance start --full-balance' option to skip this\n");
+	printf("\twarning. The operation will start in %d seconds.\n", delay);
+	printf("\tUse Ctrl-C to stop it.\n");
+	while (delay) {
+		printf("%2d", delay--);
+		fflush(stdout);
+		sleep(1);
+	}
+	printf("\nStarting balance without any filters.\n");
+}
+
 static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args,
 		      unsigned flags, bool enqueue)
 {
@@ -548,21 +567,7 @@ static int cmd_balance_start(const struct cmd_struct *cmd,
 	}
 
 	if (!(start_flags & BALANCE_START_FILTERS) && !(start_flags & BALANCE_START_NOWARN)) {
-		int delay = 10;
-
-		printf("WARNING:\n\n");
-		printf("\tFull balance without filters requested. This operation is very\n");
-		printf("\tintense and takes potentially very long. It is recommended to\n");
-		printf("\tuse the balance filters to narrow down the scope of balance.\n");
-		printf("\tUse 'btrfs balance start --full-balance' option to skip this\n");
-		printf("\twarning. The operation will start in %d seconds.\n", delay);
-		printf("\tUse Ctrl-C to stop it.\n");
-		while (delay) {
-			printf("%2d", delay--);
-			fflush(stdout);
-			sleep(1);
-		}
-		printf("\nStarting balance without any filters.\n");
+		print_start_warn_mesg();
 	}
 
 	if (force)
@@ -886,6 +891,8 @@ static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
 		memset(&args, 0, sizeof(args));
 		args.flags |= BTRFS_BALANCE_TYPE_MASK;
 
+		print_start_warn_mesg();
+
 		/* No enqueueing supported for the obsolete syntax */
 		return do_balance(argv[1], &args, 0, false);
 	}
-- 
2.25.1


             reply	other threads:[~2021-10-31  2:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31  2:21 Sidong Yang [this message]
2021-10-31 11:28 ` [PATCH] btrfs-progs: balance: print warn mesg in old command Qu Wenruo
2021-10-31 12:55   ` Sidong Yang

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=20211031022152.41730-1-realwakka@gmail.com \
    --to=realwakka@gmail.com \
    --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