aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/spa_stats.c
diff options
context:
space:
mode:
authorOlaf Faaland <[email protected]>2018-02-22 15:34:34 -0800
committerBrian Behlendorf <[email protected]>2018-02-22 15:34:34 -0800
commit7088545d0166aa05b2c783f18aa821d95a1f023d (patch)
tree18d65e20a458db4c8c67a2ddeb24ff12a83d4aef /module/zfs/spa_stats.c
parent0d398b25644ff1eb67141629bc6e5aead95edeba (diff)
Report duration and error in mmp_history entries
After an MMP write completes, update the relevant mmp_history entry with the time between submission and completion, and the error status of the write. [faaland1@toss3a zfs]$ cat /proc/spl/kstat/zfs/pool/multihost 39 0 0x01 100 8800 69147946270893 72723903122926 id txg timestamp error duration mmp_delay vdev_guid 10607 1166 1518985089 0 138301 637785455 4882... 10608 1166 1518985089 0 136154 635407747 1151... 10609 1166 1518985089 0 803618560 633048078 9740... 10610 1166 1518985090 0 144826 633048078 4882... 10611 1166 1518985090 0 164527 666187671 1151... Where duration = gethrtime_in_done_fn - gethrtime_at_submission, and error = zio->io_error. Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Olaf Faaland <[email protected]> Closes #7190
Diffstat (limited to 'module/zfs/spa_stats.c')
-rw-r--r--module/zfs/spa_stats.c54
1 files changed, 44 insertions, 10 deletions
diff --git a/module/zfs/spa_stats.c b/module/zfs/spa_stats.c
index 3eeb83a50..c560d642f 100644
--- a/module/zfs/spa_stats.c
+++ b/module/zfs/spa_stats.c
@@ -722,21 +722,24 @@ spa_io_history_destroy(spa_t *spa)
*/
typedef struct spa_mmp_history {
+ uint64_t mmp_kstat_id; /* unique # for updates */
uint64_t txg; /* txg of last sync */
uint64_t timestamp; /* UTC time of of last sync */
uint64_t mmp_delay; /* nanosec since last MMP write */
uint64_t vdev_guid; /* unique ID of leaf vdev */
char *vdev_path;
uint64_t vdev_label; /* vdev label */
+ int io_error; /* error status of MMP write */
+ hrtime_t duration; /* time from submission to completion */
list_node_t smh_link;
} spa_mmp_history_t;
static int
spa_mmp_history_headers(char *buf, size_t size)
{
- (void) snprintf(buf, size, "%-10s %-10s %-12s %-24s %-10s %s\n",
- "txg", "timestamp", "mmp_delay", "vdev_guid", "vdev_label",
- "vdev_path");
+ (void) snprintf(buf, size, "%-10s %-10s %-10s %-6s %-10s %-12s %-24s "
+ "%-10s %s\n", "id", "txg", "timestamp", "error", "duration",
+ "mmp_delay", "vdev_guid", "vdev_label", "vdev_path");
return (0);
}
@@ -745,11 +748,12 @@ spa_mmp_history_data(char *buf, size_t size, void *data)
{
spa_mmp_history_t *smh = (spa_mmp_history_t *)data;
- (void) snprintf(buf, size, "%-10llu %-10llu %-12llu %-24llu %-10llu "
- "%s\n",
- (u_longlong_t)smh->txg, (u_longlong_t)smh->timestamp,
- (u_longlong_t)smh->mmp_delay, (u_longlong_t)smh->vdev_guid,
- (u_longlong_t)smh->vdev_label,
+ (void) snprintf(buf, size, "%-10llu %-10llu %-10llu %-6lld %-10lld "
+ "%-12llu %-24llu %-10llu %s\n",
+ (u_longlong_t)smh->mmp_kstat_id, (u_longlong_t)smh->txg,
+ (u_longlong_t)smh->timestamp, (longlong_t)smh->io_error,
+ (longlong_t)smh->duration, (u_longlong_t)smh->mmp_delay,
+ (u_longlong_t)smh->vdev_guid, (u_longlong_t)smh->vdev_label,
(smh->vdev_path ? smh->vdev_path : "-"));
return (0);
@@ -866,11 +870,40 @@ spa_mmp_history_destroy(spa_t *spa)
}
/*
- * Add a new MMP update to historical record.
+ * Set MMP write duration and error status in existing record.
+ */
+int
+spa_mmp_history_set(spa_t *spa, uint64_t mmp_kstat_id, int io_error,
+ hrtime_t duration)
+{
+ spa_stats_history_t *ssh = &spa->spa_stats.mmp_history;
+ spa_mmp_history_t *smh;
+ int error = ENOENT;
+
+ if (zfs_multihost_history == 0 && ssh->size == 0)
+ return (0);
+
+ mutex_enter(&ssh->lock);
+ for (smh = list_head(&ssh->list); smh != NULL;
+ smh = list_next(&ssh->list, smh)) {
+ if (smh->mmp_kstat_id == mmp_kstat_id) {
+ smh->io_error = io_error;
+ smh->duration = duration;
+ error = 0;
+ break;
+ }
+ }
+ mutex_exit(&ssh->lock);
+
+ return (error);
+}
+
+/*
+ * Add a new MMP write to historical record.
*/
void
spa_mmp_history_add(uint64_t txg, uint64_t timestamp, uint64_t mmp_delay,
- vdev_t *vd, int label)
+ vdev_t *vd, int label, uint64_t mmp_kstat_id)
{
spa_t *spa = vd->vdev_spa;
spa_stats_history_t *ssh = &spa->spa_stats.mmp_history;
@@ -887,6 +920,7 @@ spa_mmp_history_add(uint64_t txg, uint64_t timestamp, uint64_t mmp_delay,
if (vd->vdev_path)
smh->vdev_path = strdup(vd->vdev_path);
smh->vdev_label = label;
+ smh->mmp_kstat_id = mmp_kstat_id;
mutex_enter(&ssh->lock);