svn commit: r262170 - in stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys
Andriy Gapon
avg at FreeBSD.org
Tue Feb 18 15:07:26 UTC 2014
Author: avg
Date: Tue Feb 18 15:07:24 2014
New Revision: 262170
URL: http://svnweb.freebsd.org/changeset/base/262170
Log:
MFC r254608: Add kstat entries for ZFS compression statistics
MFC slacker: gibbs
Modified:
stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_compress.h
stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_compress.c
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/cddl/contrib/opensolaris/ (props changed)
Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Tue Feb 18 15:05:09 2014 (r262169)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Tue Feb 18 15:07:24 2014 (r262170)
@@ -1893,6 +1893,7 @@ dmu_init(void)
dnode_init();
dbuf_init();
zfetch_init();
+ zio_compress_init();
l2arc_init();
arc_init();
}
@@ -1903,6 +1904,7 @@ dmu_fini(void)
arc_fini(); /* arc depends on l2arc, so arc must go first */
l2arc_fini();
zfetch_fini();
+ zio_compress_fini();
dbuf_fini();
dnode_fini();
dmu_objset_fini();
Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_compress.h
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_compress.h Tue Feb 18 15:05:09 2014 (r262169)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_compress.h Tue Feb 18 15:07:24 2014 (r262170)
@@ -85,6 +85,12 @@ extern size_t zio_compress_data(enum zio
extern int zio_decompress_data(enum zio_compress c, void *src, void *dst,
size_t s_len, size_t d_len);
+/*
+ * Module lifetime management.
+ */
+extern void zio_compress_init(void);
+extern void zio_compress_fini(void);
+
#ifdef __cplusplus
}
#endif
Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_compress.c
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_compress.c Tue Feb 18 15:05:09 2014 (r262169)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_compress.c Tue Feb 18 15:07:24 2014 (r262170)
@@ -33,10 +33,32 @@
#include <sys/zfs_context.h>
#include <sys/compress.h>
+#include <sys/kstat.h>
#include <sys/spa.h>
#include <sys/zio.h>
#include <sys/zio_compress.h>
+typedef struct zcomp_stats {
+ kstat_named_t zcompstat_attempts;
+ kstat_named_t zcompstat_empty;
+ kstat_named_t zcompstat_skipped_minblocksize;
+ kstat_named_t zcompstat_skipped_insufficient_gain;
+} zcomp_stats_t;
+
+static zcomp_stats_t zcomp_stats = {
+ { "attempts", KSTAT_DATA_UINT64 },
+ { "empty", KSTAT_DATA_UINT64 },
+ { "skipped_minblocksize", KSTAT_DATA_UINT64 },
+ { "skipped_insufficient_gain", KSTAT_DATA_UINT64 }
+};
+
+#define ZCOMPSTAT_INCR(stat, val) \
+ atomic_add_64(&zcomp_stats.stat.value.ui64, (val));
+
+#define ZCOMPSTAT_BUMP(stat) ZCOMPSTAT_INCR(stat, 1);
+
+kstat_t *zcomp_ksp;
+
/*
* Compression vectors.
*/
@@ -87,6 +109,8 @@ zio_compress_data(enum zio_compress c, v
ASSERT((uint_t)c < ZIO_COMPRESS_FUNCTIONS);
ASSERT((uint_t)c == ZIO_COMPRESS_EMPTY || ci->ci_compress != NULL);
+ ZCOMPSTAT_BUMP(zcompstat_attempts);
+
/*
* If the data is all zeroes, we don't even need to allocate
* a block for it. We indicate this by returning zero size.
@@ -96,21 +120,27 @@ zio_compress_data(enum zio_compress c, v
if (*word != 0)
break;
- if (word == word_end)
- return (0);
+ if (word == word_end) {
+ ZCOMPSTAT_BUMP(zcompstat_empty);
+ return (0);
+ }
if (c == ZIO_COMPRESS_EMPTY)
return (s_len);
/* Compress at least 12.5% */
d_len = P2ALIGN(s_len - (s_len >> 3), minblocksize);
- if (d_len == 0)
+ if (d_len == 0) {
+ ZCOMPSTAT_BUMP(zcompstat_skipped_minblocksize);
return (s_len);
+ }
c_len = ci->ci_compress(src, dst, s_len, d_len, ci->ci_level);
- if (c_len > d_len)
+ if (c_len > d_len) {
+ ZCOMPSTAT_BUMP(zcompstat_skipped_insufficient_gain);
return (s_len);
+ }
/*
* Cool. We compressed at least as much as we were hoping to.
@@ -139,3 +169,26 @@ zio_decompress_data(enum zio_compress c,
return (ci->ci_decompress(src, dst, s_len, d_len, ci->ci_level));
}
+
+void
+zio_compress_init(void)
+{
+
+ zcomp_ksp = kstat_create("zfs", 0, "zcompstats", "misc",
+ KSTAT_TYPE_NAMED, sizeof (zcomp_stats) / sizeof (kstat_named_t),
+ KSTAT_FLAG_VIRTUAL);
+
+ if (zcomp_ksp != NULL) {
+ zcomp_ksp->ks_data = &zcomp_stats;
+ kstat_install(zcomp_ksp);
+ }
+}
+
+void
+zio_compress_fini(void)
+{
+ if (zcomp_ksp != NULL) {
+ kstat_delete(zcomp_ksp);
+ zcomp_ksp = NULL;
+ }
+}
More information about the svn-src-stable-9
mailing list