diff options
author | LOLi <[email protected]> | 2017-05-02 22:43:53 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-05-02 13:43:53 -0700 |
commit | e7fbeb606a18b9f04daadddc19b9c4f9a9b34841 (patch) | |
tree | 8b9e4a464343553bc5d8b01ca1dd25b917a73990 /cmd/zpool | |
parent | 03b60eee78b0bf1125878dbad0fcffd717def61f (diff) |
Add zfs_nicebytes() to print human-readable sizes
* Add zfs_nicebytes() to print human-readable sizes
Some 'zfs', 'zpool' and 'zdb' output strings can be confusing to the
user when no units are specified. This add a new zfs_nicenum_format
"ZFS_NICENUM_BYTES" used to print bytes in their human-readable form.
Additionally, update some test cases to use machine-parsable 'zfs get'.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #2414
Closes #3185
Closes #3594
Closes #6032
Diffstat (limited to 'cmd/zpool')
-rw-r--r-- | cmd/zpool/zpool_main.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 67b0ab058..e8c8dba79 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -5730,7 +5730,7 @@ print_scan_status(pool_scan_stat_t *ps) start = ps->pss_start_time; end = ps->pss_end_time; - zfs_nicenum(ps->pss_processed, processed_buf, sizeof (processed_buf)); + zfs_nicebytes(ps->pss_processed, processed_buf, sizeof (processed_buf)); assert(ps->pss_func == POOL_SCAN_SCRUB || ps->pss_func == POOL_SCAN_RESILVER); @@ -5792,9 +5792,9 @@ print_scan_status(pool_scan_stat_t *ps) mins_left = ((total - examined) / rate) / 60; hours_left = mins_left / 60; - zfs_nicenum(examined, examined_buf, sizeof (examined_buf)); - zfs_nicenum(total, total_buf, sizeof (total_buf)); - zfs_nicenum(rate, rate_buf, sizeof (rate_buf)); + zfs_nicebytes(examined, examined_buf, sizeof (examined_buf)); + zfs_nicebytes(total, total_buf, sizeof (total_buf)); + zfs_nicebytes(rate, rate_buf, sizeof (rate_buf)); /* * do not print estimated time if hours_left is more than 30 days @@ -5897,6 +5897,7 @@ print_dedup_stats(nvlist_t *config) ddt_stat_t *dds; ddt_object_t *ddo; uint_t c; + char dspace[6], mspace[6]; /* * If the pool was faulted then we may not have been able to @@ -5914,10 +5915,12 @@ print_dedup_stats(nvlist_t *config) return; } - (void) printf("DDT entries %llu, size %llu on disk, %llu in core\n", + zfs_nicebytes(ddo->ddo_dspace, dspace, sizeof (dspace)); + zfs_nicebytes(ddo->ddo_mspace, mspace, sizeof (mspace)); + (void) printf("DDT entries %llu, size %s on disk, %s in core\n", (u_longlong_t)ddo->ddo_count, - (u_longlong_t)ddo->ddo_dspace, - (u_longlong_t)ddo->ddo_mspace); + dspace, + mspace); verify(nvlist_lookup_uint64_array(config, ZPOOL_CONFIG_DDT_STATS, (uint64_t **)&dds, &c) == 0); |