From owner-freebsd-current@FreeBSD.ORG Sat Jan 30 13:51:40 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C270E1065676; Sat, 30 Jan 2010 13:51:40 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by mx1.freebsd.org (Postfix) with ESMTP id 42BD58FC1B; Sat, 30 Jan 2010 13:51:39 +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 o0UDpQC3053952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 30 Jan 2010 15:51:26 +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 o0UDpQU4073478; Sat, 30 Jan 2010 15:51:26 +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 o0UDpQZu073477; Sat, 30 Jan 2010 15:51:26 +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: Sat, 30 Jan 2010 15:51:26 +0200 From: Kostik Belousov To: Pawel Jakub Dawidek Message-ID: <20100130135126.GV3877@deviant.kiev.zoral.com.ua> References: <4B636812.8060403@FreeBSD.org> <20100130112749.GA1660@garage.freebsd.pl> <20100130114451.GB1660@garage.freebsd.pl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2HdWiV8iqzNK3pYB" Content-Disposition: inline In-Reply-To: <20100130114451.GB1660@garage.freebsd.pl> 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, Alexander Motin , FreeBSD-Current , freebsd-geom@freebsd.org Subject: Re: Deadlock between GEOM and devfs device destroy and process exit. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2010 13:51:41 -0000 --2HdWiV8iqzNK3pYB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 30, 2010 at 12:44:51PM +0100, Pawel Jakub Dawidek wrote: > On Sat, Jan 30, 2010 at 12:27:49PM +0100, Pawel Jakub Dawidek wrote: > > On Sat, Jan 30, 2010 at 12:58:26AM +0200, Alexander Motin wrote: > > > Hi. > > >=20 > > > Experimenting with SATA hot-plug I've found quite repeatable deadlock > > > case. Problem observed when several SATA devices, opened via devfs, > > > disappear at exactly same time. In my case, at time of unplugging SATA > > > Port Multiplier with several disks beyond it. All I have to do is to = run > > > several `dd if=3D/dev/adaX of=3D/dev/null bs=3D1m &` commands and unp= lug > > > multiplier. That causes predictable I/O errors and devices destructio= n. > > > But with high probability several dd processes getting stuck in kerne= l. > > [...] > >=20 > > I observed the same thing yesterday while stress-testing HAST: > >=20 > > 3659 2504 3659 0 DE+ GEOM top 0x8079a348 dd > > 3658 2102 2102 0 DE+ GEOM top 0x8079a348 hastd > > 2 0 0 0 DL devdrn 0x85b1bc68 [g_event] > >=20 > > Both dd(1) and hastd(8) wait for the GEOM topology lock in the exit pat= h, > > which is already held by the g_event thread. >=20 > Maybe I'll add how I understand what's going on: >=20 > GEOM calls destroy_dev() while holding the topology lock. >=20 > Destroy_dev() wants to destroy device, but can't because there are > threads that still have it open. >=20 > The threads can't close it, because to close it they need the topology > lock. >=20 > The deadlock is quite obvious, IMHO. >=20 > I believe the problem could be solved by dropping the topology lock in > g_dev_orphan() when calling destroy_dev(dev), but it is hard to say if > it is safe to drop the topology lock there. Maybe Poul-Henning could > take a look. As I already said, if you cannot drop a lock, destroy_dev_sched() is designed to handle this. You should be careful to not allow any further activitity on the device scheduled for destruction. --2HdWiV8iqzNK3pYB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAktkOV0ACgkQC3+MBN1Mb4geLQCg3v+nX9pTfbMUUpasQBDnMwnd B7EAoN5oA9K9nFfI62P4vwKRzIUyAMO7 =15Wt -----END PGP SIGNATURE----- --2HdWiV8iqzNK3pYB--