Skip to content

Commit

Permalink
zpool iostat tells which rotor vector each vdev is part of.
Browse files Browse the repository at this point in the history
For the time being, abusing the -k flag (of the previous commit).
  • Loading branch information
inkdot7 committed Jan 13, 2017
1 parent 90cc8c3 commit 74d4247
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2803,7 +2803,6 @@ print_iostat_labels(iostat_cbdata_t *cb, unsigned int force_column_width,

}
}
printf("\n");
}

/*
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

/*
Expand Down
4 changes: 4 additions & 0 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 2 additions & 0 deletions module/zfs/vdev_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 74d4247

Please sign in to comment.