summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_subr.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-02-08 13:03:57 +0000
committerphk <phk@FreeBSD.org>2003-02-08 13:03:57 +0000
commit04a4ba381f551a8fb24d018a99d63e4b8a4eec00 (patch)
treeee0ea82e7a7c15d53378207492946755ff1ca6b9 /sys/geom/geom_subr.c
parent15f4f6a52b122bc25685c03d547db8506a57b97a (diff)
downloadFreeBSD-src-04a4ba381f551a8fb24d018a99d63e4b8a4eec00.zip
FreeBSD-src-04a4ba381f551a8fb24d018a99d63e4b8a4eec00.tar.gz
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.
Diffstat (limited to 'sys/geom/geom_subr.c')
-rw-r--r--sys/geom/geom_subr.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index d8b3054..237e199 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -60,6 +60,7 @@
#include <sys/sbuf.h>
#include <geom/geom.h>
#include <geom/geom_int.h>
+#include <geom/geom_stats.h>
#include <machine/stdarg.h>
struct class_list_head g_classes = LIST_HEAD_INITIALIZER(g_classes);
@@ -145,7 +146,7 @@ g_new_consumer(struct g_geom *gp)
cp = g_malloc(sizeof *cp, M_ZERO);
cp->protect = 0x020016602;
cp->geom = gp;
- cp->stat.id = cp;
+ cp->stat = g_stat_new(cp);
LIST_INSERT_HEAD(&gp->consumer, cp, consumer);
return(cp);
}
@@ -162,6 +163,7 @@ g_destroy_consumer(struct g_consumer *cp)
KASSERT (cp->acw == 0, ("g_destroy_consumer with acw"));
KASSERT (cp->ace == 0, ("g_destroy_consumer with ace"));
LIST_REMOVE(cp, consumer);
+ g_stat_delete(cp->stat);
g_free(cp);
}
@@ -185,7 +187,7 @@ g_new_providerf(struct g_geom *gp, const char *fmt, ...)
LIST_INIT(&pp->consumers);
pp->error = ENXIO;
pp->geom = gp;
- pp->stat.id = pp;
+ pp->stat = g_stat_new(pp);
LIST_INSERT_HEAD(&gp->provider, pp, provider);
g_nproviders++;
g_post_event(EV_NEW_PROVIDER, NULL, NULL, pp, NULL);
@@ -216,6 +218,7 @@ g_destroy_provider(struct g_provider *pp)
g_nproviders--;
LIST_REMOVE(pp, provider);
gp = pp->geom;
+ g_stat_delete(pp->stat);
g_free(pp);
if (!(gp->flags & G_GEOM_WITHER))
return;
@@ -329,7 +332,8 @@ g_detach(struct g_consumer *cp)
KASSERT(cp->acr == 0, ("detach but nonzero acr"));
KASSERT(cp->acw == 0, ("detach but nonzero acw"));
KASSERT(cp->ace == 0, ("detach but nonzero ace"));
- KASSERT(cp->stat.nop == cp->stat.nend, ("detach with active requests"));
+ KASSERT(cp->stat->nop == cp->stat->nend,
+ ("detach with active requests"));
pp = cp->provider;
LIST_REMOVE(cp, consumers);
cp->provider = NULL;
OpenPOWER on IntegriCloud