Skip to content

Commit

Permalink
zpool iostat -S shows which vdevs are ssd, hdd or mixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
inkdot7 committed Oct 9, 2016
1 parent 1d621e3 commit bc255f4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
41 changes: 38 additions & 3 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ get_usage(zpool_help_t idx) {
"[-R root] [-F [-n]]\n"
"\t <pool | id> [newpool]\n"));
case HELP_IOSTAT:
return (gettext("\tiostat [-T d | u] [-ghHLpPvy] "
return (gettext("\tiostat [-T d | u] [-ghHLpPSvy] "
"[[-lq]|[-r|-w]]\n"
"\t [[pool ...]|[pool vdev ...]|[vdev ...]] "
"[interval [count]]\n"));
Expand Down Expand Up @@ -1450,6 +1450,21 @@ max_width(zpool_handle_t *zhp, nvlist_t *nv, int depth, int max,
return (max);
}

static const char *
nonrotational_mark(vdev_stat_t *vs)
{
switch (vs->vs_nonrotational) {
case VDEV_NONROTATIONAL_YES:
return ("y");
case VDEV_NONROTATIONAL_MIXED:
return ("m");
case VDEV_NONROTATIONAL_NO:
return ("n");
default:
return ("?");
}
}

typedef struct spare_cbdata {
uint64_t cb_guid;
zpool_handle_t *cb_zhp;
Expand Down Expand Up @@ -2571,6 +2586,7 @@ typedef struct iostat_cbdata {
boolean_t cb_verbose;
boolean_t cb_literal;
boolean_t cb_scripted;
boolean_t cb_nonrotational;
zpool_list_t *cb_list;
} iostat_cbdata_t;

Expand Down Expand Up @@ -2786,6 +2802,9 @@ print_iostat_dashes(iostat_cbdata_t *cb, unsigned int force_column_width,
(void) printf("-");
}

if (cb->cb_nonrotational)
printf(" -");

/* For each bit in flags */
for (f = flags; f; f &= ~(1ULL << idx)) {
unsigned int column_width;
Expand Down Expand Up @@ -2845,10 +2864,16 @@ print_iostat_header_impl(iostat_cbdata_t *cb, unsigned int force_column_width,
printf("%*s", namewidth, "");


if (cb->cb_nonrotational)
printf(" N");

print_iostat_labels(cb, force_column_width, iostat_top_labels);

printf("%-*s", namewidth, title);

if (cb->cb_nonrotational)
printf(" R");

print_iostat_labels(cb, force_column_width, iostat_bottom_labels);

print_iostat_separator_impl(cb, force_column_width);
Expand Down Expand Up @@ -3348,6 +3373,10 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv,
(int)(cb->cb_namewidth - strlen(name) -
depth), "");
}
if (cb->cb_nonrotational) {
printf("%s%s", cb->cb_scripted ? "\t" : " ",
nonrotational_mark(newvs));
}
}

/* Calculate our scaling factor */
Expand Down Expand Up @@ -3910,7 +3939,7 @@ fsleep(float sec) {


/*
* zpool iostat [-ghHLpPvy] [[-lq]|[-r|-w]] [-n name] [-T d|u]
* zpool iostat [-ghHLpPSvy] [[-lq]|[-r|-w]] [-n name] [-T d|u]
* [[ pool ...]|[pool vdev ...]|[vdev ...]]
* [interval [count]]
*
Expand All @@ -3926,6 +3955,7 @@ fsleep(float sec) {
* -q Display queue depths
* -w Display latency histograms
* -r Display request size histogram
* -S Display marker for solid-state based devices, and mixed.
* -T Display a timestamp in date(1) or Unix format
*
* This command can be tricky because we want to be able to deal with pool
Expand All @@ -3950,6 +3980,7 @@ zpool_do_iostat(int argc, char **argv)
boolean_t guid = B_FALSE;
boolean_t follow_links = B_FALSE;
boolean_t full_name = B_FALSE;
boolean_t nonrotational = B_FALSE;
iostat_cbdata_t cb = { 0 };

/* Used for printing error message */
Expand All @@ -3959,7 +3990,7 @@ zpool_do_iostat(int argc, char **argv)
uint64_t unsupported_flags;

/* check options */
while ((c = getopt(argc, argv, "gLPT:vyhplqrwH")) != -1) {
while ((c = getopt(argc, argv, "gLPT:vyhplqrSwH")) != -1) {
switch (c) {
case 'g':
guid = B_TRUE;
Expand Down Expand Up @@ -3994,6 +4025,9 @@ zpool_do_iostat(int argc, char **argv)
case 'r':
rq_histo = B_TRUE;
break;
case 'S':
nonrotational = B_TRUE;
break;
case 'y':
omit_since_boot = B_TRUE;
break;
Expand Down Expand Up @@ -4022,6 +4056,7 @@ zpool_do_iostat(int argc, char **argv)
cb.cb_iteration = 0;
cb.cb_namewidth = 0;
cb.cb_verbose = verbose;
cb.cb_nonrotational = nonrotational;

/* Get our interval and count values (if any) */
if (guid) {
Expand Down
13 changes: 11 additions & 2 deletions man/man8/zpool.8
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ zpool \- configures ZFS storage pools

.LP
.nf
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [\fB-lq\fR]|[\fB-r\fR|-\fBw\fR]]
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPSvy\fR] [\fB-lq\fR]|[\fB-r\fR|-\fBw\fR]]
[[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR

.fi
Expand Down Expand Up @@ -1510,7 +1510,7 @@ Scan using the default search path, the libblkid cache will not be consulted. A
.sp
.ne 2
.na
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [[\fB-lq\fR]|[\fB-r\fR|\fB-w\fR]] [[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPSvy\fR] [[\fB-lq\fR]|[\fB-r\fR|\fB-w\fR]] [[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR

.ad
.sp .6
Expand Down Expand Up @@ -1595,6 +1595,15 @@ request size stats with the block layer requests; it's possible ZIOs can
be broken up before being sent to the block device.
.RE

.sp
.ne 2
.na
\fB\fB-S\fR\fR
.ad
.RS 12n
Display whether a pool or vdev is based on solid-state devices, i.e. non-rotational, marked with a "y". Other devices are marked with "n". Mixed mirrored devices that have at least one solid-state member are marked "m". A pool is considered mixed if all members are at least mixed.
.RE

.sp
.ne 2
.na
Expand Down

0 comments on commit bc255f4

Please sign in to comment.