summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_subr.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-11-18 18:17:39 +0000
committerphk <phk@FreeBSD.org>2003-11-18 18:17:39 +0000
commitd7fc6b258d3126c6aeb71b6a57bb1e3dc66ddcf7 (patch)
tree81969c37973618de3fe9d1f56b5a2b3ad328f230 /sys/geom/geom_subr.c
parent7755abc4df8e3b16a71f0400cfef42442660fd84 (diff)
downloadFreeBSD-src-d7fc6b258d3126c6aeb71b6a57bb1e3dc66ddcf7.zip
FreeBSD-src-d7fc6b258d3126c6aeb71b6a57bb1e3dc66ddcf7.tar.gz
Call class->init() an class->fini() while the class is hooked up,
rather than right before and right after. This allows these routines to manipulate the mesh. KASSERT that nobody creates a geom on an alien class. Assert topology in g_valid_obj(). Approved by: re@
Diffstat (limited to 'sys/geom/geom_subr.c')
-rw-r--r--sys/geom/geom_subr.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index f2f8820..995c113 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -92,10 +92,10 @@ g_load_class(void *arg, int flag)
("A GEOM class named %s is already loaded", mp2->name));
}
- if (mp->init != NULL)
- mp->init(mp);
LIST_INIT(&mp->geom);
LIST_INSERT_HEAD(&g_classes, mp, class);
+ if (mp->init != NULL)
+ mp->init(mp);
if (mp->taste == NULL)
return;
LIST_FOREACH(mp2, &g_classes, class) {
@@ -154,9 +154,9 @@ g_unload_class(void *arg, int flag)
break;
}
if (error == 0) {
- LIST_REMOVE(mp, class);
if (mp->fini != NULL)
mp->fini(mp);
+ LIST_REMOVE(mp, class);
}
hh->error = error;
return;
@@ -206,6 +206,7 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...)
struct sbuf *sb;
g_topology_assert();
+ KASSERT(g_valid_obj(mp), ("g_new_geom_f() on alien class %p", mp));
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
va_start(ap, fmt);
sbuf_vprintf(sb, fmt, ap);
@@ -803,6 +804,7 @@ g_valid_obj(void const *ptr)
struct g_consumer *cp;
struct g_provider *pp;
+ g_topology_assert();
LIST_FOREACH(mp, &g_classes, class) {
if (ptr == mp)
return (1);
OpenPOWER on IntegriCloud