From owner-svn-src-stable-10@freebsd.org Wed Sep 16 04:38:09 2015 Return-Path: Delivered-To: svn-src-stable-10@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 228929CD39B; Wed, 16 Sep 2015 04:38:09 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 06A8D11AA; Wed, 16 Sep 2015 04:38:09 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8G4c868082595; Wed, 16 Sep 2015 04:38:08 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8G4c8ho082592; Wed, 16 Sep 2015 04:38:08 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201509160438.t8G4c8ho082592@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 16 Sep 2015 04:38:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287850 - in stable/10/sys: geom geom/multipath vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2015 04:38:09 -0000 Author: imp Date: Wed Sep 16 04:38:07 2015 New Revision: 287850 URL: https://svnweb.freebsd.org/changeset/base/287850 Log: MFC 281310, 287567: r287567 | imp | 2015-09-08 11:47:56 -0600 (Tue, 08 Sep 2015) | 16 lines Mark the swap pager as direct dispatch compatible. r281310 | mav | 2015-04-09 07:09:05 -0600 (Thu, 09 Apr 2015) | 4 lines Remove sleeps from geom_up thread on device destruction. Modified: stable/10/sys/geom/geom_dev.c stable/10/sys/geom/multipath/g_multipath.c stable/10/sys/vm/swap_pager.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/geom/geom_dev.c ============================================================================== --- stable/10/sys/geom/geom_dev.c Wed Sep 16 04:35:23 2015 (r287849) +++ stable/10/sys/geom/geom_dev.c Wed Sep 16 04:38:07 2015 (r287850) @@ -570,7 +570,7 @@ g_dev_done(struct bio *bp2) } mtx_unlock(&sc->sc_mtx); if (destroy) - g_post_event(g_dev_destroy, cp, M_WAITOK, NULL); + g_post_event(g_dev_destroy, cp, M_NOWAIT, NULL); biodone(bp); } Modified: stable/10/sys/geom/multipath/g_multipath.c ============================================================================== --- stable/10/sys/geom/multipath/g_multipath.c Wed Sep 16 04:35:23 2015 (r287849) +++ stable/10/sys/geom/multipath/g_multipath.c Wed Sep 16 04:38:07 2015 (r287850) @@ -369,9 +369,9 @@ g_multipath_done(struct bio *bp) mtx_lock(&sc->sc_mtx); (*cnt)--; if (*cnt == 0 && (cp->index & MP_LOST)) { - cp->index |= MP_POSTED; + if (g_post_event(g_mpd, cp, M_NOWAIT, NULL) == 0) + cp->index |= MP_POSTED; mtx_unlock(&sc->sc_mtx); - g_post_event(g_mpd, cp, M_WAITOK, NULL); } else mtx_unlock(&sc->sc_mtx); g_std_done(bp); Modified: stable/10/sys/vm/swap_pager.c ============================================================================== --- stable/10/sys/vm/swap_pager.c Wed Sep 16 04:35:23 2015 (r287849) +++ stable/10/sys/vm/swap_pager.c Wed Sep 16 04:38:07 2015 (r287850) @@ -2354,8 +2354,8 @@ swapoff_one(struct swdevt *sp, struct uc swap_pager_swapoff(sp); sp->sw_close(curthread, sp); - sp->sw_id = NULL; mtx_lock(&sw_dev_mtx); + sp->sw_id = NULL; TAILQ_REMOVE(&swtailq, sp, sw_list); nswapdev--; if (nswapdev == 0) { @@ -2541,13 +2541,39 @@ swapgeom_close_ev(void *arg, int flags) g_destroy_consumer(cp); } +/* + * Add a reference to the g_consumer for an inflight transaction. + */ +static void +swapgeom_acquire(struct g_consumer *cp) +{ + + mtx_assert(&sw_dev_mtx, MA_OWNED); + cp->index++; +} + +/* + * Remove a reference from the g_consumer. Post a close event if + * all referneces go away. + */ +static void +swapgeom_release(struct g_consumer *cp, struct swdevt *sp) +{ + + mtx_assert(&sw_dev_mtx, MA_OWNED); + cp->index--; + if (cp->index == 0) { + if (g_post_event(swapgeom_close_ev, cp, M_NOWAIT, NULL) == 0) + sp->sw_id = NULL; + } +} + static void swapgeom_done(struct bio *bp2) { struct swdevt *sp; struct buf *bp; struct g_consumer *cp; - int destroy; bp = bp2->bio_caller2; cp = bp2->bio_from; @@ -2557,16 +2583,11 @@ swapgeom_done(struct bio *bp2) bp->b_resid = bp->b_bcount - bp2->bio_completed; bp->b_error = bp2->bio_error; bufdone(bp); + sp = bp2->bio_caller1; mtx_lock(&sw_dev_mtx); - destroy = ((--cp->index) == 0 && cp->private); - if (destroy) { - sp = bp2->bio_caller1; - sp->sw_id = NULL; - } + swapgeom_release(cp, sp); mtx_unlock(&sw_dev_mtx); g_destroy_bio(bp2); - if (destroy) - g_waitfor_event(swapgeom_close_ev, cp, M_WAITOK, NULL); } static void @@ -2584,13 +2605,16 @@ swapgeom_strategy(struct buf *bp, struct bufdone(bp); return; } - cp->index++; + swapgeom_acquire(cp); mtx_unlock(&sw_dev_mtx); if (bp->b_iocmd == BIO_WRITE) bio = g_new_bio(); else bio = g_alloc_bio(); if (bio == NULL) { + mtx_lock(&sw_dev_mtx); + swapgeom_release(cp, sp); + mtx_unlock(&sw_dev_mtx); bp->b_error = ENOMEM; bp->b_ioflags |= BIO_ERROR; bufdone(bp); @@ -2630,7 +2654,12 @@ swapgeom_orphan(struct g_consumer *cp) break; } } - cp->private = (void *)(uintptr_t)1; + /* + * Drop reference we were created with. Do directly since we're in a + * special context where we don't have to queue the call to + * swapgeom_close_ev(). + */ + cp->index--; destroy = ((sp != NULL) && (cp->index == 0)); if (destroy) sp->sw_id = NULL; @@ -2691,8 +2720,8 @@ swapongeom_ev(void *arg, int flags) if (gp == NULL) gp = g_new_geomf(&g_swap_class, "swap"); cp = g_new_consumer(gp); - cp->index = 0; /* Number of active I/Os. */ - cp->private = NULL; /* Orphanization flag */ + cp->index = 1; /* Number of active I/Os, plus one for being active. */ + cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; g_attach(cp, pp); /* * XXX: Everytime you think you can improve the margin for