From owner-svn-src-head@FreeBSD.ORG Mon Aug 26 20:39:03 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0EF70D21; Mon, 26 Aug 2013 20:39:03 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D7D762E91; Mon, 26 Aug 2013 20:39:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7QKd2oB012092; Mon, 26 Aug 2013 20:39:02 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7QKd2Xc012090; Mon, 26 Aug 2013 20:39:02 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201308262039.r7QKd2Xc012090@svn.freebsd.org> From: Alexander Motin Date: Mon, 26 Aug 2013 20:39:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254936 - head/sys/geom/zero 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.14 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: Mon, 26 Aug 2013 20:39:03 -0000 Author: mav Date: Mon Aug 26 20:39:02 2013 New Revision: 254936 URL: http://svnweb.freebsd.org/changeset/base/254936 Log: MFprojects/camlock r254895: Add unmapped BIO support to GEOM ZERO if kern.geom.zero.clear is cleared. Modified: head/sys/geom/zero/g_zero.c Modified: head/sys/geom/zero/g_zero.c ============================================================================== --- head/sys/geom/zero/g_zero.c Mon Aug 26 20:03:44 2013 (r254935) +++ head/sys/geom/zero/g_zero.c Mon Aug 26 20:39:02 2013 (r254936) @@ -41,16 +41,37 @@ __FBSDID("$FreeBSD$"); #define G_ZERO_CLASS_NAME "ZERO" +static int g_zero_clear_sysctl(SYSCTL_HANDLER_ARGS); + SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, zero, CTLFLAG_RW, 0, "GEOM_ZERO stuff"); static int g_zero_clear = 1; -SYSCTL_INT(_kern_geom_zero, OID_AUTO, clear, CTLFLAG_RW, &g_zero_clear, 0, - "Clear read data buffer"); +SYSCTL_PROC(_kern_geom_zero, OID_AUTO, clear, CTLTYPE_INT|CTLFLAG_RW, + &g_zero_clear, 0, g_zero_clear_sysctl, "I", "Clear read data buffer"); static int g_zero_byte = 0; SYSCTL_INT(_kern_geom_zero, OID_AUTO, byte, CTLFLAG_RW, &g_zero_byte, 0, "Byte (octet) value to clear the buffers with"); +static struct g_provider *gpp; + +static int +g_zero_clear_sysctl(SYSCTL_HANDLER_ARGS) +{ + int error; + + error = sysctl_handle_int(oidp, &g_zero_clear, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (gpp == NULL) + return (ENXIO); + if (g_zero_clear) + gpp->flags &= ~G_PF_ACCEPT_UNMAPPED; + else + gpp->flags |= G_PF_ACCEPT_UNMAPPED; + return (0); +} + static void g_zero_start(struct bio *bp) { @@ -58,7 +79,7 @@ g_zero_start(struct bio *bp) switch (bp->bio_cmd) { case BIO_READ: - if (g_zero_clear) + if (g_zero_clear && (bp->bio_flags & BIO_UNMAPPED) == 0) memset(bp->bio_data, g_zero_byte, bp->bio_length); /* FALLTHROUGH */ case BIO_DELETE: @@ -84,7 +105,9 @@ g_zero_init(struct g_class *mp) gp = g_new_geomf(mp, "gzero"); gp->start = g_zero_start; gp->access = g_std_access; - pp = g_new_providerf(gp, "%s", gp->name); + gpp = pp = g_new_providerf(gp, "%s", gp->name); + if (!g_zero_clear) + pp->flags |= G_PF_ACCEPT_UNMAPPED; pp->mediasize = 1152921504606846976LLU; pp->sectorsize = 512; g_error_provider(pp, 0); @@ -104,6 +127,7 @@ g_zero_destroy_geom(struct gctl_req *req return (0); if (pp->acr > 0 || pp->acw > 0 || pp->ace > 0) return (EBUSY); + gpp = NULL; g_wither_geom(gp, ENXIO); return (0); }