From owner-freebsd-geom@freebsd.org Sat Jan 28 11:44:54 2017 Return-Path: Delivered-To: freebsd-geom@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D7470CC59AA for ; Sat, 28 Jan 2017 11:44:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 39625151D for ; Sat, 28 Jan 2017 11:44:53 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA07401; Sat, 28 Jan 2017 13:44:51 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1cXRR5-000ExI-6v; Sat, 28 Jan 2017 13:44:51 +0200 Subject: Re: g_disk_done() vs a destroyed disk To: Poul-Henning Kamp References: <31395.1485554104@critter.freebsd.dk> Cc: freebsd-geom@FreeBSD.org From: Andriy Gapon Message-ID: <8de79017-f0b0-c86a-93c5-65be4d97b21c@FreeBSD.org> Date: Sat, 28 Jan 2017 13:43:55 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <31395.1485554104@critter.freebsd.dk> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jan 2017 11:44:54 -0000 On 27/01/2017 23:55, Poul-Henning Kamp wrote: > -------- > In message , Andriy Gapon writes: >> >> I've seen a situation where g_disk_done() was called on a bio after the >> corresponding disk had been already destroyed via g_disk_destroy(). >> That call resulted in a crash here: >> devstat_end_transaction_bio_bt(sc->dp->d_devstat, bp, &now); >> because sc->dp was NULL. >> >> Is it a bug that we do not check for dp being NULL (or dp->d_destroyed being >> set) in g_disk_done() ? >> Or is it a bug that a controller driver called biodone() for that bio having I should have said a disk driver here. >> earlier called disk_destroy() ? > > It is a driver bug to call disk_destroy() before purging all in-flight bios > with biodone() Oh, I didn't think of that. So, the correct sequence should be: - call disk_gone() to prevent new I/O - handle all in-flight I/O - call disk_destroy() Is that right? Thank you! -- Andriy Gapon