summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2012-10-22 16:57:27 -0700
committerBrian Behlendorf <[email protected]>2012-11-02 15:17:40 -0700
commitdba79fcbf2cc50be5caef84ae01657e884ac5d89 (patch)
tree45071c65d0cf08c261574edb09aff0401e919a5e /module
parent71c9f0b00307e6ee703eef9eba91e7640731c458 (diff)
Add KSTAT_TYPE_TXG type
Add a new kstat type for tracking useful statistics about a TXG. The new KSTAT_TYPE_TXG type can be used to tracks the following statistics per-txg. txg - Unique txg number state - State (O)pen/(Q)uiescing/(S)yncing/(C)ommitted birth; - Creation time nread - Bytes read nwritten; - Bytes written reads - IOPs read writes - IOPs write open_time; - Length in nanoseconds the txg was open quiesce_time - Length in nanoseconds the txg was quiescing sync_time; - Length in nanoseconds the txg was syncing Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module')
-rw-r--r--module/spl/spl-kstat.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/module/spl/spl-kstat.c b/module/spl/spl-kstat.c
index 164a8436d..ea2d67dd4 100644
--- a/module/spl/spl-kstat.c
+++ b/module/spl/spl-kstat.c
@@ -78,6 +78,14 @@ kstat_seq_show_headers(struct seq_file *f)
"name", "events", "elapsed",
"min", "max", "start", "stop");
break;
+ case KSTAT_TYPE_TXG:
+ seq_printf(f,
+ "%-8s %-5s %-13s %-12s %-12s %-8s %-8s "
+ "%-12s %-12s %-12s\n",
+ "txg", "state", "birth",
+ "nread", "nwritten", "reads", "writes",
+ "otime", "qtime", "stime");
+ break;
default:
PANIC("Undefined kstat type %d\n", ksp->ks_type);
}
@@ -191,6 +199,27 @@ kstat_seq_show_timer(struct seq_file *f, kstat_timer_t *ktp)
}
static int
+kstat_seq_show_txg(struct seq_file *f, kstat_txg_t *ktp)
+{
+ char state;
+
+ switch (ktp->state) {
+ case TXG_STATE_OPEN: state = 'O'; break;
+ case TXG_STATE_QUIESCING: state = 'Q'; break;
+ case TXG_STATE_SYNCING: state = 'S'; break;
+ case TXG_STATE_COMMITTED: state = 'C'; break;
+ default: state = '?'; break;
+ }
+
+ seq_printf(f,
+ "%-8llu %-5c %-13llu %-12llu %-12llu %-8u %-8u "
+ "%12lld %12lld %12lld\n", ktp->txg, state, ktp->birth,
+ ktp->nread, ktp->nwritten, ktp->reads, ktp->writes,
+ ktp->open_time, ktp->quiesce_time, ktp->sync_time);
+ return 0;
+}
+
+static int
kstat_seq_show(struct seq_file *f, void *p)
{
kstat_t *ksp = (kstat_t *)f->private;
@@ -216,6 +245,9 @@ kstat_seq_show(struct seq_file *f, void *p)
case KSTAT_TYPE_TIMER:
rc = kstat_seq_show_timer(f, (kstat_timer_t *)p);
break;
+ case KSTAT_TYPE_TXG:
+ rc = kstat_seq_show_txg(f, (kstat_txg_t *)p);
+ break;
default:
PANIC("Undefined kstat type %d\n", ksp->ks_type);
}
@@ -252,6 +284,9 @@ kstat_seq_data_addr(kstat_t *ksp, loff_t n)
case KSTAT_TYPE_TIMER:
rc = ksp->ks_data + n * sizeof(kstat_timer_t);
break;
+ case KSTAT_TYPE_TXG:
+ rc = ksp->ks_data + n * sizeof(kstat_txg_t);
+ break;
default:
PANIC("Undefined kstat type %d\n", ksp->ks_type);
}
@@ -396,6 +431,10 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
ksp->ks_ndata = ks_ndata;
ksp->ks_data_size = ks_ndata * sizeof(kstat_timer_t);
break;
+ case KSTAT_TYPE_TXG:
+ ksp->ks_ndata = ks_ndata;
+ ksp->ks_data_size = ks_ndata * sizeof(kstat_timer_t);
+ break;
default:
PANIC("Undefined kstat type %d\n", ksp->ks_type);
}