aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/vdev_queue.c
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2013-08-26 17:09:29 -0700
committerBrian Behlendorf <[email protected]>2013-10-31 09:16:03 -0700
commit330847ff36146a427a48e79a9733dda3828284e8 (patch)
treedb3a98b0b3b48203aad38ebc4d92aa837c6764d7 /module/zfs/vdev_queue.c
parenta117a6d66e5cf1e9d4f173bccc786a169e9a8e04 (diff)
Illumos #3537
3537 want pool io kstats Reviewed by: George Wilson <[email protected]> Reviewed by: Adam Leventhal <[email protected]> Reviewed by: Eric Schrock <[email protected]> Reviewed by: Sa?o Kiselkov <[email protected]> Reviewed by: Garrett D'Amore <[email protected]> Reviewed by: Brendan Gregg <[email protected]> Approved by: Gordon Ross <[email protected]> References: http://www.illumos.org/issues/3537 illumos/illumos-gate@c3a6601 Ported by: Cyril Plisko <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Porting Notes: 1. The patch was restructured to take advantage of the existing spa statistics infrastructure. To accomplish this the kstat was moved in to spa->io_stats and the init/destroy code moved to spa_stats.c. 2. The I/O kstat was simply named <pool> which conflicted with the pool directory we had already created. Therefore it was renamed to <pool>/io 3. An update handler was added to allow the kstat to be zeroed.
Diffstat (limited to 'module/zfs/vdev_queue.c')
-rw-r--r--module/zfs/vdev_queue.c65
1 files changed, 62 insertions, 3 deletions
diff --git a/module/zfs/vdev_queue.c b/module/zfs/vdev_queue.c
index b2cc6b87f..c01990bf7 100644
--- a/module/zfs/vdev_queue.c
+++ b/module/zfs/vdev_queue.c
@@ -29,8 +29,10 @@
#include <sys/zfs_context.h>
#include <sys/vdev_impl.h>
+#include <sys/spa_impl.h>
#include <sys/zio.h>
#include <sys/avl.h>
+#include <sys/kstat.h>
/*
* These tunables are for performance analysis.
@@ -164,15 +166,72 @@ vdev_queue_fini(vdev_t *vd)
static void
vdev_queue_io_add(vdev_queue_t *vq, zio_t *zio)
{
+ spa_t *spa = zio->io_spa;
+ spa_stats_history_t *ssh = &spa->spa_stats.io_history;
+
avl_add(&vq->vq_deadline_tree, zio);
avl_add(zio->io_vdev_tree, zio);
+
+ if (ssh->kstat != NULL) {
+ mutex_enter(&ssh->lock);
+ kstat_waitq_enter(ssh->kstat->ks_data);
+ mutex_exit(&ssh->lock);
+ }
}
static void
vdev_queue_io_remove(vdev_queue_t *vq, zio_t *zio)
{
+ spa_t *spa = zio->io_spa;
+ spa_stats_history_t *ssh = &spa->spa_stats.io_history;
+
avl_remove(&vq->vq_deadline_tree, zio);
avl_remove(zio->io_vdev_tree, zio);
+
+ if (ssh->kstat != NULL) {
+ mutex_enter(&ssh->lock);
+ kstat_waitq_exit(ssh->kstat->ks_data);
+ mutex_exit(&ssh->lock);
+ }
+}
+
+static void
+vdev_queue_pending_add(vdev_queue_t *vq, zio_t *zio)
+{
+ spa_t *spa = zio->io_spa;
+ spa_stats_history_t *ssh = &spa->spa_stats.io_history;
+
+ avl_add(&vq->vq_pending_tree, zio);
+
+ if (ssh->kstat != NULL) {
+ mutex_enter(&ssh->lock);
+ kstat_runq_enter(ssh->kstat->ks_data);
+ mutex_exit(&ssh->lock);
+ }
+}
+
+static void
+vdev_queue_pending_remove(vdev_queue_t *vq, zio_t *zio)
+{
+ spa_t *spa = zio->io_spa;
+ spa_stats_history_t *ssh = &spa->spa_stats.io_history;
+
+ avl_remove(&vq->vq_pending_tree, zio);
+
+ if (ssh->kstat != NULL) {
+ kstat_io_t *ksio = ssh->kstat->ks_data;
+
+ mutex_enter(&ssh->lock);
+ kstat_runq_exit(ksio);
+ if (zio->io_type == ZIO_TYPE_READ) {
+ ksio->reads++;
+ ksio->nread += zio->io_size;
+ } else if (zio->io_type == ZIO_TYPE_WRITE) {
+ ksio->writes++;
+ ksio->nwritten += zio->io_size;
+ }
+ mutex_exit(&ssh->lock);
+ }
}
static void
@@ -351,7 +410,7 @@ again:
zio_execute(dio);
} while (dio != lio);
- avl_add(&vq->vq_pending_tree, aio);
+ vdev_queue_pending_add(vq, aio);
list_remove(&vq->vq_io_list, vi);
return (aio);
@@ -374,7 +433,7 @@ again:
goto again;
}
- avl_add(&vq->vq_pending_tree, fio);
+ vdev_queue_pending_add(vq, fio);
return (fio);
}
@@ -431,7 +490,7 @@ vdev_queue_io_done(zio_t *zio)
mutex_enter(&vq->vq_lock);
- avl_remove(&vq->vq_pending_tree, zio);
+ vdev_queue_pending_remove(vq, zio);
zio->io_delta = gethrtime() - zio->io_timestamp;
vq->vq_io_complete_ts = gethrtime();