From 74d424790b8e2aa1acdc5ea00c093e6e34ef7f01 Mon Sep 17 00:00:00 2001 From: Haakan T Johansson Date: Sun, 11 Sep 2016 14:35:23 +0200 Subject: [PATCH] zpool iostat tells which rotor vector each vdev is part of. For the time being, abusing the -k flag (of the previous commit). --- cmd/zpool/zpool_main.c | 22 +++++++++++++++++++++- include/sys/fs/zfs.h | 3 +++ module/zfs/vdev.c | 4 ++++ module/zfs/vdev_label.c | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 66d744ae32a1..63e43857f052 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -2803,7 +2803,6 @@ print_iostat_labels(iostat_cbdata_t *cb, unsigned int force_column_width, } } - printf("\n"); } /* @@ -2874,6 +2873,10 @@ print_iostat_dashes(iostat_cbdata_t *cb, unsigned int force_column_width, "--------------------"); } } + + if (cb->cb_flags & IOS_KIND_M) + printf(" ---"); + printf("\n"); } @@ -2916,10 +2919,14 @@ print_iostat_header_impl(iostat_cbdata_t *cb, unsigned int force_column_width, print_iostat_labels(cb, force_column_width, iostat_top_labels); + printf("\n"); printf("%-*s", namewidth, title); print_iostat_labels(cb, force_column_width, iostat_bottom_labels); + if (cb->cb_flags & IOS_KIND_M) + printf(" nrv"); + printf("\n"); print_iostat_separator_impl(cb, force_column_width); } @@ -3370,6 +3377,8 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv, int ret = 0; uint64_t tdelta; double scale; + nvlist_t *nvx; + uint64_t nrotor = (uint64_t)-1; calcvs = safe_malloc(sizeof (*calcvs)); @@ -3452,6 +3461,17 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv, print_iostat_histos(cb, oldnv, newnv, scale, name); } + if (nvlist_lookup_nvlist(newnv, ZPOOL_CONFIG_VDEV_STATS_EX, &nvx) == 0) + nvlist_lookup_uint64(nvx, ZPOOL_CONFIG_VDEV_NROTOR, + &nrotor); + + if (cb->cb_flags & IOS_KIND_M) { + if (nrotor != (uint64_t)-1) + (void) printf(" %d", (int)nrotor); + else + (void) printf(" -"); + } + if (cb->vcdl != NULL) { char *path; if (nvlist_lookup_string(newnv, ZPOOL_CONFIG_PATH, diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index ee0cf42c794a..53814a2571f9 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -598,6 +598,7 @@ typedef struct zpool_rewind_policy { /* Kind (ssd, file, mix, hdd) (part of vdev_stat_ex_t) */ #define ZPOOL_CONFIG_VDEV_KIND "kind" +#define ZPOOL_CONFIG_VDEV_NROTOR "nrotor" #define ZPOOL_CONFIG_WHOLE_DISK "whole_disk" #define ZPOOL_CONFIG_ERRCOUNT "error_count" @@ -902,6 +903,8 @@ typedef struct vdev_stat_ex { /* Kind of vdev (ssd, file, mixed, hdd). Exported as one value. */ uint64_t vsx_kind; + /* Allocation rotor */ + uint64_t vsx_nrotor; } vdev_stat_ex_t; /* diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 728b65ef007b..cadd1af8ffe2 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -2938,6 +2938,10 @@ vdev_get_stats_ex_impl(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx) vsx->vsx_kind = VDEV_KIND_MIXED; else vsx->vsx_kind = VDEV_KIND_HDD; + if (vd->vdev_mg) + vsx->vsx_nrotor = vd->vdev_mg->mg_nrot; + else + vsx->vsx_nrotor = -1; } } diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 6f7b7fc33aa9..a0ab8a8d3c20 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -346,6 +346,8 @@ vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv) fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_KIND, vsx->vsx_kind); + fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_NROTOR, vsx->vsx_nrotor); + /* Add extended stats nvlist to main nvlist */ fnvlist_add_nvlist(nv, ZPOOL_CONFIG_VDEV_STATS_EX, nvx);