diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zdb/zdb.c | 2 | ||||
-rw-r--r-- | cmd/zfs/zfs_main.c | 40 | ||||
-rw-r--r-- | cmd/zpool/zpool_main.c | 17 |
3 files changed, 41 insertions, 18 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index b020b3783..6c4071060 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3077,7 +3077,7 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, int sec_remaining = (zcb->zcb_totalasize - bytes) / 1024 / kb_per_sec; - zfs_nicenum(bytes, buf, sizeof (buf)); + zfs_nicebytes(bytes, buf, sizeof (buf)); (void) fprintf(stderr, "\r%5s completed (%4dMB/s) " "estimated time remaining: %uhr %02umin %02usec ", diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index afaabdfab..6ac26fdaf 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -1313,7 +1313,7 @@ zfs_do_destroy(int argc, char **argv) if (cb.cb_verbose) { char buf[16]; - zfs_nicenum(cb.cb_snapused, buf, sizeof (buf)); + zfs_nicebytes(cb.cb_snapused, buf, sizeof (buf)); if (cb.cb_parsable) { (void) printf("reclaim\t%llu\n", (u_longlong_t)cb.cb_snapused); @@ -2549,11 +2549,17 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space) } /* Calculate/update width of USED/QUOTA fields */ - if (cb->cb_nicenum) - zfs_nicenum(space, sizebuf, sizeof (sizebuf)); - else + if (cb->cb_nicenum) { + if (prop == ZFS_PROP_USERUSED || prop == ZFS_PROP_GROUPUSED || + prop == ZFS_PROP_USERQUOTA || prop == ZFS_PROP_GROUPQUOTA) { + zfs_nicebytes(space, sizebuf, sizeof (sizebuf)); + } else { + zfs_nicenum(space, sizebuf, sizeof (sizebuf)); + } + } else { (void) snprintf(sizebuf, sizeof (sizebuf), "%llu", (u_longlong_t)space); + } sizelen = strlen(sizebuf); if (prop == ZFS_PROP_USERUSED || prop == ZFS_PROP_GROUPUSED) { propname = "used"; @@ -2646,22 +2652,36 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types, break; case USFIELD_USED: case USFIELD_QUOTA: + if (type == DATA_TYPE_UINT64) { + if (parsable) { + (void) sprintf(valstr, "%llu", + (u_longlong_t)val64); + strval = valstr; + } else if (field == USFIELD_QUOTA && + val64 == 0) { + strval = "none"; + } else { + zfs_nicebytes(val64, valstr, + sizeof (valstr)); + strval = valstr; + } + } + break; case USFIELD_OBJUSED: case USFIELD_OBJQUOTA: if (type == DATA_TYPE_UINT64) { if (parsable) { (void) sprintf(valstr, "%llu", (u_longlong_t)val64); + strval = valstr; + } else if (field == USFIELD_OBJQUOTA && + val64 == 0) { + strval = "none"; } else { zfs_nicenum(val64, valstr, sizeof (valstr)); - } - if ((field == USFIELD_QUOTA || - field == USFIELD_OBJQUOTA) && - strcmp(valstr, "0") == 0) - strval = "none"; - else strval = valstr; + } } break; } 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); |