summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/zpool/zpool_main.c2
-rw-r--r--include/libzfs.h12
-rw-r--r--lib/libzfs/libzfs_util.c9
3 files changed, 19 insertions, 4 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 5fccd754b..2a68fe66f 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -3460,7 +3460,7 @@ print_iostat_latency(iostat_cbdata_t *cb, nvlist_t *oldnv,
nva = calc_and_alloc_stats_ex(names, ARRAY_SIZE(names), oldnv, newnv);
if (cb->cb_literal)
- format = ZFS_NICENUM_RAW;
+ format = ZFS_NICENUM_RAWTIME;
else
format = ZFS_NICENUM_TIME;
diff --git a/include/libzfs.h b/include/libzfs.h
index c634ccd86..62a61406a 100644
--- a/include/libzfs.h
+++ b/include/libzfs.h
@@ -775,11 +775,21 @@ extern int zfs_unshareall(zfs_handle_t *);
extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
void *, void *, int, zfs_share_op_t);
+/*
+ * Formats for iostat numbers. Examples: "12K", "30ms", "4B", "2321234", "-".
+ *
+ * ZFS_NICENUM_1024: Print kilo, mega, tera, peta, exa..
+ * ZFS_NICENUM_BYTES: Print single bytes ("13B"), kilo, mega, tera...
+ * ZFS_NICENUM_TIME: Print nanosecs, microsecs, millisecs, seconds...
+ * ZFS_NICENUM_RAW: Print the raw number without any formatting
+ * ZFS_NICENUM_RAWTIME: Same as RAW, but print dashes ('-') for zero.
+ */
enum zfs_nicenum_format {
ZFS_NICENUM_1024 = 0,
ZFS_NICENUM_BYTES = 1,
ZFS_NICENUM_TIME = 2,
- ZFS_NICENUM_RAW = 3
+ ZFS_NICENUM_RAW = 3,
+ ZFS_NICENUM_RAWTIME = 4
};
/*
diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c
index c281f9eb3..1fb7b5ee5 100644
--- a/lib/libzfs/libzfs_util.c
+++ b/lib/libzfs/libzfs_util.c
@@ -623,9 +623,14 @@ zfs_nicenum_format(uint64_t num, char *buf, size_t buflen,
if (format == ZFS_NICENUM_RAW) {
snprintf(buf, buflen, "%llu", (u_longlong_t)num);
return;
+ } else if (format == ZFS_NICENUM_RAWTIME && num > 0) {
+ snprintf(buf, buflen, "%llu", (u_longlong_t)num);
+ return;
+ } else if (format == ZFS_NICENUM_RAWTIME && num == 0) {
+ snprintf(buf, buflen, "%s", "-");
+ return;
}
-
while (n >= k_unit[format] && index < units_len[format]) {
n /= k_unit[format];
index++;
@@ -633,7 +638,7 @@ zfs_nicenum_format(uint64_t num, char *buf, size_t buflen,
u = units[format][index];
- /* Don't print 0ns times */
+ /* Don't print zero latencies since they're invalid */
if ((format == ZFS_NICENUM_TIME) && (num == 0)) {
(void) snprintf(buf, buflen, "-");
} else if ((index == 0) || ((num %