Add ZIL statistics.
[zfs.git] / include / sys / zil.h
index 45900c9..c583887 100644 (file)
@@ -372,6 +372,65 @@ typedef struct itx {
        /* followed by type-specific part of lr_xx_t and its immediate data */
 } itx_t;
 
+/*
+ * Used for zil kstat.
+ */
+typedef struct zil_stats {
+       /*
+        * Number of times a ZIL commit (e.g. fsync) has been requested.
+        */
+       kstat_named_t zil_commit_count;
+
+       /*
+        * Number of times the ZIL has been flushed to stable storage.
+        * This is less than zil_commit_count when commits are "merged"
+        * (see the documentation above zil_commit()).
+        */
+       kstat_named_t zil_commit_writer_count;
+
+       /*
+        * Number of transactions (reads, writes, renames, etc.)
+        * that have been commited.
+        */
+       kstat_named_t zil_itx_count;
+
+       /*
+        * See the documentation for itx_wr_state_t above.
+        * Note that "bytes" accumulates the length of the transactions
+        * (i.e. data), not the actual log record sizes.
+        */
+       kstat_named_t zil_itx_indirect_count;
+       kstat_named_t zil_itx_indirect_bytes;
+       kstat_named_t zil_itx_copied_count;
+       kstat_named_t zil_itx_copied_bytes;
+       kstat_named_t zil_itx_needcopy_count;
+       kstat_named_t zil_itx_needcopy_bytes;
+
+       /*
+        * Transactions which have been allocated to the "normal"
+        * (i.e. not slog) storage pool. Note that "bytes" accumulate
+        * the actual log record sizes - which do not include the actual
+        * data in case of indirect writes.
+        */
+       kstat_named_t zil_itx_metaslab_normal_count;
+       kstat_named_t zil_itx_metaslab_normal_bytes;
+
+       /*
+        * Transactions which have been allocated to the "slog" storage pool.
+        * If there are no separate log devices, this is the same as the
+        * "normal" pool.
+        */
+       kstat_named_t zil_itx_metaslab_slog_count;
+       kstat_named_t zil_itx_metaslab_slog_bytes;
+} zil_stats_t;
+
+extern zil_stats_t zil_stats;
+
+#define ZIL_STAT_INCR(stat, val) \
+    atomic_add_64(&zil_stats.stat.value.ui64, (val));
+#define ZIL_STAT_BUMP(stat) \
+    ZIL_STAT_INCR(stat, 1);
+
 typedef int zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg,
     uint64_t txg);
 typedef int zil_parse_lr_func_t(zilog_t *zilog, lr_t *lr, void *arg,