FreeBSD/sys/geom/geom_event.c
/*
 * This function is called once on each provider which the event handler
 * finds on its g_doorstep.
 */
This function is called once on each provider which the event handler
finds on its g_doorstep.
This function is called once on each provider which the event handler finds on its g_doorstep .
static void
g_orphan_register(struct g_provider *pp)
{
	struct g_consumer *cp, *cp2;
	int wf;
	g_topology_assert();
	G_VALID_PROVIDER(pp);
	g_trace(G_T_TOPOLOGY, "g_orphan_register(%s)", pp->name);
	g_cancel_event(pp);
	wf = pp->flags & G_PF_WITHER;
	pp->flags &= ~G_PF_WITHER;
	LIST_FOREACH_SAFE(cp, &pp->consumers, consumers, cp2) {
		KASSERT(cp->geom->orphan != NULL,
		    ("geom %s has no orphan, class %s",
		    cp->geom->name, cp->geom->class->name));
		if (cp->flags & G_CF_ORPHAN)
			continue;
		cp->flags |= G_CF_ORPHAN;
		cp->geom->orphan(cp);
	}
	if (LIST_EMPTY(&pp->consumers) && wf)
		g_destroy_provider(pp);
	else
		pp->flags |= wf;
#ifdef notyet
	cp = LIST_FIRST(&pp->consumers);
	if (cp != NULL)
		return;
	if (pp->geom->flags & G_GEOM_WITHER)
		g_destroy_provider(pp);
#endif
}
static void g_orphan_register ( struct g_provider * pp ) { struct g_consumer * cp , * cp2 ; int wf ; g_topology_assert ( ) ; G_VALID_PROVIDER ( pp ) ; g_trace ( G_T_TOPOLOGY , " " , pp -> name ) ; g_cancel_event ( pp ) ; wf = pp -> flags & G_PF_WITHER ; pp -> flags &= ~ G_PF_WITHER ; LIST_FOREACH_SAFE ( cp , & pp -> consumers , consumers , cp2 ) { KASSERT ( cp -> geom -> orphan != NULL , ( " " , cp -> geom -> name , cp -> geom -> class -> name ) ) ; if ( cp -> flags & G_CF_ORPHAN ) continue ; cp -> flags |= G_CF_ORPHAN ; cp -> geom -> orphan ( cp ) ; } if ( LIST_EMPTY ( & pp -> consumers ) && wf ) g_destroy_provider ( pp ) ; else pp -> flags |= wf ; #ifdef notyet cp = LIST_FIRST ( & pp -> consumers ) ; if ( cp != NULL ) return ; if ( pp -> geom -> flags & G_GEOM_WITHER ) g_destroy_provider ( pp ) ; #endif }
This function is called once on each provider which the event handler
 finds on its g_doorstep.
This function is called once on each provider which the event handler finds on its g_doorstep .
/*
	 * Tell all consumers the bad news.
	 * Don't be surprised if they self-destruct.
	 */ /*
		 * XXX: g_dev_orphan method does deferred destroying
		 * and it is possible, that other event could already
		 * call the orphan method. Check consumer's flags to
		 * do not schedule it twice.
		 */