mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-27 18:34:22 +03:00
Dashes for zero latency values in zpool iostat -p
This prints dashes instead of zeros for zero latency values in 'zpool iostat -p'. You'll get zero latencies reported when the disk is idle, but technically a zero latency is invalid, since you can't measure the latency of doing nothing. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #6210
This commit is contained in:
parent
d9ad3fea3b
commit
29eb494285
@ -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);
|
nva = calc_and_alloc_stats_ex(names, ARRAY_SIZE(names), oldnv, newnv);
|
||||||
|
|
||||||
if (cb->cb_literal)
|
if (cb->cb_literal)
|
||||||
format = ZFS_NICENUM_RAW;
|
format = ZFS_NICENUM_RAWTIME;
|
||||||
else
|
else
|
||||||
format = ZFS_NICENUM_TIME;
|
format = ZFS_NICENUM_TIME;
|
||||||
|
|
||||||
|
@ -775,11 +775,21 @@ extern int zfs_unshareall(zfs_handle_t *);
|
|||||||
extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
|
extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
|
||||||
void *, void *, int, zfs_share_op_t);
|
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 {
|
enum zfs_nicenum_format {
|
||||||
ZFS_NICENUM_1024 = 0,
|
ZFS_NICENUM_1024 = 0,
|
||||||
ZFS_NICENUM_BYTES = 1,
|
ZFS_NICENUM_BYTES = 1,
|
||||||
ZFS_NICENUM_TIME = 2,
|
ZFS_NICENUM_TIME = 2,
|
||||||
ZFS_NICENUM_RAW = 3
|
ZFS_NICENUM_RAW = 3,
|
||||||
|
ZFS_NICENUM_RAWTIME = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -623,9 +623,14 @@ zfs_nicenum_format(uint64_t num, char *buf, size_t buflen,
|
|||||||
if (format == ZFS_NICENUM_RAW) {
|
if (format == ZFS_NICENUM_RAW) {
|
||||||
snprintf(buf, buflen, "%llu", (u_longlong_t)num);
|
snprintf(buf, buflen, "%llu", (u_longlong_t)num);
|
||||||
return;
|
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]) {
|
while (n >= k_unit[format] && index < units_len[format]) {
|
||||||
n /= k_unit[format];
|
n /= k_unit[format];
|
||||||
index++;
|
index++;
|
||||||
@ -633,7 +638,7 @@ zfs_nicenum_format(uint64_t num, char *buf, size_t buflen,
|
|||||||
|
|
||||||
u = units[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)) {
|
if ((format == ZFS_NICENUM_TIME) && (num == 0)) {
|
||||||
(void) snprintf(buf, buflen, "-");
|
(void) snprintf(buf, buflen, "-");
|
||||||
} else if ((index == 0) || ((num %
|
} else if ((index == 0) || ((num %
|
||||||
|
Loading…
Reference in New Issue
Block a user