From owner-svn-src-all@freebsd.org Tue Dec 19 16:16:35 2017 Return-Path: Delivered-To: svn-src-all@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 68481E8D207; Tue, 19 Dec 2017 16:16:35 +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 2ED847F4C1; Tue, 19 Dec 2017 16:16:35 +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 vBJGGY7C093398; Tue, 19 Dec 2017 16:16:34 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBJGGYP7093397; Tue, 19 Dec 2017 16:16:34 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201712191616.vBJGGYP7093397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 19 Dec 2017 16:16:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r326979 - stable/11/sys/geom/mirror X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/geom/mirror X-SVN-Commit-Revision: 326979 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Dec 2017 16:16:35 -0000 Author: markj Date: Tue Dec 19 16:16:34 2017 New Revision: 326979 URL: https://svnweb.freebsd.org/changeset/base/326979 Log: MFC r326796-r326798: Fix sc_writes tracking, and address a lost wakeup. Modified: stable/11/sys/geom/mirror/g_mirror.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/11/sys/geom/mirror/g_mirror.c Tue Dec 19 15:50:46 2017 (r326978) +++ stable/11/sys/geom/mirror/g_mirror.c Tue Dec 19 16:16:34 2017 (r326979) @@ -213,7 +213,7 @@ g_mirror_event_send(void *arg, int state, int flags) } static struct g_mirror_event * -g_mirror_event_get(struct g_mirror_softc *sc) +g_mirror_event_first(struct g_mirror_softc *sc) { struct g_mirror_event *ep; @@ -548,7 +548,7 @@ g_mirror_destroy_device(struct g_mirror_softc *sc) g_mirror_update_metadata(disk); g_mirror_destroy_disk(disk); } - while ((ep = g_mirror_event_get(sc)) != NULL) { + while ((ep = g_mirror_event_first(sc)) != NULL) { g_mirror_event_remove(sc, ep); if ((ep->e_flags & G_MIRROR_EVENT_DONTWAIT) != 0) g_mirror_event_free(ep); @@ -930,7 +930,7 @@ g_mirror_regular_request(struct bio *bp) pbp = bp->bio_parent; sc = pbp->bio_to->private; bp->bio_from->index--; - if (bp->bio_cmd == BIO_WRITE) + if (bp->bio_cmd == BIO_WRITE || bp->bio_cmd == BIO_DELETE) sc->sc_writes--; disk = bp->bio_from->private; if (disk == NULL) { @@ -1869,7 +1869,7 @@ g_mirror_worker(void *arg) * First take a look at events. * This is important to handle events before any I/O requests. */ - ep = g_mirror_event_get(sc); + ep = g_mirror_event_first(sc); if (ep != NULL) { g_mirror_event_remove(sc, ep); if ((ep->e_flags & G_MIRROR_EVENT_DEVICE) != 0) { @@ -1937,16 +1937,9 @@ g_mirror_worker(void *arg) continue; } } + if (g_mirror_event_first(sc) != NULL) + continue; sx_xunlock(&sc->sc_lock); - /* - * XXX: We can miss an event here, because an event - * can be added without sx-device-lock and without - * mtx-queue-lock. Maybe I should just stop using - * dedicated mutex for events synchronization and - * stick with the queue lock? - * The event will hang here until next I/O request - * or next event is received. - */ MSLEEP(sc, &sc->sc_queue_mtx, PRIBIO | PDROP, "m:w1", timeout * hz); sx_xlock(&sc->sc_lock);