From owner-svn-src-head@freebsd.org Wed Jun 22 21:00:30 2016 Return-Path: Delivered-To: svn-src-head@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 2B1EDAC5EF1; Wed, 22 Jun 2016 21:00:30 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EE7E92178; Wed, 22 Jun 2016 21:00:29 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5ML0T91086310; Wed, 22 Jun 2016 21:00:29 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5ML0TRd086309; Wed, 22 Jun 2016 21:00:29 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201606222100.u5ML0TRd086309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 22 Jun 2016 21:00:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302091 - head/sys/geom/mirror X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2016 21:00:30 -0000 Author: markj Date: Wed Jun 22 21:00:28 2016 New Revision: 302091 URL: https://svnweb.freebsd.org/changeset/base/302091 Log: Do not complete pending gmirror BIOs when tearing down the provider. This will result in lock recursion and is more generally incorrect since the completion handlers will just reinsert the BIOs into the queue we're trying to drain. Reviewed by: imp, ngie Approved by: re (gjb) MFC after: 3 weeks Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D6908 Modified: head/sys/geom/mirror/g_mirror.c Modified: head/sys/geom/mirror/g_mirror.c ============================================================================== --- head/sys/geom/mirror/g_mirror.c Wed Jun 22 20:31:49 2016 (r302090) +++ head/sys/geom/mirror/g_mirror.c Wed Jun 22 21:00:28 2016 (r302091) @@ -2121,8 +2121,21 @@ g_mirror_destroy_provider(struct g_mirro g_topology_lock(); g_error_provider(sc->sc_provider, ENXIO); mtx_lock(&sc->sc_queue_mtx); - while ((bp = bioq_takefirst(&sc->sc_queue)) != NULL) - g_io_deliver(bp, ENXIO); + while ((bp = bioq_takefirst(&sc->sc_queue)) != NULL) { + /* + * Abort any pending I/O that wasn't generated by us. + * Synchronization requests and requests destined for individual + * mirror components can be destroyed immediately. + */ + if (bp->bio_to == sc->sc_provider && + bp->bio_from->geom != sc->sc_sync.ds_geom) { + g_io_deliver(bp, ENXIO); + } else { + if ((bp->bio_cflags & G_MIRROR_BIO_FLAG_SYNC) != 0) + free(bp->bio_data, M_MIRROR); + g_destroy_bio(bp); + } + } mtx_unlock(&sc->sc_queue_mtx); G_MIRROR_DEBUG(0, "Device %s: provider %s destroyed.", sc->sc_name, sc->sc_provider->name);