g_wither_geom() bugs on class unload

Jaakko Heinonen jh at saunalahti.fi
Tue Dec 16 13:18:20 PST 2008


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


More information about the freebsd-geom mailing list