summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-03-23 23:01:40 +0000
committerphk <phk@FreeBSD.org>2003-03-23 23:01:40 +0000
commit8e76f1cefa385812b9d3e31763425ef47ea98298 (patch)
tree829eff49c4fa2f3f599d6677149a5861299d2c65
parent3e8d794231fb21789419e92eeeb9c85d1c725ce6 (diff)
downloadFreeBSD-src-8e76f1cefa385812b9d3e31763425ef47ea98298.zip
FreeBSD-src-8e76f1cefa385812b9d3e31763425ef47ea98298.tar.gz
Introduce g_cancel_events() and use it a couple of places where it makes
sense.
-rw-r--r--sys/geom/geom_event.c22
-rw-r--r--sys/geom/geom_int.h1
-rw-r--r--sys/geom/geom_subr.c3
3 files changed, 26 insertions, 0 deletions
diff --git a/sys/geom/geom_event.c b/sys/geom/geom_event.c
index d726a01..5413a34 100644
--- a/sys/geom/geom_event.c
+++ b/sys/geom/geom_event.c
@@ -324,6 +324,28 @@ g_post_event(enum g_events ev, struct g_class *mp, struct g_geom *gp, struct g_p
wakeup(&g_wait_event);
}
+void
+g_cancel_event(struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp)
+{
+ struct g_event *ep, *epn;
+
+ mtx_lock(&g_eventlock);
+ ep = TAILQ_FIRST(&g_events);
+ for (;ep != NULL;) {
+ epn = TAILQ_NEXT(ep, events);
+ if (
+ (ep->class != NULL && ep->class == mp) ||
+ (ep->geom != NULL && ep->geom == gp) ||
+ (ep->provider != NULL && ep->provider == pp) ||
+ (ep->consumer != NULL && ep->consumer == cp)) {
+ TAILQ_REMOVE(&g_events, ep, events);
+ g_free(ep);
+ }
+ ep = epn;
+ }
+ mtx_unlock(&g_eventlock);
+}
+
int
g_call_me(g_call_me_t *func, void *arg)
{
diff --git a/sys/geom/geom_int.h b/sys/geom/geom_int.h
index b56895b..26b3d78 100644
--- a/sys/geom/geom_int.h
+++ b/sys/geom/geom_int.h
@@ -93,6 +93,7 @@ void g_conftxt(void *);
/* geom_event.c */
void g_event_init(void);
void g_post_event(enum g_events ev, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
+void g_cancel_event(struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
void g_run_events(void);
void g_stall_events(void);
void g_release_events(void);
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index b5c1861..f047b59 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -126,6 +126,7 @@ g_destroy_geom(struct g_geom *gp)
KASSERT(LIST_EMPTY(&gp->provider),
("g_destroy_geom(%s) with provider(s) [%p]",
gp->name, LIST_FIRST(&gp->consumer)));
+ g_cancel_event(NULL, gp, NULL, NULL);
LIST_REMOVE(gp, geom);
TAILQ_REMOVE(&geoms, gp, geoms);
g_free(gp->name);
@@ -162,6 +163,7 @@ g_destroy_consumer(struct g_consumer *cp)
KASSERT (cp->acr == 0, ("g_destroy_consumer with acr"));
KASSERT (cp->acw == 0, ("g_destroy_consumer with acw"));
KASSERT (cp->ace == 0, ("g_destroy_consumer with ace"));
+ g_cancel_event(NULL, NULL, NULL, cp);
LIST_REMOVE(cp, consumer);
devstat_remove_entry(cp->stat);
g_free(cp);
@@ -216,6 +218,7 @@ g_destroy_provider(struct g_provider *pp)
KASSERT (pp->acr == 0, ("g_destroy_provider with acr"));
KASSERT (pp->acw == 0, ("g_destroy_provider with acw"));
KASSERT (pp->acw == 0, ("g_destroy_provider with ace"));
+ g_cancel_event(NULL, NULL, pp, NULL);
g_nproviders--;
LIST_REMOVE(pp, provider);
gp = pp->geom;
OpenPOWER on IntegriCloud