Date: Tue, 16 Dec 2008 23:03:12 +0200 From: Jaakko Heinonen <jh@saunalahti.fi> To: freebsd-geom@freebsd.org Subject: g_wither_geom() bugs on class unload Message-ID: <20081216210311.GA5229@a91-153-125-115.elisa-laajakaista.fi>
next in thread | raw e-mail | index | archive | help
Hi, Some time ago I discovered problems with g_wither_geom() on GEOM class unload. Many classes use it to destroy geoms prior to unloading. g_wither_geom() call just initiates withering which will be done in the g_event thread. There are no guarantees when withering will finish. I have seen two different problems on class (module) unload: 1) Class doesn't have destroy method ang g_wither_geom() is called before unloading (acd(4), fdc(4)). So withering has been started but may not be finished when entering to g_unload_class(). g_unload_class() fails if there are geom instances left and because there isn't a destroy method it can't try to destroy geoms. (Combined with acd(4) and fdc(4) ignorance of the g_modevent() return value the result may be a panic.) 2) Class has a destroy method which uses g_wither_geom(). When destroy method exists and there are geoms left when g_unload_class() is called, g_unload_class() tries to call destroy method repeatedly to get rid of geoms. Because g_unload_class() is run as geom event it blocks the event thread and thus prevents withering to proceed. The result is a deadlock. Here is a patch which works around these problems (at least to some degree): http://www.saunalahti.fi/~jh3/patches/geom-unload-class.diff -- Jaakko
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081216210311.GA5229>