From owner-freebsd-hackers@FreeBSD.ORG Mon Feb 1 11:08:55 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30DBF10656E4; Mon, 1 Feb 2010 11:08:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 6720F8FC20; Mon, 1 Feb 2010 11:08:54 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o11B8Z5S048484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 1 Feb 2010 13:08:50 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id o11AhSRO031239; Mon, 1 Feb 2010 12:43:28 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id o11AhSXE031205; Mon, 1 Feb 2010 12:43:28 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 1 Feb 2010 12:43:28 +0200 From: Kostik Belousov To: Alexander Motin Message-ID: <20100201104328.GD15587@deviant.kiev.zoral.com.ua> References: <4B636812.8060403@FreeBSD.org> <20100130112749.GA1660@garage.freebsd.pl> <20100130114451.GB1660@garage.freebsd.pl> <20100201092334.GB1743@garage.freebsd.pl> <4B66A669.2070406@FreeBSD.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xB0nW4MQa6jZONgY" Content-Disposition: inline In-Reply-To: <4B66A669.2070406@FreeBSD.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, FreeBSD-Current , Pawel Jakub Dawidek , freebsd-geom@freebsd.org Subject: Re: Deadlock between GEOM and devfs device destroy and process exit. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Feb 2010 11:08:55 -0000 --xB0nW4MQa6jZONgY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 01, 2010 at 12:01:13PM +0200, Alexander Motin wrote: > Pawel Jakub Dawidek wrote: > > On Sat, Jan 30, 2010 at 12:44:51PM +0100, Pawel Jakub Dawidek wrote: > >> Maybe I'll add how I understand what's going on: > >> > >> GEOM calls destroy_dev() while holding the topology lock. > >> > >> Destroy_dev() wants to destroy device, but can't because there are > >> threads that still have it open. > >> > >> The threads can't close it, because to close it they need the topology > >> lock. > >> > >> The deadlock is quite obvious, IMHO. > >=20 > > Guys, changing destroy_dev() to destroy_dev_sched() in geom_dev.c fixes > > the problem for me (at least it makes race window so small that I can't > > reproduce it). Is there anyone who isn't happy with such a change? >=20 > Have you done some locking there? Because my system crashes with such > straightforward change, when g_dev_close() called after geom node being > destroyed. Attached patch fixes that for me, but I have doubts that it > is complete. There is still seems to be a race with new I/O requests and > ioctl's, that are not protected by topology lock. At least if devfs code > doesn't handle it somehow. Devfs prevents new threads from entering cdevsw methods after destroy_dev_sched() is called. It is driver responsibility to take care about other code pathes that may access cdev. --xB0nW4MQa6jZONgY Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAktmsFAACgkQC3+MBN1Mb4hNzQCg2m16aRPIrgVnePtnZj0tCrYU AqYAoJZ0iO6X7ivDvPxIgD5rdeEuLje/ =7DeA -----END PGP SIGNATURE----- --xB0nW4MQa6jZONgY--