aboutsummaryrefslogtreecommitdiff
path: root/sys/geom/geom_io.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2003-02-08 13:03:57 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2003-02-08 13:03:57 +0000
commit4ec353005cc7d720a55f03f52db5d28f9e4af6e3 (patch)
treeee0ea82e7a7c15d53378207492946755ff1ca6b9 /sys/geom/geom_io.c
parent91cd3dc6f5accad6c5f2781fe71d4cba4f65f369 (diff)
downloadsrc-4ec353005cc7d720a55f03f52db5d28f9e4af6e3.tar.gz
src-4ec353005cc7d720a55f03f52db5d28f9e4af6e3.zip
Move the g_stat struct to its own .h file, we will export it to other code.
Insted of embedding a struct g_stat in consumers and providers, merely include a pointer. Remove a couple of <sys/time.h> includes now unneeded. Add a special allocator for struct g_stat. This allocator will allocate entire pages and hand out g_stat functions from there. The "id" field indicates free/used status. Add "/dev/geom.stats" device driver whic exports the pages from the allocator to userland with mmap(2) in read-only mode. This mmap(2) interface should be considered a non-public interface and the functions in libgeom (not yet committed) should be used to access the statistics data.
Notes
Notes: svn path=/head/; revision=110541
Diffstat (limited to 'sys/geom/geom_io.c')
-rw-r--r--sys/geom/geom_io.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index 842595afbf9e..865f5840a623 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -55,6 +55,7 @@
#include <sys/errno.h>
#include <geom/geom.h>
#include <geom/geom_int.h>
+#include <geom/geom_stats.h>
static struct g_bioq g_bio_run_down;
static struct g_bioq g_bio_run_up;
@@ -278,25 +279,25 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
if (g_collectstats) {
/* Collect statistics */
binuptime(&bp->bio_t0);
- if (cp->stat.nop == cp->stat.nend) {
+ if (cp->stat->nop == cp->stat->nend) {
/* Consumer is idle */
bt = bp->bio_t0;
- bintime_sub(&bt, &cp->stat.wentidle);
- bintime_add(&cp->stat.it, &bt);
- if (pp->stat.nop == pp->stat.nend) {
+ bintime_sub(&bt, &cp->stat->wentidle);
+ bintime_add(&cp->stat->it, &bt);
+ if (pp->stat->nop == pp->stat->nend) {
/*
* NB: Provider can only be idle if the
* consumer is but we cannot trust them
* to have gone idle at the same time.
*/
bt = bp->bio_t0;
- bintime_sub(&bt, &pp->stat.wentidle);
- bintime_add(&pp->stat.it, &bt);
+ bintime_sub(&bt, &pp->stat->wentidle);
+ bintime_add(&pp->stat->it, &bt);
}
}
}
- cp->stat.nop++;
- pp->stat.nop++;
+ cp->stat->nop++;
+ pp->stat->nop++;
/* Pass it on down. */
g_trace(G_T_BIO, "bio_request(%p) from %p(%s) to %p(%s) cmd %d",
@@ -339,29 +340,29 @@ g_io_deliver(struct bio *bp, int error)
/* Collect statistics */
if (g_collectstats) {
binuptime(&t1);
- pp->stat.wentidle = t1;
- cp->stat.wentidle = t1;
+ pp->stat->wentidle = t1;
+ cp->stat->wentidle = t1;
if (idx >= 0) {
bintime_sub(&t1, &bp->bio_t0);
- bintime_add(&cp->stat.ops[idx].dt, &t1);
- bintime_add(&pp->stat.ops[idx].dt, &t1);
- pp->stat.ops[idx].nbyte += bp->bio_completed;
- cp->stat.ops[idx].nbyte += bp->bio_completed;
- pp->stat.ops[idx].nop++;
- cp->stat.ops[idx].nop++;
+ bintime_add(&cp->stat->ops[idx].dt, &t1);
+ bintime_add(&pp->stat->ops[idx].dt, &t1);
+ pp->stat->ops[idx].nbyte += bp->bio_completed;
+ cp->stat->ops[idx].nbyte += bp->bio_completed;
+ pp->stat->ops[idx].nop++;
+ cp->stat->ops[idx].nop++;
if (error == ENOMEM) {
- cp->stat.ops[idx].nmem++;
- pp->stat.ops[idx].nmem++;
+ cp->stat->ops[idx].nmem++;
+ pp->stat->ops[idx].nmem++;
} else if (error != 0) {
- cp->stat.ops[idx].nerr++;
- pp->stat.ops[idx].nerr++;
+ cp->stat->ops[idx].nerr++;
+ pp->stat->ops[idx].nerr++;
}
}
}
- pp->stat.nend++; /* In reverse order of g_io_request() */
- cp->stat.nend++;
+ pp->stat->nend++; /* In reverse order of g_io_request() */
+ cp->stat->nend++;
if (error == ENOMEM) {
printf("ENOMEM %p on %p(%s)\n", bp, pp, pp->name);