From owner-svn-src-head@freebsd.org Sat May 25 00:07:50 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2450E15B86C5; Sat, 25 May 2019 00:07:50 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B1843859B9; Sat, 25 May 2019 00:07:49 +0000 (UTC) (envelope-from mckusick@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B4B924392; Sat, 25 May 2019 00:07:49 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4P07nOr019188; Sat, 25 May 2019 00:07:49 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4P07nfA019187; Sat, 25 May 2019 00:07:49 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201905250007.x4P07nfA019187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Sat, 25 May 2019 00:07:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348259 - head/sys/geom/nop X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/geom/nop X-SVN-Commit-Revision: 348259 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B1843859B9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Sat, 25 May 2019 00:07:50 -0000 Author: mckusick Date: Sat May 25 00:07:49 2019 New Revision: 348259 URL: https://svnweb.freebsd.org/changeset/base/348259 Log: When using the destroy option to shut down a nop GEOM module, I/O operations already in its queue were not being properly drained. The GEOM framework does the queue draining, but the module needs to wait for the draining to happen. The waiting is done by adding a g_nop_providergone() function to wait for the I/O operations to finish up. This change is similar to change -r345758 made to the memory-disk driver. Submitted by: Chuck Silvers Tested by: Chuck Silvers MFC after: 1 week Sponsored by: Netflix Modified: head/sys/geom/nop/g_nop.c Modified: head/sys/geom/nop/g_nop.c ============================================================================== --- head/sys/geom/nop/g_nop.c Fri May 24 23:28:11 2019 (r348258) +++ head/sys/geom/nop/g_nop.c Sat May 25 00:07:49 2019 (r348259) @@ -54,17 +54,26 @@ static int g_nop_destroy_geom(struct gctl_req *req, st struct g_geom *gp); static void g_nop_config(struct gctl_req *req, struct g_class *mp, const char *verb); -static void g_nop_dumpconf(struct sbuf *sb, const char *indent, - struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp); +static g_access_t g_nop_access; +static g_dumpconf_t g_nop_dumpconf; +static g_orphan_t g_nop_orphan; +static g_provgone_t g_nop_providergone; +static g_resize_t g_nop_resize; +static g_start_t g_nop_start; struct g_class g_nop_class = { .name = G_NOP_CLASS_NAME, .version = G_VERSION, .ctlreq = g_nop_config, - .destroy_geom = g_nop_destroy_geom + .destroy_geom = g_nop_destroy_geom, + .access = g_nop_access, + .dumpconf = g_nop_dumpconf, + .orphan = g_nop_orphan, + .providergone = g_nop_providergone, + .resize = g_nop_resize, + .start = g_nop_start, }; - static void g_nop_orphan(struct g_consumer *cp) { @@ -320,11 +329,6 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, sc->sc_wrotebytes = 0; mtx_init(&sc->sc_lock, "gnop lock", NULL, MTX_DEF); gp->softc = sc; - gp->start = g_nop_start; - gp->orphan = g_nop_orphan; - gp->resize = g_nop_resize; - gp->access = g_nop_access; - gp->dumpconf = g_nop_dumpconf; newpp = g_new_providerf(gp, "%s", gp->name); newpp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; @@ -357,6 +361,18 @@ fail: return (error); } +static void +g_nop_providergone(struct g_provider *pp) +{ + struct g_geom *gp = pp->geom; + struct g_nop_softc *sc = gp->softc; + + gp->softc = NULL; + free(sc->sc_physpath, M_GEOM); + mtx_destroy(&sc->sc_lock); + g_free(sc); +} + static int g_nop_destroy(struct g_geom *gp, boolean_t force) { @@ -367,7 +383,6 @@ g_nop_destroy(struct g_geom *gp, boolean_t force) sc = gp->softc; if (sc == NULL) return (ENXIO); - free(sc->sc_physpath, M_GEOM); pp = LIST_FIRST(&gp->provider); if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) { if (force) { @@ -381,9 +396,6 @@ g_nop_destroy(struct g_geom *gp, boolean_t force) } else { G_NOP_DEBUG(0, "Device %s removed.", gp->name); } - gp->softc = NULL; - mtx_destroy(&sc->sc_lock); - g_free(sc); g_wither_geom(gp, ENXIO); return (0);