geom_event.c (3924ad705e6cf5a5fa4108ba44859936c92c25f6) | geom_event.c (b5cba4167f324641aafb96a167191a6b7a588d6e) |
---|---|
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 --- 32 unchanged lines hidden (view full) --- 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> | 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 --- 32 unchanged lines hidden (view full) --- 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} |