]> git.proxmox.com Git - mirror_zfs.git/blobdiff - lib/libzpool/util.c
Add -lhHpw options to "zpool iostat" for avg latency, histograms, & queues
[mirror_zfs.git] / lib / libzpool / util.c
index 231043d75bed52340313aa467078e72a6313961c..7a0748c0322685835dd7a18770f1aac0cd9d58cc 100644 (file)
@@ -67,7 +67,7 @@ static void
 show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
 {
        vdev_stat_t *vs;
-       vdev_stat_t v0 = { 0 };
+       vdev_stat_t *v0 = { 0 };
        uint64_t sec;
        uint64_t is_log = 0;
        nvlist_t **child;
@@ -76,6 +76,8 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
        char rops[6], wops[6], rbytes[6], wbytes[6], rerr[6], werr[6], cerr[6];
        char *prefix = "";
 
+       v0 = umem_zalloc(sizeof (*v0), UMEM_NOFAIL);
+
        if (indent == 0 && desc != NULL) {
                (void) printf("                           "
                    " capacity   operations   bandwidth  ---- errors ----\n");
@@ -91,7 +93,7 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
 
                if (nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
                    (uint64_t **)&vs, &c) != 0)
-                       vs = &v0;
+                       vs = v0;
 
                sec = MAX(1, vs->vs_timestamp / NANOSEC);
 
@@ -114,6 +116,7 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
                    vs->vs_space ? 6 : 0, vs->vs_space ? avail : "",
                    rops, wops, rbytes, wbytes, rerr, werr, cerr);
        }
+       free(v0);
 
        if (nvlist_lookup_nvlist_array(nv, ctype, &child, &children) != 0)
                return;