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;
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
};
/*
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++;
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 %