Add -lhHpw options to "zpool iostat" for avg latency, histograms, & queues
Update the zfs module to collect statistics on average latencies, queue sizes, and keep an internal histogram of all IO latencies. Along with this, update "zpool iostat" with some new options to print out the stats: -l: Include average IO latencies stats: total_wait disk_wait syncq_wait asyncq_wait scrub read write read write read write read write wait ----- ----- ----- ----- ----- ----- ----- ----- ----- - 41ms - 2ms - 46ms - 4ms - - 5ms - 1ms - 1us - 4ms - - 5ms - 1ms - 1us - 4ms - - - - - - - - - - - 49ms - 2ms - 47ms - - - - - - - - - - - - - 2ms - 1ms - - - 1ms - ----- ----- ----- ----- ----- ----- ----- ----- ----- 1ms 1ms 1ms 413us 16us 25us - 5ms - 1ms 1ms 1ms 413us 16us 25us - 5ms - 2ms 1ms 2ms 412us 26us 25us - 5ms - - 1ms - 413us - 25us - 5ms - - 1ms - 460us - 29us - 5ms - 196us 1ms 196us 370us 7us 23us - 5ms - ----- ----- ----- ----- ----- ----- ----- ----- ----- -w: Print out latency histograms: sdb total disk sync_queue async_queue latency read write read write read write read write scrub ------- ------ ------ ------ ------ ------ ------ ------ ------ ------ 1ns 0 0 0 0 0 0 0 0 0 ... 33us 0 0 0 0 0 0 0 0 0 66us 0 0 107 2486 2 788 12 12 0 131us 2 797 359 4499 10 558 184 184 6 262us 22 801 264 1563 10 286 287 287 24 524us 87 575 71 52086 15 1063 136 136 92 1ms 152 1190 5 41292 4 1693 252 252 141 2ms 245 2018 0 50007 0 2322 371 371 220 4ms 189 7455 22 162957 0 3912 6726 6726 199 8ms 108 9461 0 102320 0 5775 2526 2526 86 17ms 23 11287 0 37142 0 8043 1813 1813 19 34ms 0 14725 0 24015 0 11732 3071 3071 0 67ms 0 23597 0 7914 0 18113 5025 5025 0 134ms 0 33798 0 254 0 25755 7326 7326 0 268ms 0 51780 0 12 0 41593 10002 10002 0 537ms 0 77808 0 0 0 64255 13120 13120 0 1s 0 105281 0 0 0 83805 20841 20841 0 2s 0 88248 0 0 0 73772 14006 14006 0 4s 0 47266 0 0 0 29783 17176 17176 0 9s 0 10460 0 0 0 4130 6295 6295 0 17s 0 0 0 0 0 0 0 0 0 34s 0 0 0 0 0 0 0 0 0 69s 0 0 0 0 0 0 0 0 0 137s 0 0 0 0 0 0 0 0 0 ------------------------------------------------------------------------------- -h: Help -H: Scripted mode. Do not display headers, and separate fields by a single tab instead of arbitrary space. -q: Include current number of entries in sync & async read/write queues, and scrub queue: syncq_read syncq_write asyncq_read asyncq_write scrubq_read pend activ pend activ pend activ pend activ pend activ ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 0 0 0 0 78 29 0 0 0 0 0 0 0 0 78 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - - - 0 0 0 0 0 0 0 0 0 0 - - - - - - - - - - 0 0 0 0 0 0 0 0 0 0 ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 0 0 227 394 0 19 0 0 0 0 0 0 227 394 0 19 0 0 0 0 0 0 108 98 0 19 0 0 0 0 0 0 19 98 0 0 0 0 0 0 0 0 78 98 0 0 0 0 0 0 0 0 19 88 0 0 0 0 0 0 ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -p: Display numbers in parseable (exact) values. Also, update iostat syntax to allow the user to specify specific vdevs to show statistics for. The three options for choosing pools/vdevs are: Display a list of pools: zpool iostat ... [pool ...] Display a list of vdevs from a specific pool: zpool iostat ... [pool vdev ...] Display a list of vdevs from any pools: zpool iostat ... [vdev ...] Lastly, allow zpool command "interval" value to be floating point: zpool iostat -v 0.5 Signed-off-by: Tony Hutter <hutter2@llnl.gov Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4433
This commit is contained in:
parent
20c901dc7a
commit
193a37cb24
@ -19,4 +19,4 @@ zpool_LDADD = \
|
||||
$(top_builddir)/lib/libzpool/libzpool.la \
|
||||
$(top_builddir)/lib/libzfs/libzfs.la \
|
||||
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
|
||||
$(LIBBLKID)
|
||||
-lm $(LIBBLKID)
|
||||
|
@ -250,3 +250,69 @@ for_each_pool(int argc, char **argv, boolean_t unavail,
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
for_each_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, pool_vdev_iter_f func,
|
||||
void *data)
|
||||
{
|
||||
nvlist_t **child;
|
||||
uint_t c, children;
|
||||
int ret = 0;
|
||||
int i;
|
||||
char *type;
|
||||
|
||||
const char *list[] = {
|
||||
ZPOOL_CONFIG_SPARES,
|
||||
ZPOOL_CONFIG_L2CACHE,
|
||||
ZPOOL_CONFIG_CHILDREN
|
||||
};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(list); i++) {
|
||||
if (nvlist_lookup_nvlist_array(nv, list[i], &child,
|
||||
&children) == 0) {
|
||||
for (c = 0; c < children; c++) {
|
||||
uint64_t ishole = 0;
|
||||
|
||||
(void) nvlist_lookup_uint64(child[c],
|
||||
ZPOOL_CONFIG_IS_HOLE, &ishole);
|
||||
|
||||
if (ishole)
|
||||
continue;
|
||||
|
||||
ret |= for_each_vdev_cb(zhp, child[c], func,
|
||||
data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0)
|
||||
return (ret);
|
||||
|
||||
/* Don't run our function on root vdevs */
|
||||
if (strcmp(type, VDEV_TYPE_ROOT) != 0) {
|
||||
ret |= func(zhp, nv, data);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the equivalent of for_each_pool() for vdevs. It iterates thorough
|
||||
* all vdevs in the pool, ignoring root vdevs and holes, calling func() on
|
||||
* each one.
|
||||
*
|
||||
* @zhp: Zpool handle
|
||||
* @func: Function to call on each vdev
|
||||
* @data: Custom data to pass to the function
|
||||
*/
|
||||
int
|
||||
for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data)
|
||||
{
|
||||
nvlist_t *config, *nvroot;
|
||||
|
||||
if ((config = zpool_get_config(zhp, NULL)) != NULL) {
|
||||
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
|
||||
&nvroot) == 0);
|
||||
}
|
||||
return (for_each_vdev_cb(zhp, nvroot, func, data));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "zpool_util.h"
|
||||
|
||||
@ -84,3 +85,27 @@ num_logs(nvlist_t *nv)
|
||||
}
|
||||
return (nlogs);
|
||||
}
|
||||
|
||||
/* Find the max element in an array of uint64_t values */
|
||||
uint64_t
|
||||
array64_max(uint64_t array[], unsigned int len) {
|
||||
uint64_t max = 0;
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
max = MAX(max, array[i]);
|
||||
|
||||
return (max);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 1 if "str" is a number string, 0 otherwise. Works for integer and
|
||||
* floating point numbers.
|
||||
*/
|
||||
int
|
||||
isnumber(char *str) {
|
||||
for (; *str; str++)
|
||||
if (!(isdigit(*str) || (*str == '.')))
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ extern "C" {
|
||||
void *safe_malloc(size_t);
|
||||
void zpool_no_memory(void);
|
||||
uint_t num_logs(nvlist_t *nv);
|
||||
uint64_t array64_max(uint64_t array[], unsigned int len);
|
||||
int isnumber(char *str);
|
||||
|
||||
/*
|
||||
* Virtual device functions
|
||||
@ -55,6 +57,10 @@ nvlist_t *split_mirror_vdev(zpool_handle_t *zhp, char *newname,
|
||||
int for_each_pool(int, char **, boolean_t unavail, zprop_list_t **,
|
||||
zpool_iter_f, void *);
|
||||
|
||||
/* Vdev list functions */
|
||||
typedef int (*pool_vdev_iter_f)(zpool_handle_t *, nvlist_t *, void *);
|
||||
int for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data);
|
||||
|
||||
typedef struct zpool_list zpool_list_t;
|
||||
|
||||
zpool_list_t *pool_list_get(int, char **, zprop_list_t **, int *);
|
||||
|
@ -747,10 +747,21 @@ extern int zfs_unshareall(zfs_handle_t *);
|
||||
extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
|
||||
void *, void *, int, zfs_share_op_t);
|
||||
|
||||
enum zfs_nicenum_format {
|
||||
ZFS_NICENUM_1024 = 0,
|
||||
ZFS_NICENUM_TIME = 1,
|
||||
ZFS_NICENUM_RAW = 2
|
||||
};
|
||||
|
||||
/*
|
||||
* Utility function to convert a number to a human-readable form.
|
||||
*/
|
||||
extern void zfs_nicenum(uint64_t, char *, size_t);
|
||||
extern void zfs_nicenum_format(uint64_t num, char *buf, size_t buflen,
|
||||
enum zfs_nicenum_format type);
|
||||
|
||||
|
||||
extern void zfs_nicetime(uint64_t, char *, size_t);
|
||||
extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *);
|
||||
|
||||
/*
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define _SYS_FS_ZFS_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/zio_priority.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -528,6 +529,37 @@ typedef struct zpool_rewind_policy {
|
||||
#define ZPOOL_CONFIG_DTL "DTL"
|
||||
#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
|
||||
#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
|
||||
|
||||
/* container nvlist of extended stats */
|
||||
#define ZPOOL_CONFIG_VDEV_STATS_EX "vdev_stats_ex"
|
||||
|
||||
/* Active queue read/write stats */
|
||||
#define ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE "vdev_sync_r_active_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE "vdev_sync_w_active_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE "vdev_async_r_active_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE "vdev_async_w_active_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE "vdev_async_scrub_active_queue"
|
||||
|
||||
/* Queue sizes */
|
||||
#define ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE "vdev_sync_r_pend_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE "vdev_sync_w_pend_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE "vdev_async_r_pend_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE "vdev_async_w_pend_queue"
|
||||
#define ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE "vdev_async_scrub_pend_queue"
|
||||
|
||||
/* Latency read/write histogram stats */
|
||||
#define ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO "vdev_tot_r_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO "vdev_tot_w_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO "vdev_disk_r_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO "vdev_disk_w_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO "vdev_sync_r_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO "vdev_sync_w_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO "vdev_async_r_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO "vdev_async_w_lat_histo"
|
||||
#define ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO "vdev_scrub_histo"
|
||||
|
||||
|
||||
|
||||
#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
|
||||
#define ZPOOL_CONFIG_ERRCOUNT "error_count"
|
||||
#define ZPOOL_CONFIG_NOT_PRESENT "not_present"
|
||||
@ -766,8 +798,49 @@ typedef struct vdev_stat {
|
||||
uint64_t vs_scan_removing; /* removing? */
|
||||
uint64_t vs_scan_processed; /* scan processed bytes */
|
||||
uint64_t vs_fragmentation; /* device fragmentation */
|
||||
|
||||
} vdev_stat_t;
|
||||
|
||||
/*
|
||||
* Extended stats
|
||||
*
|
||||
* These are stats which aren't included in the original iostat output. For
|
||||
* convenience, they are grouped together in vdev_stat_ex, although each stat
|
||||
* is individually exported as a nvlist.
|
||||
*/
|
||||
typedef struct vdev_stat_ex {
|
||||
/* Number of ZIOs issued to disk and waiting to finish */
|
||||
uint64_t vsx_active_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
|
||||
|
||||
/* Number of ZIOs pending to be issued to disk */
|
||||
uint64_t vsx_pend_queue[ZIO_PRIORITY_NUM_QUEUEABLE];
|
||||
|
||||
/*
|
||||
* Below are the histograms for various latencies. Buckets are in
|
||||
* units of nanoseconds.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 2^37 nanoseconds = 134s. Timeouts will probably start kicking in
|
||||
* before this.
|
||||
*/
|
||||
#define VDEV_HISTO_BUCKETS 37
|
||||
|
||||
/* Amount of time in ZIO queue (ns) */
|
||||
uint64_t vsx_queue_histo[ZIO_PRIORITY_NUM_QUEUEABLE]
|
||||
[VDEV_HISTO_BUCKETS];
|
||||
|
||||
/* Total ZIO latency (ns). Includes queuing and disk access time */
|
||||
uint64_t vsx_total_histo[ZIO_TYPES][VDEV_HISTO_BUCKETS];
|
||||
|
||||
/* Amount of time to read/write the disk (ns) */
|
||||
uint64_t vsx_disk_histo[ZIO_TYPES][VDEV_HISTO_BUCKETS];
|
||||
|
||||
/* "lookup the bucket for a value" macro */
|
||||
#define HISTO(a) (a != 0 ? MIN(highbit64(a) - 1, VDEV_HISTO_BUCKETS - 1) : 0)
|
||||
|
||||
} vdev_stat_ex_t;
|
||||
|
||||
/*
|
||||
* DDT statistics. Note: all fields should be 64-bit because this
|
||||
* is passed between kernel and userland as an nvlist uint64 array.
|
||||
|
@ -85,7 +85,7 @@ extern void vdev_expand(vdev_t *vd, uint64_t txg);
|
||||
extern void vdev_split(vdev_t *vd);
|
||||
extern void vdev_deadman(vdev_t *vd);
|
||||
|
||||
|
||||
extern void vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx);
|
||||
extern void vdev_get_stats(vdev_t *vd, vdev_stat_t *vs);
|
||||
extern void vdev_clear_stats(vdev_t *vd);
|
||||
extern void vdev_stat_update(zio_t *zio, uint64_t psize);
|
||||
@ -153,6 +153,7 @@ extern uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset);
|
||||
extern int vdev_label_number(uint64_t psise, uint64_t offset);
|
||||
extern nvlist_t *vdev_label_read_config(vdev_t *vd, uint64_t txg);
|
||||
extern void vdev_uberblock_load(vdev_t *, struct uberblock *, nvlist_t **);
|
||||
extern void vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv);
|
||||
|
||||
typedef enum {
|
||||
VDEV_LABEL_CREATE, /* create/add a new device */
|
||||
|
@ -150,6 +150,7 @@ struct vdev {
|
||||
vdev_t **vdev_child; /* array of children */
|
||||
uint64_t vdev_children; /* number of children */
|
||||
vdev_stat_t vdev_stat; /* virtual device statistics */
|
||||
vdev_stat_ex_t vdev_stat_ex; /* extended statistics */
|
||||
boolean_t vdev_expanding; /* expand the vdev? */
|
||||
boolean_t vdev_reopening; /* reopen in progress? */
|
||||
boolean_t vdev_nonrot; /* true if solid state */
|
||||
|
@ -647,6 +647,7 @@ extern void delay(clock_t ticks);
|
||||
extern uint64_t physmem;
|
||||
|
||||
extern int highbit64(uint64_t i);
|
||||
extern int lowbit64(uint64_t i);
|
||||
extern int random_get_bytes(uint8_t *ptr, size_t len);
|
||||
extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);
|
||||
|
||||
|
@ -421,7 +421,8 @@ struct zio {
|
||||
uint64_t io_offset;
|
||||
hrtime_t io_timestamp; /* submitted at */
|
||||
hrtime_t io_delta; /* vdev queue service delta */
|
||||
uint64_t io_delay; /* vdev disk service delta (ticks) */
|
||||
hrtime_t io_delay; /* Device access time (disk or */
|
||||
/* file). */
|
||||
avl_node_t io_queue_node;
|
||||
avl_node_t io_offset_node;
|
||||
|
||||
|
@ -29,8 +29,7 @@ typedef enum zio_priority {
|
||||
ZIO_PRIORITY_ASYNC_WRITE, /* spa_sync() */
|
||||
ZIO_PRIORITY_SCRUB, /* asynchronous scrub/resilver reads */
|
||||
ZIO_PRIORITY_NUM_QUEUEABLE,
|
||||
|
||||
ZIO_PRIORITY_NOW /* non-queued i/os (e.g. free) */
|
||||
ZIO_PRIORITY_NOW, /* non-queued i/os (e.g. free) */
|
||||
} zio_priority_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -39,6 +39,9 @@
|
||||
#ifndef ABS
|
||||
#define ABS(a) ((a) < 0 ? -(a) : (a))
|
||||
#endif
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
|
||||
#endif
|
||||
|
||||
#define makedevice(maj, min) makedev(maj, min)
|
||||
#define _sysconf(a) sysconf(a)
|
||||
|
@ -3538,7 +3538,6 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
|
||||
* If it's a raidz device, we need to stick in the parity level.
|
||||
*/
|
||||
if (strcmp(path, VDEV_TYPE_RAIDZ) == 0) {
|
||||
|
||||
verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NPARITY,
|
||||
&value) == 0);
|
||||
(void) snprintf(buf, sizeof (buf), "%s%llu", path,
|
||||
@ -3552,7 +3551,6 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
|
||||
*/
|
||||
if (name_flags & VDEV_NAME_TYPE_ID) {
|
||||
uint64_t id;
|
||||
|
||||
verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_ID,
|
||||
&id) == 0);
|
||||
(void) snprintf(tmpbuf, sizeof (tmpbuf), "%s-%llu",
|
||||
|
@ -596,27 +596,49 @@ zfs_strdup(libzfs_handle_t *hdl, const char *str)
|
||||
* Convert a number to an appropriately human-readable output.
|
||||
*/
|
||||
void
|
||||
zfs_nicenum(uint64_t num, char *buf, size_t buflen)
|
||||
zfs_nicenum_format(uint64_t num, char *buf, size_t buflen,
|
||||
enum zfs_nicenum_format format)
|
||||
{
|
||||
uint64_t n = num;
|
||||
int index = 0;
|
||||
char u;
|
||||
const char *u;
|
||||
const char *units[3][7] = {
|
||||
[ZFS_NICENUM_1024] = {"", "K", "M", "G", "T", "P", "E"},
|
||||
[ZFS_NICENUM_TIME] = {"ns", "us", "ms", "s", "?", "?", "?"}
|
||||
};
|
||||
|
||||
while (n >= 1024 && index < 6) {
|
||||
n /= 1024;
|
||||
const int units_len[] = {[ZFS_NICENUM_1024] = 6,
|
||||
[ZFS_NICENUM_TIME] = 4};
|
||||
|
||||
const int k_unit[] = { [ZFS_NICENUM_1024] = 1024,
|
||||
[ZFS_NICENUM_TIME] = 1000};
|
||||
|
||||
double val;
|
||||
|
||||
if (format == ZFS_NICENUM_RAW) {
|
||||
snprintf(buf, buflen, "%llu", (u_longlong_t) num);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while (n >= k_unit[format] && index < units_len[format]) {
|
||||
n /= k_unit[format];
|
||||
index++;
|
||||
}
|
||||
|
||||
u = " KMGTPE"[index];
|
||||
u = units[format][index];
|
||||
|
||||
if (index == 0) {
|
||||
(void) snprintf(buf, buflen, "%llu", (u_longlong_t) n);
|
||||
} else if ((num & ((1ULL << 10 * index) - 1)) == 0) {
|
||||
/* Don't print 0ns times */
|
||||
if ((format == ZFS_NICENUM_TIME) && (num == 0)) {
|
||||
(void) snprintf(buf, buflen, "-");
|
||||
} else if ((index == 0) || ((num %
|
||||
(uint64_t) powl(k_unit[format], index)) == 0)) {
|
||||
/*
|
||||
* If this is an even multiple of the base, always display
|
||||
* without any decimal precision.
|
||||
*/
|
||||
(void) snprintf(buf, buflen, "%llu%c", (u_longlong_t) n, u);
|
||||
(void) snprintf(buf, buflen, "%llu%s", (u_longlong_t) n, u);
|
||||
|
||||
} else {
|
||||
/*
|
||||
* We want to choose a precision that reflects the best choice
|
||||
@ -629,12 +651,60 @@ zfs_nicenum(uint64_t num, char *buf, size_t buflen)
|
||||
*/
|
||||
int i;
|
||||
for (i = 2; i >= 0; i--) {
|
||||
if (snprintf(buf, buflen, "%.*f%c", i,
|
||||
(double)num / (1ULL << 10 * index), u) <= 5)
|
||||
val = (double) num /
|
||||
(uint64_t) powl(k_unit[format], index);
|
||||
|
||||
/*
|
||||
* Don't print floating point values for time. Note,
|
||||
* we use floor() instead of round() here, since
|
||||
* round can result in undesirable results. For
|
||||
* example, if "num" is in the range of
|
||||
* 999500-999999, it will print out "1000us". This
|
||||
* doesn't happen if we use floor().
|
||||
*/
|
||||
if (format == ZFS_NICENUM_TIME) {
|
||||
if (snprintf(buf, buflen, "%d%s",
|
||||
(unsigned int) floor(val), u) <= 5)
|
||||
break;
|
||||
|
||||
} else {
|
||||
if (snprintf(buf, buflen, "%.*f%s", i,
|
||||
val, u) <= 5)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a number to an appropriately human-readable output.
|
||||
*/
|
||||
void
|
||||
zfs_nicenum(uint64_t num, char *buf, size_t buflen)
|
||||
{
|
||||
zfs_nicenum_format(num, buf, buflen, ZFS_NICENUM_1024);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a time to an appropriately human-readable output.
|
||||
* @num: Time in nanoseconds
|
||||
*/
|
||||
void
|
||||
zfs_nicetime(uint64_t num, char *buf, size_t buflen)
|
||||
{
|
||||
zfs_nicenum_format(num, buf, buflen, ZFS_NICENUM_TIME);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out a raw number with correct column spacing
|
||||
*/
|
||||
void
|
||||
zfs_niceraw(uint64_t num, char *buf, size_t buflen)
|
||||
{
|
||||
zfs_nicenum_format(num, buf, buflen, ZFS_NICENUM_RAW);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
libzfs_print_on_error(libzfs_handle_t *hdl, boolean_t printerr)
|
||||
|
@ -1071,6 +1071,50 @@ highbit64(uint64_t i)
|
||||
return (h);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find lowest one bit set.
|
||||
* Returns bit number + 1 of lowest bit that is set, otherwise returns 0.
|
||||
* This is basically a reimplementation of ffsll(), which is GNU specific.
|
||||
*/
|
||||
int
|
||||
lowbit64(uint64_t i)
|
||||
{
|
||||
register int h = 64;
|
||||
if (i == 0)
|
||||
return (0);
|
||||
|
||||
if (i & 0x00000000ffffffffULL)
|
||||
h -= 32;
|
||||
else
|
||||
i >>= 32;
|
||||
|
||||
if (i & 0x0000ffff)
|
||||
h -= 16;
|
||||
else
|
||||
i >>= 16;
|
||||
|
||||
if (i & 0x00ff)
|
||||
h -= 8;
|
||||
else
|
||||
i >>= 8;
|
||||
|
||||
if (i & 0x0f)
|
||||
h -= 4;
|
||||
else
|
||||
i >>= 4;
|
||||
|
||||
if (i & 0x3)
|
||||
h -= 2;
|
||||
else
|
||||
i >>= 2;
|
||||
|
||||
if (i & 0x1)
|
||||
h -= 1;
|
||||
|
||||
return (h);
|
||||
}
|
||||
|
||||
|
||||
static int random_fd = -1, urandom_fd = -1;
|
||||
|
||||
static int
|
||||
|
@ -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;
|
||||
|
209
man/man8/zpool.8
209
man/man8/zpool.8
@ -95,7 +95,9 @@ zpool \- configures ZFS storage pools
|
||||
|
||||
.LP
|
||||
.nf
|
||||
\fBzpool iostat\fR [\fB-T\fR d | u ] [\fB-gLPvy\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]]
|
||||
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [\fB-G\fR|[\fB-lq\fR]]
|
||||
[[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR
|
||||
|
||||
.fi
|
||||
|
||||
.LP
|
||||
@ -1677,11 +1679,22 @@ Scan using the default search path, the libblkid cache will not be consulted. A
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-gLPvy\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]]\fR
|
||||
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [\fB-w\fR|[\fB-lq\fR]] [[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR
|
||||
|
||||
.ad
|
||||
.sp .6
|
||||
.RS 4n
|
||||
Displays \fBI/O\fR statistics for the given pools. When given an interval, the statistics are printed every \fIinterval\fR seconds until \fBCtrl-C\fR is pressed. If no \fIpools\fR are specified, statistics for every pool in the system is shown. If \fIcount\fR is specified, the command exits after \fIcount\fR reports are printed.
|
||||
Displays \fBI/O\fR statistics for the given \fIpool\fRs/\fIvdev\fRs. You can
|
||||
pass in a list of \fIpool\fRs, a \fIpool\fR and list of \fIvdev\fRs in that
|
||||
\fIpool\fR, or a list of any \fIvdev\fRs from any \fIpool\fR. If no items are
|
||||
specified, statistics for every pool in the system are shown. When given an
|
||||
interval, the statistics are printed every \fIinterval\fR seconds until
|
||||
\fBCtrl-C\fR is pressed. If \fIcount\fR is specified, the command exits after
|
||||
\fIcount\fR reports are printed. The first report printed is always the
|
||||
statistics since boot regardless of whether \fIinterval\fR and \fIcount\fR
|
||||
are passed. However, this behavior can be suppressed with the -y flag. Also
|
||||
note that the units of 'K', 'M', 'G'... that are printed in the report are in
|
||||
base 1024. To get the raw values, use the \fB-p\fR flag.
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
@ -1706,6 +1719,17 @@ Specify \fBu\fR for a printed representation of the internal representation of t
|
||||
Display vdev GUIDs instead of the normal device names. These GUIDs can be used in place of device names for the zpool detach/offline/remove/replace commands.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
\fB\fB-H\fR\fR
|
||||
.ad
|
||||
.RS 12n
|
||||
.rt
|
||||
Scripted mode. Do not display headers, and separate fields by a single tab instead of arbitrary space.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
@ -1717,6 +1741,17 @@ Display vdev GUIDs instead of the normal device names. These GUIDs can be used i
|
||||
Display real paths for vdevs resolving all symbolic links. This can be used to look up the current block device name regardless of the /dev/disk/ path used to open it.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
\fB\fB-p\fR\fR
|
||||
.ad
|
||||
.RS 12n
|
||||
.rt
|
||||
Display numbers in parseable (exact) values. Time values are in nanoseconds.
|
||||
.RE
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
@ -1749,9 +1784,177 @@ Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within t
|
||||
.rt
|
||||
Omit statistics since boot. Normally the first line of output reports the statistics since boot. This option suppresses that first line of output.
|
||||
.RE
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
\fB\fB-w\fR\fR
|
||||
.ad
|
||||
.RS 12n
|
||||
.rt
|
||||
Display latency histograms:
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
total_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Total IO time (queuing + disk IO time).
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
disk_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Disk IO time (time reading/writing the disk).
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
syncq_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Amount of time IO spent in synchronous priority queues. Does not include
|
||||
disk time.
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
asyncq_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Amount of time IO spent in asynchronous priority queues. Does not include
|
||||
disk time.
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
scrub:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Amount of time IO spent in scrub queue. Does not include disk time.
|
||||
|
||||
|
||||
.RE
|
||||
|
||||
All histogram buckets are power-of-two sized. The time labels are the end
|
||||
ranges of the buckets, so for example, a 15ns bucket stores latencies from
|
||||
8-15ns. The last bucket is also a catch-all for latencies higher than the
|
||||
maximum.
|
||||
.RE
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
\fB\fB-l\fR\fR
|
||||
.ad
|
||||
.RS 12n
|
||||
.rt
|
||||
Include average latency statistics:
|
||||
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
total_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Average total IO time (queuing + disk IO time).
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
disk_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Average disk IO time (time reading/writing the disk).
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
syncq_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Average amount of time IO spent in synchronous priority queues. Does not
|
||||
include disk time.
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
asyncq_wait:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Average amount of time IO spent in asynchronous priority queues. Does not
|
||||
include disk time.
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
scrub:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Average queuing time in scrub queue. Does not include disk time.
|
||||
.RE
|
||||
|
||||
.RE
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
\fB\fB-q\fR\fR
|
||||
.ad
|
||||
.RS 12n
|
||||
.rt
|
||||
Include active queue statistics. Each priority queue has both pending ("pend")
|
||||
and active ("activ") IOs. Pending IOs are waiting to be issued to the disk, and
|
||||
active IOs have been issued to disk and are waiting for completion. These stats
|
||||
are broken out by priority queue:
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
syncq_read/write:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Current number of entries in synchronous priority queues.
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
asyncq_read/write:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Current number of entries in asynchronous priority queues.
|
||||
.RE
|
||||
.ne 2
|
||||
.mk
|
||||
.na
|
||||
scrubq_read:
|
||||
.ad
|
||||
.RS 20n
|
||||
.rt
|
||||
Current number of entries in scrub queue.
|
||||
.RE
|
||||
|
||||
All queue statistics are instantaneous measurements of the number of entries
|
||||
in the queues. If you specify an interval, the measurements will be sampled
|
||||
from the end of the interval.
|
||||
.RE
|
||||
.sp
|
||||
.ne 2
|
||||
.mk
|
||||
|
@ -3350,6 +3350,8 @@ spa_add_l2cache(spa_t *spa, nvlist_t *config)
|
||||
ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &vsc)
|
||||
== 0);
|
||||
vdev_get_stats(vd, vs);
|
||||
vdev_config_generate_stats(vd, l2cache[i]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2764,49 +2764,123 @@ vdev_accessible(vdev_t *vd, zio_t *zio)
|
||||
return (B_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
vdev_get_child_stat(vdev_t *cvd, vdev_stat_t *vs, vdev_stat_t *cvs)
|
||||
{
|
||||
int t;
|
||||
for (t = 0; t < ZIO_TYPES; t++) {
|
||||
vs->vs_ops[t] += cvs->vs_ops[t];
|
||||
vs->vs_bytes[t] += cvs->vs_bytes[t];
|
||||
}
|
||||
|
||||
cvs->vs_scan_removing = cvd->vdev_removing;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get extended stats
|
||||
*/
|
||||
static void
|
||||
vdev_get_child_stat_ex(vdev_t *cvd, vdev_stat_ex_t *vsx, vdev_stat_ex_t *cvsx)
|
||||
{
|
||||
int t, b;
|
||||
for (t = 0; t < ZIO_TYPES; t++) {
|
||||
for (b = 0; b < VDEV_HISTO_BUCKETS; b++) {
|
||||
vsx->vsx_disk_histo[t][b] += cvsx->vsx_disk_histo[t][b];
|
||||
vsx->vsx_total_histo[t][b] +=
|
||||
cvsx->vsx_total_histo[t][b];
|
||||
}
|
||||
}
|
||||
|
||||
for (t = 0; t < ZIO_PRIORITY_NUM_QUEUEABLE; t++) {
|
||||
for (b = 0; b < VDEV_HISTO_BUCKETS; b++) {
|
||||
vsx->vsx_queue_histo[t][b] +=
|
||||
cvsx->vsx_queue_histo[t][b];
|
||||
}
|
||||
vsx->vsx_active_queue[t] += cvsx->vsx_active_queue[t];
|
||||
vsx->vsx_pend_queue[t] += cvsx->vsx_pend_queue[t];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get statistics for the given vdev.
|
||||
*/
|
||||
void
|
||||
vdev_get_stats(vdev_t *vd, vdev_stat_t *vs)
|
||||
static void
|
||||
vdev_get_stats_ex_impl(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
|
||||
{
|
||||
spa_t *spa = vd->vdev_spa;
|
||||
vdev_t *rvd = spa->spa_root_vdev;
|
||||
int c, t;
|
||||
/*
|
||||
* If we're getting stats on the root vdev, aggregate the I/O counts
|
||||
* over all top-level vdevs (i.e. the direct children of the root).
|
||||
*/
|
||||
if (!vd->vdev_ops->vdev_op_leaf) {
|
||||
if (vs) {
|
||||
memset(vs->vs_ops, 0, sizeof (vs->vs_ops));
|
||||
memset(vs->vs_bytes, 0, sizeof (vs->vs_bytes));
|
||||
}
|
||||
if (vsx)
|
||||
memset(vsx, 0, sizeof (*vsx));
|
||||
|
||||
ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0);
|
||||
for (c = 0; c < vd->vdev_children; c++) {
|
||||
vdev_t *cvd = vd->vdev_child[c];
|
||||
vdev_stat_t *cvs = &cvd->vdev_stat;
|
||||
vdev_stat_ex_t *cvsx = &cvd->vdev_stat_ex;
|
||||
|
||||
vdev_get_stats_ex_impl(cvd, cvs, cvsx);
|
||||
if (vs)
|
||||
vdev_get_child_stat(cvd, vs, cvs);
|
||||
if (vsx)
|
||||
vdev_get_child_stat_ex(cvd, vsx, cvsx);
|
||||
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* We're a leaf. Just copy our ZIO active queue stats in. The
|
||||
* other leaf stats are updated in vdev_stat_update().
|
||||
*/
|
||||
if (!vsx)
|
||||
return;
|
||||
|
||||
memcpy(vsx, &vd->vdev_stat_ex, sizeof (vd->vdev_stat_ex));
|
||||
|
||||
for (t = 0; t < ARRAY_SIZE(vd->vdev_queue.vq_class); t++) {
|
||||
vsx->vsx_active_queue[t] =
|
||||
vd->vdev_queue.vq_class[t].vqc_active;
|
||||
vsx->vsx_pend_queue[t] = avl_numnodes(
|
||||
&vd->vdev_queue.vq_class[t].vqc_queued_tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vdev_get_stats_ex(vdev_t *vd, vdev_stat_t *vs, vdev_stat_ex_t *vsx)
|
||||
{
|
||||
mutex_enter(&vd->vdev_stat_lock);
|
||||
if (vs) {
|
||||
bcopy(&vd->vdev_stat, vs, sizeof (*vs));
|
||||
vs->vs_timestamp = gethrtime() - vs->vs_timestamp;
|
||||
vs->vs_state = vd->vdev_state;
|
||||
vs->vs_rsize = vdev_get_min_asize(vd);
|
||||
if (vd->vdev_ops->vdev_op_leaf)
|
||||
vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE;
|
||||
vs->vs_rsize += VDEV_LABEL_START_SIZE +
|
||||
VDEV_LABEL_END_SIZE;
|
||||
vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize;
|
||||
if (vd->vdev_aux == NULL && vd == vd->vdev_top && !vd->vdev_ishole) {
|
||||
if (vd->vdev_aux == NULL && vd == vd->vdev_top &&
|
||||
!vd->vdev_ishole) {
|
||||
vs->vs_fragmentation = vd->vdev_mg->mg_fragmentation;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're getting stats on the root vdev, aggregate the I/O counts
|
||||
* over all top-level vdevs (i.e. the direct children of the root).
|
||||
*/
|
||||
if (vd == rvd) {
|
||||
for (c = 0; c < rvd->vdev_children; c++) {
|
||||
vdev_t *cvd = rvd->vdev_child[c];
|
||||
vdev_stat_t *cvs = &cvd->vdev_stat;
|
||||
|
||||
for (t = 0; t < ZIO_TYPES; t++) {
|
||||
vs->vs_ops[t] += cvs->vs_ops[t];
|
||||
vs->vs_bytes[t] += cvs->vs_bytes[t];
|
||||
}
|
||||
cvs->vs_scan_removing = cvd->vdev_removing;
|
||||
}
|
||||
}
|
||||
ASSERT(spa_config_held(vd->vdev_spa, SCL_ALL, RW_READER) != 0);
|
||||
vdev_get_stats_ex_impl(vd, vs, vsx);
|
||||
mutex_exit(&vd->vdev_stat_lock);
|
||||
}
|
||||
|
||||
void
|
||||
vdev_get_stats(vdev_t *vd, vdev_stat_t *vs)
|
||||
{
|
||||
return (vdev_get_stats_ex(vd, vs, NULL));
|
||||
}
|
||||
|
||||
void
|
||||
vdev_clear_stats(vdev_t *vd)
|
||||
{
|
||||
@ -2840,6 +2914,7 @@ vdev_stat_update(zio_t *zio, uint64_t psize)
|
||||
vdev_t *pvd;
|
||||
uint64_t txg = zio->io_txg;
|
||||
vdev_stat_t *vs = &vd->vdev_stat;
|
||||
vdev_stat_ex_t *vsx = &vd->vdev_stat_ex;
|
||||
zio_type_t type = zio->io_type;
|
||||
int flags = zio->io_flags;
|
||||
|
||||
@ -2890,9 +2965,25 @@ vdev_stat_update(zio_t *zio, uint64_t psize)
|
||||
vs->vs_self_healed += psize;
|
||||
}
|
||||
|
||||
/*
|
||||
* The bytes/ops/histograms are recorded at the leaf level and
|
||||
* aggregated into the higher level vdevs in vdev_get_stats().
|
||||
*/
|
||||
if (vd->vdev_ops->vdev_op_leaf) {
|
||||
|
||||
vs->vs_ops[type]++;
|
||||
vs->vs_bytes[type] += psize;
|
||||
|
||||
if (zio->io_delta && zio->io_delay) {
|
||||
vsx->vsx_queue_histo[zio->io_priority]
|
||||
[HISTO(zio->io_delta - zio->io_delay)]++;
|
||||
vsx->vsx_disk_histo[type]
|
||||
[HISTO(zio->io_delay)]++;
|
||||
vsx->vsx_total_histo[type]
|
||||
[HISTO(zio->io_delta)]++;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_exit(&vd->vdev_stat_lock);
|
||||
return;
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ vdev_disk_error(zio_t *zio)
|
||||
{
|
||||
#ifdef ZFS_DEBUG
|
||||
printk("ZFS: zio error=%d type=%d offset=%llu size=%llu "
|
||||
"flags=%x delay=%llu\n", zio->io_error, zio->io_type,
|
||||
"flags=%x\n", zio->io_error, zio->io_type,
|
||||
(u_longlong_t)zio->io_offset, (u_longlong_t)zio->io_size,
|
||||
zio->io_flags, (u_longlong_t)zio->io_delay);
|
||||
zio->io_flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -410,7 +410,6 @@ vdev_disk_dio_put(dio_request_t *dr)
|
||||
vdev_disk_dio_free(dr);
|
||||
|
||||
if (zio) {
|
||||
zio->io_delay = jiffies_64 - zio->io_delay;
|
||||
zio->io_error = error;
|
||||
ASSERT3S(zio->io_error, >=, 0);
|
||||
if (zio->io_error)
|
||||
@ -588,8 +587,6 @@ __vdev_disk_physio(struct block_device *bdev, zio_t *zio, caddr_t kbuf_ptr,
|
||||
|
||||
/* Extra reference to protect dio_request during vdev_submit_bio */
|
||||
vdev_disk_dio_get(dr);
|
||||
if (zio)
|
||||
zio->io_delay = jiffies_64;
|
||||
|
||||
/* Submit all bio's associated with this dio */
|
||||
for (i = 0; i < dr->dr_bio_count; i++)
|
||||
@ -630,7 +627,6 @@ BIO_END_IO_PROTO(vdev_disk_io_flush_completion, bio, rc)
|
||||
int rc = bio->bi_error;
|
||||
#endif
|
||||
|
||||
zio->io_delay = jiffies_64 - zio->io_delay;
|
||||
zio->io_error = -rc;
|
||||
if (rc && (rc == -EOPNOTSUPP))
|
||||
zio->io_vd->vdev_nowritecache = B_TRUE;
|
||||
@ -660,7 +656,6 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
|
||||
bio->bi_end_io = vdev_disk_io_flush_completion;
|
||||
bio->bi_private = zio;
|
||||
bio->bi_bdev = bdev;
|
||||
zio->io_delay = jiffies_64;
|
||||
vdev_submit_bio(VDEV_WRITE_FLUSH_FUA, bio);
|
||||
invalidate_bdev(bdev);
|
||||
|
||||
|
@ -207,6 +207,107 @@ vdev_label_write(zio_t *zio, vdev_t *vd, int l, void *buf, uint64_t offset,
|
||||
ZIO_PRIORITY_SYNC_WRITE, flags, B_TRUE));
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate the nvlist representing this vdev's stats
|
||||
*/
|
||||
void
|
||||
vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv)
|
||||
{
|
||||
nvlist_t *nvx;
|
||||
vdev_stat_t *vs;
|
||||
vdev_stat_ex_t *vsx;
|
||||
|
||||
vs = kmem_alloc(sizeof (*vs), KM_SLEEP);
|
||||
vsx = kmem_alloc(sizeof (*vsx), KM_SLEEP);
|
||||
|
||||
vdev_get_stats_ex(vd, vs, vsx);
|
||||
fnvlist_add_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
|
||||
(uint64_t *)vs, sizeof (*vs) / sizeof (uint64_t));
|
||||
|
||||
kmem_free(vs, sizeof (*vs));
|
||||
|
||||
/*
|
||||
* Add extended stats into a special extended stats nvlist. This keeps
|
||||
* all the extended stats nicely grouped together. The extended stats
|
||||
* nvlist is then added to the main nvlist.
|
||||
*/
|
||||
nvx = fnvlist_alloc();
|
||||
|
||||
/* ZIOs in flight to disk */
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE,
|
||||
vsx->vsx_active_queue[ZIO_PRIORITY_SYNC_READ]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_SYNC_W_ACTIVE_QUEUE,
|
||||
vsx->vsx_active_queue[ZIO_PRIORITY_SYNC_WRITE]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_ASYNC_R_ACTIVE_QUEUE,
|
||||
vsx->vsx_active_queue[ZIO_PRIORITY_ASYNC_READ]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_ASYNC_W_ACTIVE_QUEUE,
|
||||
vsx->vsx_active_queue[ZIO_PRIORITY_ASYNC_WRITE]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_SCRUB_ACTIVE_QUEUE,
|
||||
vsx->vsx_active_queue[ZIO_PRIORITY_SCRUB]);
|
||||
|
||||
/* ZIOs pending */
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_SYNC_R_PEND_QUEUE,
|
||||
vsx->vsx_pend_queue[ZIO_PRIORITY_SYNC_READ]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_SYNC_W_PEND_QUEUE,
|
||||
vsx->vsx_pend_queue[ZIO_PRIORITY_SYNC_WRITE]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_ASYNC_R_PEND_QUEUE,
|
||||
vsx->vsx_pend_queue[ZIO_PRIORITY_ASYNC_READ]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_ASYNC_W_PEND_QUEUE,
|
||||
vsx->vsx_pend_queue[ZIO_PRIORITY_ASYNC_WRITE]);
|
||||
|
||||
fnvlist_add_uint64(nvx, ZPOOL_CONFIG_VDEV_SCRUB_PEND_QUEUE,
|
||||
vsx->vsx_pend_queue[ZIO_PRIORITY_SCRUB]);
|
||||
|
||||
/* Histograms */
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_TOT_R_LAT_HISTO,
|
||||
vsx->vsx_total_histo[ZIO_TYPE_READ],
|
||||
ARRAY_SIZE(vsx->vsx_total_histo[ZIO_TYPE_READ]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_TOT_W_LAT_HISTO,
|
||||
vsx->vsx_total_histo[ZIO_TYPE_WRITE],
|
||||
ARRAY_SIZE(vsx->vsx_total_histo[ZIO_TYPE_WRITE]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_DISK_R_LAT_HISTO,
|
||||
vsx->vsx_disk_histo[ZIO_TYPE_READ],
|
||||
ARRAY_SIZE(vsx->vsx_disk_histo[ZIO_TYPE_READ]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_DISK_W_LAT_HISTO,
|
||||
vsx->vsx_disk_histo[ZIO_TYPE_WRITE],
|
||||
ARRAY_SIZE(vsx->vsx_disk_histo[ZIO_TYPE_WRITE]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_SYNC_R_LAT_HISTO,
|
||||
vsx->vsx_queue_histo[ZIO_PRIORITY_SYNC_READ],
|
||||
ARRAY_SIZE(vsx->vsx_queue_histo[ZIO_PRIORITY_SYNC_READ]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_SYNC_W_LAT_HISTO,
|
||||
vsx->vsx_queue_histo[ZIO_PRIORITY_SYNC_WRITE],
|
||||
ARRAY_SIZE(vsx->vsx_queue_histo[ZIO_PRIORITY_SYNC_WRITE]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_ASYNC_R_LAT_HISTO,
|
||||
vsx->vsx_queue_histo[ZIO_PRIORITY_ASYNC_READ],
|
||||
ARRAY_SIZE(vsx->vsx_queue_histo[ZIO_PRIORITY_ASYNC_READ]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_ASYNC_W_LAT_HISTO,
|
||||
vsx->vsx_queue_histo[ZIO_PRIORITY_ASYNC_WRITE],
|
||||
ARRAY_SIZE(vsx->vsx_queue_histo[ZIO_PRIORITY_ASYNC_WRITE]));
|
||||
|
||||
fnvlist_add_uint64_array(nvx, ZPOOL_CONFIG_VDEV_SCRUB_LAT_HISTO,
|
||||
vsx->vsx_queue_histo[ZIO_PRIORITY_SCRUB],
|
||||
ARRAY_SIZE(vsx->vsx_queue_histo[ZIO_PRIORITY_SCRUB]));
|
||||
|
||||
/* Add extended stats nvlist to main nvlist */
|
||||
fnvlist_add_nvlist(nv, ZPOOL_CONFIG_VDEV_STATS_EX, nvx);
|
||||
|
||||
kmem_free(vsx, sizeof (*vsx));
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate the nvlist representing this vdev's config.
|
||||
*/
|
||||
@ -215,7 +316,6 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats,
|
||||
vdev_config_flag_t flags)
|
||||
{
|
||||
nvlist_t *nv = NULL;
|
||||
|
||||
nv = fnvlist_alloc();
|
||||
|
||||
fnvlist_add_string(nv, ZPOOL_CONFIG_TYPE, vd->vdev_ops->vdev_op_type);
|
||||
@ -306,12 +406,9 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats,
|
||||
}
|
||||
|
||||
if (getstats) {
|
||||
vdev_stat_t vs;
|
||||
pool_scan_stat_t ps;
|
||||
|
||||
vdev_get_stats(vd, &vs);
|
||||
fnvlist_add_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
|
||||
(uint64_t *)&vs, sizeof (vs) / sizeof (uint64_t));
|
||||
vdev_config_generate_stats(vd, nv);
|
||||
|
||||
/* provide either current or previous scan information */
|
||||
if (spa_scan_get_stats(spa, &ps) == 0) {
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <sys/ddt.h>
|
||||
#include <sys/blkptr.h>
|
||||
#include <sys/zfeature.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/*
|
||||
* ==========================================================================
|
||||
@ -2694,6 +2695,8 @@ zio_vdev_io_start(zio_t *zio)
|
||||
uint64_t align;
|
||||
spa_t *spa = zio->io_spa;
|
||||
|
||||
zio->io_delay = 0;
|
||||
|
||||
ASSERT(zio->io_error == 0);
|
||||
ASSERT(zio->io_child_error[ZIO_CHILD_VDEV] == 0);
|
||||
|
||||
@ -2799,6 +2802,7 @@ zio_vdev_io_start(zio_t *zio)
|
||||
}
|
||||
}
|
||||
|
||||
zio->io_delay = gethrtime();
|
||||
vd->vdev_ops->vdev_op_io_start(zio);
|
||||
return (ZIO_PIPELINE_STOP);
|
||||
}
|
||||
@ -2815,6 +2819,9 @@ zio_vdev_io_done(zio_t *zio)
|
||||
|
||||
ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
|
||||
|
||||
if (zio->io_delay)
|
||||
zio->io_delay = gethrtime() - zio->io_delay;
|
||||
|
||||
if (vd != NULL && vd->vdev_ops->vdev_op_leaf) {
|
||||
|
||||
vdev_queue_io_done(zio);
|
||||
@ -3217,7 +3224,7 @@ zio_done(zio_t *zio)
|
||||
* 30 seconds to complete, post an error described the I/O delay.
|
||||
* We ignore these errors if the device is currently unavailable.
|
||||
*/
|
||||
if (zio->io_delay >= MSEC_TO_TICK(zio_delay_max)) {
|
||||
if (zio->io_delay >= MSEC2NSEC(zio_delay_max)) {
|
||||
if (zio->io_vd != NULL && !vdev_is_dead(zio->io_vd))
|
||||
zfs_ereport_post(FM_EREPORT_ZFS_DELAY, zio->io_spa,
|
||||
zio->io_vd, zio, 0, 0);
|
||||
|
@ -370,7 +370,7 @@ tests = ['zfs_list_001_pos', 'zfs_list_002_pos', 'zfs_list_003_pos',
|
||||
|
||||
[tests/functional/cli_user/zpool_iostat]
|
||||
tests = ['zpool_iostat_001_neg', 'zpool_iostat_002_pos',
|
||||
'zpool_iostat_003_neg']
|
||||
'zpool_iostat_003_neg', 'zpool_iostat_004_pos']
|
||||
|
||||
[tests/functional/cli_user/zpool_list]
|
||||
tests = ['zpool_list_001_pos', 'zpool_list_002_neg']
|
||||
|
@ -4,4 +4,5 @@ dist_pkgdata_SCRIPTS = \
|
||||
cleanup.ksh \
|
||||
zpool_iostat_001_neg.ksh \
|
||||
zpool_iostat_002_pos.ksh \
|
||||
zpool_iostat_003_neg.ksh
|
||||
zpool_iostat_003_neg.ksh \
|
||||
zpool_iostat_004_pos.ksh
|
||||
|
@ -33,4 +33,4 @@
|
||||
|
||||
DISK=${DISKS%% *}
|
||||
|
||||
default_setup $DISK
|
||||
default_raidz_setup $DISKS
|
||||
|
@ -33,13 +33,13 @@
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Verify that 'zpool iostat [interval [count]' can be executed as non-root.
|
||||
# Verify that 'zpool iostat [interval [count]]' can be executed as non-root.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Set the interval to 1 and count to 4.
|
||||
# 2. Sleep for 4 seconds.
|
||||
# 3. Verify that the output has 4 records.
|
||||
#
|
||||
# 4. Set interval to 0.5 and count to 1 to test floating point intervals.
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
@ -68,4 +68,7 @@ if [[ $stat_count -ne 4 ]]; then
|
||||
log_fail "zpool iostat [pool_name] [interval] [count] failed"
|
||||
fi
|
||||
|
||||
# Test a floating point interval value
|
||||
log_must $ZPOOL iostat -v 0.5 1
|
||||
|
||||
log_pass "zpool iostat [pool_name ...] [interval] [count] passed"
|
||||
|
@ -51,13 +51,14 @@ else
|
||||
fi
|
||||
|
||||
set -A args "" "-?" "-f" "nonexistpool" "$TESTPOOL/$TESTFS" \
|
||||
"$testpool 1.23" "$testpool 0" "$testpool -1" "$testpool 1 0" \
|
||||
"$testpool 0 0"
|
||||
"$testpool 0" "$testpool -1" "$testpool 1 0" \
|
||||
"$testpool 0 0" "$testpool -wl" "$testpool -wq"
|
||||
|
||||
log_assert "Executing 'zpool iostat' with bad options fails"
|
||||
|
||||
typeset -i i=1
|
||||
while [[ $i -lt ${#args[*]} ]]; do
|
||||
log_assert "doing $ZPOOL iostat ${args[i]}"
|
||||
log_mustnot $ZPOOL iostat ${args[i]}
|
||||
((i = i + 1))
|
||||
done
|
||||
|
@ -0,0 +1,74 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
# Copyright (C) 2016 Lawrence Livermore National Security, LLC.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Executing 'zpool iostat' command with various combinations of extended
|
||||
# stats (-vqL), parseable/script options (-pH), and misc lists of pools
|
||||
# and vdevs.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create an array of mixed 'zpool iostat' options.
|
||||
# 2. Execute each element of the array.
|
||||
# 3. Verify an error code is returned.
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
typeset testpool
|
||||
if is_global_zone ; then
|
||||
testpool=$TESTPOOL
|
||||
else
|
||||
testpool=${TESTPOOL%%/*}
|
||||
fi
|
||||
|
||||
set -A args "" "-v" "-q" "-l" "-lq $TESTPOOL" "-ql ${DISKS[0]} ${DISKS[1]}" \
|
||||
"-w $TESTPOOL ${DISKS[0]} ${DISKS[1]}" \
|
||||
"-wp $TESTPOOL" \
|
||||
"-qlH $TESTPOOL ${DISKS[0]}" \
|
||||
"-vpH ${DISKS[0]}" \
|
||||
"-wpH ${DISKS[0]}"
|
||||
|
||||
log_assert "Executing 'zpool iostat' with extended stat options succeeds"
|
||||
log_note "testpool: $TESTPOOL, disks $DISKS"
|
||||
|
||||
typeset -i i=1
|
||||
while [[ $i -lt ${#args[*]} ]]; do
|
||||
log_note "doing $ZPOOL iostat ${args[i]}"
|
||||
log_must $ZPOOL iostat ${args[i]}
|
||||
((i = i + 1))
|
||||
done
|
||||
|
||||
log_pass "Executing 'zpool iostat' with extended stat options succeeds"
|
Loading…
Reference in New Issue
Block a user