diff options
author | phk <phk@FreeBSD.org> | 2003-03-23 21:58:09 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-03-23 21:58:09 +0000 |
commit | 3e8d794231fb21789419e92eeeb9c85d1c725ce6 (patch) | |
tree | f71a7377e8d41b95cc664295bc75fa613ea937da /sys/geom | |
parent | 501da8bd5fca79615b73eea3d6f9cd46f4247456 (diff) | |
download | FreeBSD-src-3e8d794231fb21789419e92eeeb9c85d1c725ce6.zip FreeBSD-src-3e8d794231fb21789419e92eeeb9c85d1c725ce6.tar.gz |
Introduce an SX lock which allows us to stall event processing
during OAM operations.
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom_event.c | 19 | ||||
-rw-r--r-- | sys/geom/geom_int.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/sys/geom/geom_event.c b/sys/geom/geom_event.c index 73525e0..d726a01 100644 --- a/sys/geom/geom_event.c +++ b/sys/geom/geom_event.c @@ -66,6 +66,7 @@ static u_int g_pending_events; static void g_do_event(struct g_event *ep); static TAILQ_HEAD(,g_provider) g_doorstep = TAILQ_HEAD_INITIALIZER(g_doorstep); static struct mtx g_eventlock; +static struct sx g_eventstall; static int g_shutdown; void @@ -77,6 +78,20 @@ g_waitidle(void) } void +g_stall_events(void) +{ + + sx_slock(&g_eventstall); +} + +void +g_release_events(void) +{ + + sx_sunlock(&g_eventstall); +} + +void g_orphan_provider(struct g_provider *pp, int error) { @@ -220,6 +235,7 @@ one_event(void) struct g_event *ep; struct g_provider *pp; + sx_xlock(&g_eventstall); g_topology_lock(); for (;;) { mtx_lock(&g_eventlock); @@ -236,6 +252,7 @@ one_event(void) if (ep == NULL) { mtx_unlock(&g_eventlock); g_topology_unlock(); + sx_xunlock(&g_eventstall); return (0); } TAILQ_REMOVE(&g_events, ep, events); @@ -254,6 +271,7 @@ one_event(void) if (g_pending_events == 0) wakeup(&g_pending_events); g_topology_unlock(); + sx_xunlock(&g_eventstall); return (1); } @@ -345,4 +363,5 @@ g_event_init() SHUTDOWN_PRI_FIRST); #endif mtx_init(&g_eventlock, "GEOM orphanage", NULL, MTX_DEF); + sx_init(&g_eventstall, "GEOM event stalling"); } diff --git a/sys/geom/geom_int.h b/sys/geom/geom_int.h index 0b556704..b56895b 100644 --- a/sys/geom/geom_int.h +++ b/sys/geom/geom_int.h @@ -94,6 +94,8 @@ void g_conftxt(void *); 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_run_events(void); +void g_stall_events(void); +void g_release_events(void); /* geom_subr.c */ extern struct class_list_head g_classes; |