Explain why swapgeom_close_ev() is delegated.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2016-08-03 07:11:19 +00:00
parent e69ba32f88
commit 0c657d22eb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=303703

View File

@ -2431,8 +2431,9 @@ swapgeom_acquire(struct g_consumer *cp)
}
/*
* Remove a reference from the g_consumer. Post a close event if
* all references go away.
* Remove a reference from the g_consumer. Post a close event if all
* references go away, since the function might be called from the
* biodone context.
*/
static void
swapgeom_release(struct g_consumer *cp, struct swdevt *sp)
@ -2555,7 +2556,12 @@ swapgeom_close(struct thread *td, struct swdevt *sw)
cp = sw->sw_id;
sw->sw_id = NULL;
mtx_unlock(&sw_dev_mtx);
/* XXX: direct call when Giant untangled */
/*
* swapgeom_close() may be called from the biodone context,
* where we cannot perform topology changes. Delegate the
* work to the events thread.
*/
if (cp != NULL)
g_waitfor_event(swapgeom_close_ev, cp, M_WAITOK, NULL);
}