mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-22 12:56:49 +00:00
btrfs-progs: scrub status: fix rate units
There's a special case when scrub rate is printed, the device sizes and
rate use different units. The size can be in terabytes while the rate
can be in hundreds of megabytes (contemporary 10-20T disks, 250MB/s).
The sizes use what is set on command line (or human readable by
default), while the rate is always human readable with exception to
the option --raw to provide a way to print the exact numbers without any
conversions.
This got broken in commit ec3c842859
("btrfs-progs: scrub status:
with --si, show rate in metric units") that forced the command line mode
to the rate as well.
Instead of that we need to detect the SI/IEC mode and set it to the
human readable format of rate.
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
cab2eeb9ff
commit
7e0f506241
12
cmds/scrub.c
12
cmds/scrub.c
@ -204,9 +204,10 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_sta
|
||||
pr_verbose(LOG_DEFAULT, "Total to scrub: %s\n",
|
||||
pretty_size_mode(bytes_total, unit_mode));
|
||||
}
|
||||
|
||||
/*
|
||||
* Rate and size units are disproportionate so they are affected only
|
||||
* by --raw, otherwise it's human readable
|
||||
* by --raw, otherwise it's human readable (respecting the SI or IEC mode).
|
||||
*/
|
||||
if (unit_mode == UNITS_RAW) {
|
||||
pr_verbose(LOG_DEFAULT, "Rate: %s/s",
|
||||
@ -218,11 +219,16 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_sta
|
||||
pr_verbose(LOG_DEFAULT, " (some device limits set)");
|
||||
pr_verbose(LOG_DEFAULT, "\n");
|
||||
} else {
|
||||
unsigned int mode = UNITS_HUMAN_DECIMAL;
|
||||
|
||||
if (unit_mode & UNITS_BINARY)
|
||||
mode = UNITS_HUMAN_BINARY;
|
||||
|
||||
pr_verbose(LOG_DEFAULT, "Rate: %s/s",
|
||||
pretty_size_mode(bytes_per_sec, unit_mode));
|
||||
pretty_size_mode(bytes_per_sec, mode));
|
||||
if (limit > 1)
|
||||
pr_verbose(LOG_DEFAULT, " (limit %s/s)",
|
||||
pretty_size_mode(limit, unit_mode));
|
||||
pretty_size_mode(limit, mode));
|
||||
else if (limit == 1)
|
||||
pr_verbose(LOG_DEFAULT, " (some device limits set)");
|
||||
pr_verbose(LOG_DEFAULT, "\n");
|
||||
|
Loading…
Reference in New Issue
Block a user