geom_event.c (113432) | geom_event.c (113926) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $FreeBSD: head/sys/geom/geom_event.c 113432 2003-04-13 09:02:06Z phk $ | 35 * $FreeBSD: head/sys/geom/geom_event.c 113926 2003-04-23 19:15:27Z phk $ |
36 */ 37 38/* 39 * XXX: How do we in general know that objects referenced in events 40 * have not been destroyed before we get around to handle the event ? 41 */ 42 43#include <sys/param.h> 44#include <sys/malloc.h> 45#include <sys/systm.h> 46#include <sys/kernel.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> | 36 */ 37 38/* 39 * XXX: How do we in general know that objects referenced in events 40 * have not been destroyed before we get around to handle the event ? 41 */ 42 43#include <sys/param.h> 44#include <sys/malloc.h> 45#include <sys/systm.h> 46#include <sys/kernel.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> |
49#include <sys/eventhandler.h> | |
50#include <machine/stdarg.h> 51#include <sys/errno.h> 52#include <sys/time.h> 53#include <geom/geom.h> 54#include <geom/geom_int.h> 55 56static struct event_tailq_head g_events = TAILQ_HEAD_INITIALIZER(g_events); 57static u_int g_pending_events; 58static void g_do_event(struct g_event *ep); 59static TAILQ_HEAD(,g_provider) g_doorstep = TAILQ_HEAD_INITIALIZER(g_doorstep); 60static struct mtx g_eventlock; 61static struct sx g_eventstall; | 49#include <machine/stdarg.h> 50#include <sys/errno.h> 51#include <sys/time.h> 52#include <geom/geom.h> 53#include <geom/geom_int.h> 54 55static struct event_tailq_head g_events = TAILQ_HEAD_INITIALIZER(g_events); 56static u_int g_pending_events; 57static void g_do_event(struct g_event *ep); 58static TAILQ_HEAD(,g_provider) g_doorstep = TAILQ_HEAD_INITIALIZER(g_doorstep); 59static struct mtx g_eventlock; 60static struct sx g_eventstall; |
62static int g_shutdown; | |
63 64void 65g_waitidle(void) 66{ 67 68 while (g_pending_events) 69 tsleep(&g_pending_events, PPAUSE, "g_waitidle", hz/5); 70} --- 272 unchanged lines hidden (view full) --- 343 mtx_lock(&g_eventlock); 344 g_pending_events++; 345 TAILQ_INSERT_TAIL(&g_events, ep, events); 346 mtx_unlock(&g_eventlock); 347 wakeup(&g_wait_event); 348 return (0); 349} 350 | 61 62void 63g_waitidle(void) 64{ 65 66 while (g_pending_events) 67 tsleep(&g_pending_events, PPAUSE, "g_waitidle", hz/5); 68} --- 272 unchanged lines hidden (view full) --- 341 mtx_lock(&g_eventlock); 342 g_pending_events++; 343 TAILQ_INSERT_TAIL(&g_events, ep, events); 344 mtx_unlock(&g_eventlock); 345 wakeup(&g_wait_event); 346 return (0); 347} 348 |
351static void 352geom_shutdown(void *foo __unused) 353{ | |
354 | 349 |
355 g_shutdown = 1; 356} 357 | |
358void 359g_event_init() 360{ 361 | 350void 351g_event_init() 352{ 353 |
362 363 EVENTHANDLER_REGISTER(shutdown_pre_sync, geom_shutdown, NULL, 364 SHUTDOWN_PRI_FIRST); | |
365 mtx_init(&g_eventlock, "GEOM orphanage", NULL, MTX_DEF); 366 sx_init(&g_eventstall, "GEOM event stalling"); 367} | 354 mtx_init(&g_eventlock, "GEOM orphanage", NULL, MTX_DEF); 355 sx_init(&g_eventstall, "GEOM event stalling"); 356} |