summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
authorek110237 <none@none>2008-01-10 14:51:22 -0800
committerek110237 <none@none>2008-01-10 14:51:22 -0800
commit87db74c14be24ab4c463ce6ddb7127e271c647bf (patch)
tree6c41e3048c9e33b69ab3482aa3c4999942558af2 /usr/src/uts
parent98f34ea2b2c1eedcff1244c72e0961564fc7f65a (diff)
downloadillumos-gate-87db74c14be24ab4c463ce6ddb7127e271c647bf.tar.gz
6649150 add kstats to the vdev cache
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/fs/zfs/spa_misc.c4
-rw-r--r--usr/src/uts/common/fs/zfs/sys/spa.h6
-rw-r--r--usr/src/uts/common/fs/zfs/vdev_cache.c57
3 files changed, 57 insertions, 10 deletions
diff --git a/usr/src/uts/common/fs/zfs/spa_misc.c b/usr/src/uts/common/fs/zfs/spa_misc.c
index 6b1c28140a..311bec6da7 100644
--- a/usr/src/uts/common/fs/zfs/spa_misc.c
+++ b/usr/src/uts/common/fs/zfs/spa_misc.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1234,6 +1234,7 @@ spa_init(int mode)
zio_init();
dmu_init();
zil_init();
+ vdev_cache_stat_init();
zfs_prop_init();
zpool_prop_init();
spa_config_load();
@@ -1244,6 +1245,7 @@ spa_fini(void)
{
spa_evict_all();
+ vdev_cache_stat_fini();
zil_fini();
dmu_fini();
zio_fini();
diff --git a/usr/src/uts/common/fs/zfs/sys/spa.h b/usr/src/uts/common/fs/zfs/sys/spa.h
index dd723df0c9..713817d89c 100644
--- a/usr/src/uts/common/fs/zfs/sys/spa.h
+++ b/usr/src/uts/common/fs/zfs/sys/spa.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -495,6 +495,10 @@ extern void spa_errlog_drain(spa_t *spa);
extern void spa_errlog_sync(spa_t *spa, uint64_t txg);
extern void spa_get_errlists(spa_t *spa, avl_tree_t *last, avl_tree_t *scrub);
+/* vdev cache */
+extern void vdev_cache_stat_init(void);
+extern void vdev_cache_stat_fini(void);
+
/* Initialization and termination */
extern void spa_init(int flags);
extern void spa_fini(void);
diff --git a/usr/src/uts/common/fs/zfs/vdev_cache.c b/usr/src/uts/common/fs/zfs/vdev_cache.c
index 5f475f9b47..2cc059e49e 100644
--- a/usr/src/uts/common/fs/zfs/vdev_cache.c
+++ b/usr/src/uts/common/fs/zfs/vdev_cache.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -29,6 +29,7 @@
#include <sys/spa.h>
#include <sys/vdev_impl.h>
#include <sys/zio.h>
+#include <sys/kstat.h>
/*
* Virtual device read-ahead caching.
@@ -36,10 +37,10 @@
* This file implements a simple LRU read-ahead cache. When the DMU reads
* a given block, it will often want other, nearby blocks soon thereafter.
* We take advantage of this by reading a larger disk region and caching
- * the result. In the best case, this can turn 256 back-to-back 512-byte
- * reads into a single 128k read followed by 255 cache hits; this reduces
+ * the result. In the best case, this can turn 128 back-to-back 512-byte
+ * reads into a single 64k read followed by 127 cache hits; this reduces
* latency dramatically. In the worst case, it can turn an isolated 512-byte
- * read into a 128k read, which doesn't affect latency all that much but is
+ * read into a 64k read, which doesn't affect latency all that much but is
* terribly wasteful of bandwidth. A more intelligent version of the cache
* could keep track of access patterns and not do read-ahead unless it sees
* at least two temporally close I/Os to the same region. Currently, only
@@ -70,14 +71,30 @@
/*
* All i/os smaller than zfs_vdev_cache_max will be turned into
* 1<<zfs_vdev_cache_bshift byte reads by the vdev_cache (aka software
- * track buffer. At most zfs_vdev_cache_size bytes will be kept in each
+ * track buffer). At most zfs_vdev_cache_size bytes will be kept in each
* vdev's vdev_cache.
*/
-int zfs_vdev_cache_max = 1<<14;
-int zfs_vdev_cache_size = 10ULL << 20;
+int zfs_vdev_cache_max = 1<<14; /* 16KB */
+int zfs_vdev_cache_size = 10ULL << 20; /* 10MB */
int zfs_vdev_cache_bshift = 16;
-#define VCBS (1 << zfs_vdev_cache_bshift)
+#define VCBS (1 << zfs_vdev_cache_bshift) /* 64KB */
+
+kstat_t *vdc_ksp = NULL;
+
+typedef struct vdc_stats {
+ kstat_named_t vdc_stat_delegations;
+ kstat_named_t vdc_stat_hits;
+ kstat_named_t vdc_stat_misses;
+} vdc_stats_t;
+
+static vdc_stats_t vdc_stats = {
+ { "delegations", KSTAT_DATA_UINT64 },
+ { "hits", KSTAT_DATA_UINT64 },
+ { "misses", KSTAT_DATA_UINT64 }
+};
+
+#define VDCSTAT_BUMP(stat) atomic_add_64(&vdc_stats.stat.value.ui64, 1);
static int
vdev_cache_offset_compare(const void *a1, const void *a2)
@@ -279,6 +296,7 @@ vdev_cache_read(zio_t *zio)
fio->io_delegate_list = zio;
zio_vdev_io_bypass(zio);
mutex_exit(&vc->vc_lock);
+ VDCSTAT_BUMP(vdc_stat_delegations);
return (0);
}
@@ -287,6 +305,7 @@ vdev_cache_read(zio_t *zio)
mutex_exit(&vc->vc_lock);
zio_execute(zio);
+ VDCSTAT_BUMP(vdc_stat_hits);
return (0);
}
@@ -309,6 +328,7 @@ vdev_cache_read(zio_t *zio)
mutex_exit(&vc->vc_lock);
zio_nowait(fio);
+ VDCSTAT_BUMP(vdc_stat_misses);
return (0);
}
@@ -392,3 +412,24 @@ vdev_cache_fini(vdev_t *vd)
mutex_destroy(&vc->vc_lock);
}
+
+void
+vdev_cache_stat_init(void)
+{
+ vdc_ksp = kstat_create("zfs", 0, "vdev_cache_stats", "misc",
+ KSTAT_TYPE_NAMED, sizeof (vdc_stats) / sizeof (kstat_named_t),
+ KSTAT_FLAG_VIRTUAL);
+ if (vdc_ksp != NULL) {
+ vdc_ksp->ks_data = &vdc_stats;
+ kstat_install(vdc_ksp);
+ }
+}
+
+void
+vdev_cache_stat_fini(void)
+{
+ if (vdc_ksp != NULL) {
+ kstat_delete(vdc_ksp);
+ vdc_ksp = NULL;
+ }
+}