btrfs-progs: balance: use pr_stderr for messages

Replace fprintf(stderr, ...) by the level-aware helper. No change for
commands that don't have the global -q/-v options, otherwise the output
can be quieted.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-10-05 14:27:57 +02:00
parent be3193371e
commit 2c8c7ca6da

View File

@ -330,15 +330,15 @@ static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args,
if (errno == ECANCELED) {
if (args->state & BTRFS_BALANCE_STATE_PAUSE_REQ)
fprintf(stderr, "balance paused by user\n");
pr_stderr(LOG_DEFAULT, "balance paused by user\n");
if (args->state & BTRFS_BALANCE_STATE_CANCEL_REQ)
fprintf(stderr, "balance canceled by user\n");
pr_stderr(LOG_DEFAULT, "balance canceled by user\n");
ret = 0;
} else {
error("error during balancing '%s': %m", path);
if (errno != EINPROGRESS)
fprintf(stderr,
"There may be more info in syslog - try dmesg | tail\n");
pr_stderr(LOG_DEFAULT,
"There may be more info in syslog - try dmesg | tail\n");
ret = 1;
}
} else if (ret > 0) {
@ -716,9 +716,9 @@ static int cmd_balance_resume(const struct cmd_struct *cmd,
if (ret < 0) {
if (errno == ECANCELED) {
if (args.state & BTRFS_BALANCE_STATE_PAUSE_REQ)
fprintf(stderr, "balance paused by user\n");
pr_stderr(LOG_DEFAULT, "balance paused by user\n");
if (args.state & BTRFS_BALANCE_STATE_CANCEL_REQ)
fprintf(stderr, "balance canceled by user\n");
pr_stderr(LOG_DEFAULT, "balance canceled by user\n");
} else if (errno == ENOTCONN || errno == EINPROGRESS) {
error("balance resume on '%s' failed: %s", path,
(errno == ENOTCONN) ? "Not in progress" :