Transpire global --verbose option down to the btrfs balance status
sub-command.
Suggested-by: David Sterba <dsterba@xxxxxxxx>
Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
---
v3: update help and documentation
v2: Use new helper functions and defines
HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET
bconf_be_verbose(), bconf_be_quiet()
No need to init bconf.verbose in the sub command.
Documentation/btrfs-balance.asciidoc | 3 ++-
cmds/balance.c | 10 ++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Documentation/btrfs-balance.asciidoc b/Documentation/btrfs-balance.asciidoc
index 4d81692a60d8..2dccb1cc523e 100644
--- a/Documentation/btrfs-balance.asciidoc
+++ b/Documentation/btrfs-balance.asciidoc
@@ -110,7 +110,8 @@ start the process that calls the kernel ioctl
*status* [-v] <path>::
Show status of running or paused balance.
+
-If '-v' option is given, output will be verbose.
+If '-v' option is given, output will be verbose. This option is merged to the
+global verbose option.
FILTERS
-------
diff --git a/cmds/balance.c b/cmds/balance.c
index 73bfedba1405..4b4adc2ceae6 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -830,7 +830,10 @@ static const char * const cmd_balance_status_usage[] = {
"btrfs balance status [-v] <path>",
"Show status of running or paused balance",
"",
- "-v|--verbose be verbose",
+ "-v|--verbose be verbose. This option is merged to the global",
+ " verbose option.",
+ HELPINFO_INSERT_GLOBALS,
+ HELPINFO_INSERT_VERBOSE,
NULL
};
@@ -847,7 +850,6 @@ static int cmd_balance_status(const struct cmd_struct *cmd,
const char *path;
DIR *dirstream = NULL;
int fd;
- int verbose = 0;
int ret;
optind = 0;
@@ -864,7 +866,7 @@ static int cmd_balance_status(const struct cmd_struct *cmd,
switch (opt) {
case 'v':
- verbose = 1;
+ bconf_be_verbose();
break;
default:
usage_unknown_option(cmd, argv);
@@ -910,7 +912,7 @@ static int cmd_balance_status(const struct cmd_struct *cmd,
(unsigned long long)args.stat.considered,
100 * (1 - (float)args.stat.completed/args.stat.expected));
- if (verbose)
+ if (bconf.verbose > BTRFS_BCONF_QUIET)
dump_ioctl_balance_args(&args);
ret = 1;
--
2.25.1