From owner-freebsd-geom@FreeBSD.ORG Tue Dec 16 21:18:20 2008 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 723D81065670 for ; Tue, 16 Dec 2008 21:18:20 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from emh03.mail.saunalahti.fi (emh03.mail.saunalahti.fi [62.142.5.109]) by mx1.freebsd.org (Postfix) with ESMTP id 336258FC12 for ; Tue, 16 Dec 2008 21:18:20 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from saunalahti-vams (vs3-11.mail.saunalahti.fi [62.142.5.95]) by emh03-2.mail.saunalahti.fi (Postfix) with SMTP id 6D4CCEC1F1 for ; Tue, 16 Dec 2008 23:03:13 +0200 (EET) Received: from emh03.mail.saunalahti.fi ([62.142.5.109]) by vs3-11.mail.saunalahti.fi ([62.142.5.95]) with SMTP (gateway) id A0312C6730D; Tue, 16 Dec 2008 23:03:13 +0200 Received: from a91-153-125-115.elisa-laajakaista.fi (a91-153-125-115.elisa-laajakaista.fi [91.153.125.115]) by emh03.mail.saunalahti.fi (Postfix) with SMTP id 59E71158A82 for ; Tue, 16 Dec 2008 23:03:12 +0200 (EET) Date: Tue, 16 Dec 2008 23:03:12 +0200 From: Jaakko Heinonen To: freebsd-geom@freebsd.org Message-ID: <20081216210311.GA5229@a91-153-125-115.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Antivirus: VAMS Subject: g_wither_geom() bugs on class unload X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2008 21:18:20 -0000 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