[Midnightbsd-cvs] src [9968] trunk/sys/geom: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat May 26 11:23:19 EDT 2018


Revision: 9968
          http://svnweb.midnightbsd.org/src/?rev=9968
Author:   laffer1
Date:     2018-05-26 11:23:19 -0400 (Sat, 26 May 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/sys/geom/raid/g_raid.c
    trunk/sys/geom/raid/g_raid.h
    trunk/sys/geom/raid/g_raid_ctl.c
    trunk/sys/geom/raid/g_raid_md_if.m
    trunk/sys/geom/raid/g_raid_tr_if.m
    trunk/sys/geom/raid/md_ddf.c
    trunk/sys/geom/raid/md_ddf.h
    trunk/sys/geom/raid/md_intel.c
    trunk/sys/geom/raid/md_jmicron.c
    trunk/sys/geom/raid/md_nvidia.c
    trunk/sys/geom/raid/md_promise.c
    trunk/sys/geom/raid/md_sii.c
    trunk/sys/geom/raid/tr_concat.c
    trunk/sys/geom/raid/tr_raid0.c
    trunk/sys/geom/raid/tr_raid1.c
    trunk/sys/geom/raid/tr_raid1e.c
    trunk/sys/geom/raid/tr_raid5.c
    trunk/sys/geom/raid3/g_raid3.c
    trunk/sys/geom/sched/g_sched.c
    trunk/sys/geom/sched/g_sched.h
    trunk/sys/geom/sched/gs_rr.c
    trunk/sys/geom/sched/gs_scheduler.h
    trunk/sys/geom/sched/subr_disk.c
    trunk/sys/geom/shsec/g_shsec.c

Property Changed:
----------------
    trunk/sys/geom/raid/g_raid_md_if.m
    trunk/sys/geom/raid/g_raid_tr_if.m

Modified: trunk/sys/geom/raid/g_raid.c
===================================================================
--- trunk/sys/geom/raid/g_raid.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/g_raid.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/g_raid.c 281346 2015-04-10 00:43:24Z mav $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -92,7 +93,12 @@
 SYSCTL_UINT(_kern_geom_raid, OID_AUTO, idle_threshold, CTLFLAG_RW,
     &g_raid_idle_threshold, 1000000,
     "Time in microseconds to consider a volume idle.");
+static u_int ar_legacy_aliases = 1;
+SYSCTL_INT(_kern_geom_raid, OID_AUTO, legacy_aliases, CTLFLAG_RW,
+           &ar_legacy_aliases, 0, "Create aliases named as the legacy ataraid style.");
+TUNABLE_INT("kern.geom_raid.legacy_aliases", &ar_legacy_aliases);
 
+
 #define	MSLEEP(rv, ident, mtx, priority, wmesg, timeout)	do {	\
 	G_RAID_DEBUG(4, "%s: Sleeping %p.", __func__, (ident));		\
 	rv = msleep((ident), (mtx), (priority), (wmesg), (timeout));	\
@@ -787,6 +793,7 @@
 	if (pp == NULL)
 		return (NULL);
 	cp = g_new_consumer(sc->sc_geom);
+	cp->flags |= G_CF_DIRECT_RECEIVE;
 	if (g_attach(cp, pp) != 0) {
 		g_destroy_consumer(cp);
 		return (NULL);
@@ -988,9 +995,7 @@
 		cbp->bio_caller1 = sd;
 		bioq_insert_tail(&queue, cbp);
 	}
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL) {
 		sd = cbp->bio_caller1;
 		cbp->bio_caller1 = NULL;
 		g_raid_subdisk_iostart(sd, cbp);
@@ -997,11 +1002,8 @@
 	}
 	return;
 failure:
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL)
 		g_destroy_bio(cbp);
-	}
 	if (bp->bio_error == 0)
 		bp->bio_error = ENOMEM;
 	g_raid_iodone(bp, bp->bio_error);
@@ -1142,7 +1144,7 @@
 		return;
 	}
 	mtx_lock(&sc->sc_queue_mtx);
-	bioq_disksort(&sc->sc_queue, bp);
+	bioq_insert_tail(&sc->sc_queue, bp);
 	mtx_unlock(&sc->sc_queue_mtx);
 	if (!dumping) {
 		G_RAID_DEBUG1(4, sc, "Waking up %p.", sc);
@@ -1354,7 +1356,7 @@
 			    (intmax_t)(lp->l_offset+lp->l_length));
 			mtx_lock(&sc->sc_queue_mtx);
 			while ((bp = bioq_takefirst(&vol->v_locked)) != NULL)
-				bioq_disksort(&sc->sc_queue, bp);
+				bioq_insert_tail(&sc->sc_queue, bp);
 			mtx_unlock(&sc->sc_queue_mtx);
 			free(lp, M_RAID);
 			return (0);
@@ -1448,7 +1450,7 @@
 	sd = bp->bio_caller1;
 	sc = sd->sd_softc;
 	mtx_lock(&sc->sc_queue_mtx);
-	bioq_disksort(&sc->sc_queue, bp);
+	bioq_insert_tail(&sc->sc_queue, bp);
 	mtx_unlock(&sc->sc_queue_mtx);
 	if (!dumping)
 		wakeup(sc);
@@ -1634,10 +1636,13 @@
 g_raid_launch_provider(struct g_raid_volume *vol)
 {
 	struct g_raid_disk *disk;
+	struct g_raid_subdisk *sd;
 	struct g_raid_softc *sc;
 	struct g_provider *pp;
 	char name[G_RAID_MAX_VOLUMENAME];
+	char   announce_buf[80], buf1[32];
 	off_t off;
+	int i;
 
 	sc = vol->v_softc;
 	sx_assert(&sc->sc_lock, SX_LOCKED);
@@ -1650,7 +1655,35 @@
 		/* Otherwise use sequential volume number. */
 		snprintf(name, sizeof(name), "raid/r%d", vol->v_global_id);
 	}
+
+	/*
+	 * Create a /dev/ar%d that the old ataraid(4) stack once
+	 * created as an alias for /dev/raid/r%d if requested.
+	 * This helps going from stable/7 ataraid devices to newer
+	 * FreeBSD releases. sbruno 07 MAY 2013
+	 */
+
+        if (ar_legacy_aliases) {
+		snprintf(announce_buf, sizeof(announce_buf),
+                        "kern.devalias.%s", name);
+                snprintf(buf1, sizeof(buf1),
+                        "ar%d", vol->v_global_id);
+                setenv(announce_buf, buf1);
+        }
+
 	pp = g_new_providerf(sc->sc_geom, "%s", name);
+	pp->flags |= G_PF_DIRECT_RECEIVE;
+	if (vol->v_tr->tro_class->trc_accept_unmapped) {
+		pp->flags |= G_PF_ACCEPT_UNMAPPED;
+		for (i = 0; i < vol->v_disks_count; i++) {
+			sd = &vol->v_subdisks[i];
+			if (sd->sd_state == G_RAID_SUBDISK_S_NONE)
+				continue;
+			if ((sd->sd_disk->d_consumer->provider->flags &
+			    G_PF_ACCEPT_UNMAPPED) == 0)
+				pp->flags &= ~G_PF_ACCEPT_UNMAPPED;
+		}
+	}
 	pp->private = vol;
 	pp->mediasize = vol->v_mediasize;
 	pp->sectorsize = vol->v_sectorsize;
@@ -1841,6 +1874,11 @@
 		error = ENXIO;
 		goto out;
 	}
+	/* Deny write opens for read-only volumes. */
+	if (vol->v_read_only && acw > 0) {
+		error = EROFS;
+		goto out;
+	}
 	if (dcw == 0)
 		g_raid_clean(vol, dcw);
 	vol->v_provider_open += acr + acw + ace;
@@ -2149,7 +2187,7 @@
 int
 g_raid_destroy(struct g_raid_softc *sc, int how)
 {
-	int opens;
+	int error, opens;
 
 	g_topology_assert_not();
 	if (sc == NULL)
@@ -2166,11 +2204,13 @@
 			G_RAID_DEBUG1(1, sc,
 			    "%d volumes are still open.",
 			    opens);
+			sx_xunlock(&sc->sc_lock);
 			return (EBUSY);
 		case G_RAID_DESTROY_DELAYED:
 			G_RAID_DEBUG1(1, sc,
 			    "Array will be destroyed on last close.");
 			sc->sc_stopping = G_RAID_DESTROY_DELAYED;
+			sx_xunlock(&sc->sc_lock);
 			return (EBUSY);
 		case G_RAID_DESTROY_HARD:
 			G_RAID_DEBUG1(1, sc,
@@ -2184,9 +2224,9 @@
 	/* Wake up worker to let it selfdestruct. */
 	g_raid_event_send(sc, G_RAID_NODE_E_WAKE, 0);
 	/* Sleep until node destroyed. */
-	sx_sleep(&sc->sc_stopping, &sc->sc_lock,
-	    PRIBIO | PDROP, "r:destroy", 0);
-	return (0);
+	error = sx_sleep(&sc->sc_stopping, &sc->sc_lock,
+	    PRIBIO | PDROP, "r:destroy", hz * 3);
+	return (error == EWOULDBLOCK ? EBUSY : 0);
 }
 
 static void
@@ -2212,6 +2252,8 @@
 		return (NULL);
 	G_RAID_DEBUG(2, "Tasting provider %s.", pp->name);
 
+	geom = NULL;
+	status = G_RAID_MD_TASTE_FAIL;
 	gp = g_new_geomf(mp, "raid:taste");
 	/*
 	 * This orphan function should be never called.
@@ -2218,9 +2260,11 @@
 	 */
 	gp->orphan = g_raid_taste_orphan;
 	cp = g_new_consumer(gp);
+	cp->flags |= G_CF_DIRECT_RECEIVE;
 	g_attach(cp, pp);
+	if (g_access(cp, 1, 0, 0) != 0)
+		goto ofail;
 
-	geom = NULL;
 	LIST_FOREACH(class, &g_raid_md_classes, mdc_list) {
 		if (!class->mdc_enable)
 			continue;
@@ -2236,6 +2280,9 @@
 			break;
 	}
 
+	if (status == G_RAID_MD_TASTE_FAIL)
+		(void)g_access(cp, -1, 0, 0);
+ofail:
 	g_detach(cp);
 	g_destroy_consumer(cp);
 	g_destroy_geom(gp);
@@ -2281,8 +2328,6 @@
 	sx_xlock(&sc->sc_lock);
 	g_cancel_event(sc);
 	error = g_raid_destroy(gp->softc, G_RAID_DESTROY_SOFT);
-	if (error != 0)
-		sx_xunlock(&sc->sc_lock);
 	g_topology_lock();
 	return (error);
 }
@@ -2335,6 +2380,10 @@
 		vol = pp->private;
 		g_topology_unlock();
 		sx_xlock(&sc->sc_lock);
+		sbuf_printf(sb, "%s<descr>%s %s volume</descr>\n", indent,
+		    sc->sc_md->mdo_class->name,
+		    g_raid_volume_level2str(vol->v_raid_level,
+		    vol->v_raid_level_qualifier));
 		sbuf_printf(sb, "%s<Label>%s</Label>\n", indent,
 		    vol->v_name);
 		sbuf_printf(sb, "%s<RAIDLevel>%s</RAIDLevel>\n", indent,
@@ -2443,7 +2492,6 @@
 	struct g_geom *gp, *gp2;
 	struct g_raid_softc *sc;
 	struct g_raid_volume *vol;
-	int error;
 
 	mp = arg;
 	DROP_GIANT();
@@ -2457,9 +2505,7 @@
 		TAILQ_FOREACH(vol, &sc->sc_volumes, v_next)
 			g_raid_clean(vol, -1);
 		g_cancel_event(sc);
-		error = g_raid_destroy(sc, G_RAID_DESTROY_DELAYED);
-		if (error != 0)
-			sx_xunlock(&sc->sc_lock);
+		g_raid_destroy(sc, G_RAID_DESTROY_DELAYED);
 		g_topology_lock();
 	}
 	g_topology_unlock();

Modified: trunk/sys/geom/raid/g_raid.h
===================================================================
--- trunk/sys/geom/raid/g_raid.h	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/g_raid.h	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/geom/raid/g_raid.h 260385 2014-01-07 01:32:23Z scottl $
  */
 
 #ifndef	_G_RAID_H_
@@ -306,6 +307,7 @@
 	int			 v_stopping;	/* Volume is stopping */
 	int			 v_provider_open; /* Number of opens. */
 	int			 v_global_id;	/* Global volume ID (rX). */
+	int			 v_read_only;	/* Volume is read-only. */
 	TAILQ_ENTRY(g_raid_volume)	 v_next; /* List of volumes entry. */
 	LIST_ENTRY(g_raid_volume)	 v_global_next; /* Global list entry. */
 };
@@ -375,6 +377,7 @@
 	KOBJ_CLASS_FIELDS;
 	int		 trc_enable;
 	int		 trc_priority;
+	int		 trc_accept_unmapped;
 	LIST_ENTRY(g_raid_tr_class) trc_list;
 };
 

Modified: trunk/sys/geom/raid/g_raid_ctl.c
===================================================================
--- trunk/sys/geom/raid/g_raid_ctl.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/g_raid_ctl.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/g_raid_ctl.c 299497 2016-05-12 00:45:57Z pfg $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -117,7 +118,7 @@
 	}
 	format = gctl_get_asciiparam(req, "arg0");
 	if (format == NULL) {
-		gctl_error(req, "No format recieved.");
+		gctl_error(req, "No format received.");
 		return;
 	}
 	crstatus = g_raid_create_node_format(format, req, &geom);
@@ -164,7 +165,7 @@
 	}
 	nodename = gctl_get_asciiparam(req, "arg0");
 	if (nodename == NULL) {
-		gctl_error(req, "No array name recieved.");
+		gctl_error(req, "No array name received.");
 		return;
 	}
 	sc = g_raid_find_node(mp, nodename);
@@ -181,7 +182,7 @@
 	sx_xlock(&sc->sc_lock);
 	error = g_raid_destroy(sc, how);
 	if (error != 0)
-		sx_xunlock(&sc->sc_lock);
+		gctl_error(req, "Array is busy.");
 	g_topology_lock();
 }
 
@@ -204,7 +205,7 @@
 	}
 	nodename = gctl_get_asciiparam(req, "arg0");
 	if (nodename == NULL) {
-		gctl_error(req, "No array name recieved.");
+		gctl_error(req, "No array name received.");
 		return;
 	}
 	sc = g_raid_find_node(mp, nodename);

Modified: trunk/sys/geom/raid/g_raid_md_if.m
===================================================================
--- trunk/sys/geom/raid/g_raid_md_if.m	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/g_raid_md_if.m	2018-05-26 15:23:19 UTC (rev 9968)
@@ -23,6 +23,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
+# $FreeBSD: stable/10/sys/geom/raid/g_raid_md_if.m 234940 2012-05-03 05:32:56Z mav $
 # $MidnightBSD$
 
 #include <sys/param.h>


Property changes on: trunk/sys/geom/raid/g_raid_md_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/geom/raid/g_raid_tr_if.m
===================================================================
--- trunk/sys/geom/raid/g_raid_tr_if.m	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/g_raid_tr_if.m	2018-05-26 15:23:19 UTC (rev 9968)
@@ -23,6 +23,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
+# $FreeBSD: stable/10/sys/geom/raid/g_raid_tr_if.m 219974 2011-03-24 21:31:32Z mav $
 # $MidnightBSD$
 
 #include <sys/param.h>


Property changes on: trunk/sys/geom/raid/g_raid_tr_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/geom/raid/md_ddf.c
===================================================================
--- trunk/sys/geom/raid/md_ddf.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/md_ddf.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2012 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/md_ddf.c 299497 2016-05-12 00:45:57Z pfg $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -257,7 +258,7 @@
 	printf("BBM Log              %u:%u\n", GET32(meta, hdr->bbmlog_section), GET32(meta, hdr->bbmlog_length));
 	printf("Diagnostic Space     %u:%u\n", GET32(meta, hdr->Diagnostic_Space), GET32(meta, hdr->Diagnostic_Space_Length));
 	printf("Vendor_Specific_Logs %u:%u\n", GET32(meta, hdr->Vendor_Specific_Logs), GET32(meta, hdr->Vendor_Specific_Logs_Length));
-	printf("**** Controler Data ****\n");
+	printf("**** Controller Data ****\n");
 	printf("Controller_GUID      ");
 	print_guid(meta->cdr->Controller_GUID);
 	printf("\n");
@@ -1182,6 +1183,28 @@
 	g_free(buf);
 	if (GET32(meta, pdr->Signature) != DDF_PDR_SIGNATURE)
 		goto hdrerror;
+	/*
+	 * Workaround for reading metadata corrupted due to graid bug.
+	 * XXX: Remove this before we have disks above 128PB. :)
+	 */
+	if (meta->bigendian) {
+		for (i = 0; i < GET16(meta, pdr->Populated_PDEs); i++) {
+			if (isff(meta->pdr->entry[i].PD_GUID, 24))
+				continue;
+			if (GET32(meta, pdr->entry[i].PD_Reference) ==
+			    0xffffffff)
+				continue;
+			if (GET64(meta, pdr->entry[i].Configured_Size) >=
+			     (1ULL << 48)) {
+				SET16(meta, pdr->entry[i].PD_State,
+				    GET16(meta, pdr->entry[i].PD_State) &
+				    ~DDF_PDE_FAILED);
+				SET64(meta, pdr->entry[i].Configured_Size,
+				    GET64(meta, pdr->entry[i].Configured_Size) &
+				    ((1ULL << 48) - 1));
+			}
+		}
+	}
 
 	/* Read virtual disk records. */
 	buf = g_read_data(cp, (lba + GET32(meta, hdr->vdr_section)) * ss,
@@ -1711,7 +1734,7 @@
 	/* Welcome the new disk. */
 	if (resurrection)
 		g_raid_change_disk_state(disk, G_RAID_DISK_S_ACTIVE);
-	else if (GET8(gmeta, pdr->entry[md_pde_pos].PD_State) & DDF_PDE_PFA)
+	else if (GET16(gmeta, pdr->entry[md_pde_pos].PD_State) & DDF_PDE_PFA)
 		g_raid_change_disk_state(disk, G_RAID_DISK_S_FAILED);
 	else
 		g_raid_change_disk_state(disk, G_RAID_DISK_S_ACTIVE);
@@ -1730,11 +1753,11 @@
 		/* Stale disk, almost same as new. */
 		g_raid_change_subdisk_state(sd,
 		    G_RAID_SUBDISK_S_NEW);
-	} else if (GET8(gmeta, pdr->entry[md_pde_pos].PD_State) & DDF_PDE_PFA) {
+	} else if (GET16(gmeta, pdr->entry[md_pde_pos].PD_State) & DDF_PDE_PFA) {
 		/* Failed disk. */
 		g_raid_change_subdisk_state(sd,
 		    G_RAID_SUBDISK_S_FAILED);
-	} else if ((GET8(gmeta, pdr->entry[md_pde_pos].PD_State) &
+	} else if ((GET16(gmeta, pdr->entry[md_pde_pos].PD_State) &
 	     (DDF_PDE_FAILED | DDF_PDE_REBUILD)) != 0) {
 		/* Rebuilding disk. */
 		g_raid_change_subdisk_state(sd,
@@ -2098,13 +2121,10 @@
 	pp = cp->provider;
 
 	/* Read metadata from device. */
-	if (g_access(cp, 1, 0, 0) != 0)
-		return (G_RAID_MD_TASTE_FAIL);
 	g_topology_unlock();
 	bzero(&meta, sizeof(meta));
 	error = ddf_meta_read(cp, &meta);
 	g_topology_lock();
-	g_access(cp, -1, 0, 0);
 	if (error != 0)
 		return (G_RAID_MD_TASTE_FAIL);
 	be = meta.bigendian;
@@ -2142,7 +2162,11 @@
 		geom = sc->sc_geom;
 	}
 
+	/* There is no return after this point, so we close passed consumer. */
+	g_access(cp, -1, 0, 0);
+
 	rcp = g_new_consumer(geom);
+	rcp->flags |= G_CF_DIRECT_RECEIVE;
 	g_attach(rcp, pp);
 	if (g_access(rcp, 1, 1, 1) != 0)
 		; //goto fail1;
@@ -2832,24 +2856,24 @@
 			    GET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos]));
 			if (j < 0)
 				continue;
-			SET32(gmeta, pdr->entry[j].PD_Type,
-			    GET32(gmeta, pdr->entry[j].PD_Type) |
+			SET16(gmeta, pdr->entry[j].PD_Type,
+			    GET16(gmeta, pdr->entry[j].PD_Type) |
 			    DDF_PDE_PARTICIPATING);
 			if (sd->sd_state == G_RAID_SUBDISK_S_NONE)
-				SET32(gmeta, pdr->entry[j].PD_State,
-				    GET32(gmeta, pdr->entry[j].PD_State) |
+				SET16(gmeta, pdr->entry[j].PD_State,
+				    GET16(gmeta, pdr->entry[j].PD_State) |
 				    (DDF_PDE_FAILED | DDF_PDE_MISSING));
 			else if (sd->sd_state == G_RAID_SUBDISK_S_FAILED)
-				SET32(gmeta, pdr->entry[j].PD_State,
-				    GET32(gmeta, pdr->entry[j].PD_State) |
+				SET16(gmeta, pdr->entry[j].PD_State,
+				    GET16(gmeta, pdr->entry[j].PD_State) |
 				    (DDF_PDE_FAILED | DDF_PDE_PFA));
 			else if (sd->sd_state <= G_RAID_SUBDISK_S_REBUILD)
-				SET32(gmeta, pdr->entry[j].PD_State,
-				    GET32(gmeta, pdr->entry[j].PD_State) |
+				SET16(gmeta, pdr->entry[j].PD_State,
+				    GET16(gmeta, pdr->entry[j].PD_State) |
 				    DDF_PDE_REBUILD);
 			else
-				SET32(gmeta, pdr->entry[j].PD_State,
-				    GET32(gmeta, pdr->entry[j].PD_State) |
+				SET16(gmeta, pdr->entry[j].PD_State,
+				    GET16(gmeta, pdr->entry[j].PD_State) |
 				    DDF_PDE_ONLINE);
 		}
 	}
@@ -2862,8 +2886,8 @@
 		if (i < 0)
 			continue;
 		if (disk->d_state == G_RAID_DISK_S_FAILED) {
-			SET32(gmeta, pdr->entry[i].PD_State,
-			    GET32(gmeta, pdr->entry[i].PD_State) |
+			SET16(gmeta, pdr->entry[i].PD_State,
+			    GET16(gmeta, pdr->entry[i].PD_State) |
 			    (DDF_PDE_FAILED | DDF_PDE_PFA));
 		}
 		if (disk->d_state != G_RAID_DISK_S_SPARE)
@@ -2880,8 +2904,8 @@
 			    GET16(gmeta, pdr->entry[i].PD_Type) |
 			    DDF_PDE_CONFIG_SPARE);
 		}
-		SET32(gmeta, pdr->entry[i].PD_State,
-		    GET32(gmeta, pdr->entry[i].PD_State) |
+		SET16(gmeta, pdr->entry[i].PD_State,
+		    GET16(gmeta, pdr->entry[i].PD_State) |
 		    DDF_PDE_ONLINE);
 	}
 

Modified: trunk/sys/geom/raid/md_ddf.h
===================================================================
--- trunk/sys/geom/raid/md_ddf.h	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/md_ddf.h	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2012 Alexander Motin <mav at FreeBSD.org>
  * Copyright (c) 2008 Scott Long
@@ -24,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/geom/raid/md_ddf.h 234848 2012-04-30 17:53:02Z mav $
  */
 
 #ifndef MD_DDF_H

Modified: trunk/sys/geom/raid/md_intel.c
===================================================================
--- trunk/sys/geom/raid/md_intel.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/md_intel.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * Copyright (c) 2000 - 2008 Søren Schmidt <sos at FreeBSD.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/md_intel.c 286759 2015-08-14 02:45:22Z pfg $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -366,6 +367,78 @@
 	vol->curr_migr_unit_hi = curr_migr_unit >> 32;
 }
 
+static char *
+intel_status2str(int status)
+{
+
+	switch (status) {
+	case INTEL_S_READY:
+		return ("READY");
+	case INTEL_S_UNINITIALIZED:
+		return ("UNINITIALIZED");
+	case INTEL_S_DEGRADED:
+		return ("DEGRADED");
+	case INTEL_S_FAILURE:
+		return ("FAILURE");
+	default:
+		return ("UNKNOWN");
+	}
+}
+
+static char *
+intel_type2str(int type)
+{
+
+	switch (type) {
+	case INTEL_T_RAID0:
+		return ("RAID0");
+	case INTEL_T_RAID1:
+		return ("RAID1");
+	case INTEL_T_RAID5:
+		return ("RAID5");
+	default:
+		return ("UNKNOWN");
+	}
+}
+
+static char *
+intel_cngst2str(int cng_state)
+{
+
+	switch (cng_state) {
+	case INTEL_CNGST_UPDATED:
+		return ("UPDATED");
+	case INTEL_CNGST_NEEDS_UPDATE:
+		return ("NEEDS_UPDATE");
+	case INTEL_CNGST_MASTER_MISSING:
+		return ("MASTER_MISSING");
+	default:
+		return ("UNKNOWN");
+	}
+}
+
+static char *
+intel_mt2str(int type)
+{
+
+	switch (type) {
+	case INTEL_MT_INIT:
+		return ("INIT");
+	case INTEL_MT_REBUILD:
+		return ("REBUILD");
+	case INTEL_MT_VERIFY:
+		return ("VERIFY");
+	case INTEL_MT_GEN_MIGR:
+		return ("GEN_MIGR");
+	case INTEL_MT_STATE_CHANGE:
+		return ("STATE_CHANGE");
+	case INTEL_MT_REPAIR:
+		return ("REPAIR");
+	default:
+		return ("UNKNOWN");
+	}
+}
+
 static void
 g_raid_md_intel_print(struct intel_raid_conf *meta)
 {
@@ -384,7 +457,22 @@
 	printf("config_id           0x%08x\n", meta->config_id);
 	printf("generation          0x%08x\n", meta->generation);
 	printf("error_log_size      %d\n", meta->error_log_size);
-	printf("attributes          0x%08x\n", meta->attributes);
+	printf("attributes          0x%b\n", meta->attributes,
+		"\020"
+		"\001RAID0"
+		"\002RAID1"
+		"\003RAID10"
+		"\004RAID1E"
+		"\005RAID15"
+		"\006RAIDCNG"
+		"\007EXT_STRIP"
+		"\032NVM_CACHE"
+		"\0332TB_DISK"
+		"\034BBM"
+		"\035NVM_CACHE"
+		"\0362TB"
+		"\037PM"
+		"\040CHECKSUM");
 	printf("total_disks         %u\n", meta->total_disks);
 	printf("total_volumes       %u\n", meta->total_volumes);
 	printf("error_log_pos       %u\n", meta->error_log_pos);
@@ -392,12 +480,14 @@
 	printf("orig_config_id      0x%08x\n", meta->orig_config_id);
 	printf("pwr_cycle_count     %u\n", meta->pwr_cycle_count);
 	printf("bbm_log_size        %u\n", meta->bbm_log_size);
+	printf("Flags: S - Spare, A - Assigned, F - Failed, O - Online, D - Disabled\n");
 	printf("DISK#   serial disk_sectors disk_sectors_hi disk_id flags owner\n");
 	for (i = 0; i < meta->total_disks; i++ ) {
-		printf("    %d   <%.16s> %u %u 0x%08x 0x%08x %08x\n", i,
+		printf("    %d   <%.16s> %u %u 0x%08x 0x%b %08x\n", i,
 		    meta->disk[i].serial, meta->disk[i].sectors,
 		    meta->disk[i].sectors_hi, meta->disk[i].id,
-		    meta->disk[i].flags, meta->disk[i].owner_cfg_num);
+		    meta->disk[i].flags, "\20\01S\02A\03F\04O\05D",
+		    meta->disk[i].owner_cfg_num);
 	}
 	for (i = 0; i < meta->total_volumes; i++) {
 		mvol = intel_get_volume(meta, i);
@@ -404,7 +494,21 @@
 		printf(" ****** Volume %d ******\n", i);
 		printf(" name               %.16s\n", mvol->name);
 		printf(" total_sectors      %ju\n", mvol->total_sectors);
-		printf(" state              0x%08x\n", mvol->state);
+		printf(" state              0x%b\n", mvol->state,
+			"\020"
+			"\001BOOTABLE"
+			"\002BOOT_DEVICE"
+			"\003READ_COALESCING"
+			"\004WRITE_COALESCING"
+			"\005LAST_SHUTDOWN_DIRTY"
+			"\006HIDDEN_AT_BOOT"
+			"\007CURRENTLY_HIDDEN"
+			"\010VERIFY_AND_FIX"
+			"\011MAP_STATE_UNINIT"
+			"\012NO_AUTO_RECOVERY"
+			"\013CLONE_N_GO"
+			"\014CLONE_MAN_SYNC"
+			"\015CNG_MASTER_DISK_NUM");
 		printf(" reserved           %u\n", mvol->reserved);
 		printf(" migr_priority      %u\n", mvol->migr_priority);
 		printf(" num_sub_vols       %u\n", mvol->num_sub_vols);
@@ -411,13 +515,15 @@
 		printf(" tid                %u\n", mvol->tid);
 		printf(" cng_master_disk    %u\n", mvol->cng_master_disk);
 		printf(" cache_policy       %u\n", mvol->cache_policy);
-		printf(" cng_state          %u\n", mvol->cng_state);
+		printf(" cng_state          %u (%s)\n", mvol->cng_state,
+			intel_cngst2str(mvol->cng_state));
 		printf(" cng_sub_state      %u\n", mvol->cng_sub_state);
 		printf(" curr_migr_unit     %u\n", mvol->curr_migr_unit);
 		printf(" curr_migr_unit_hi  %u\n", mvol->curr_migr_unit_hi);
 		printf(" checkpoint_id      %u\n", mvol->checkpoint_id);
 		printf(" migr_state         %u\n", mvol->migr_state);
-		printf(" migr_type          %u\n", mvol->migr_type);
+		printf(" migr_type          %u (%s)\n", mvol->migr_type,
+			intel_mt2str(mvol->migr_type));
 		printf(" dirty              %u\n", mvol->dirty);
 		printf(" fs_state           %u\n", mvol->fs_state);
 		printf(" verify_errors      %u\n", mvol->verify_errors);
@@ -433,8 +539,10 @@
 			printf("  stripe_count      %u\n", mmap->stripe_count);
 			printf("  stripe_count_hi   %u\n", mmap->stripe_count_hi);
 			printf("  strip_sectors     %u\n", mmap->strip_sectors);
-			printf("  status            %u\n", mmap->status);
-			printf("  type              %u\n", mmap->type);
+			printf("  status            %u (%s)\n", mmap->status,
+				intel_status2str(mmap->status));
+			printf("  type              %u (%s)\n", mmap->type,
+				intel_type2str(mmap->type));
 			printf("  total_disks       %u\n", mmap->total_disks);
 			printf("  total_domains     %u\n", mmap->total_domains);
 			printf("  failed_disk_num   %u\n", mmap->failed_disk_num);
@@ -884,7 +992,7 @@
 		if (olddisk == NULL)
 			panic("No disk at position %d!", disk_pos);
 		if (olddisk->d_state != G_RAID_DISK_S_OFFLINE) {
-			G_RAID_DEBUG1(1, sc, "More then one disk for pos %d",
+			G_RAID_DEBUG1(1, sc, "More than one disk for pos %d",
 			    disk_pos);
 			g_raid_change_disk_state(disk, G_RAID_DISK_S_STALE);
 			return (0);
@@ -1380,10 +1488,7 @@
 
 	/* Read metadata from device. */
 	meta = NULL;
-	vendor = 0xffff;
 	disk_pos = 0;
-	if (g_access(cp, 1, 0, 0) != 0)
-		return (G_RAID_MD_TASTE_FAIL);
 	g_topology_unlock();
 	error = g_raid_md_get_label(cp, serial, sizeof(serial));
 	if (error != 0) {
@@ -1391,12 +1496,12 @@
 		    pp->name, error);
 		goto fail2;
 	}
-	len = 2;
+	vendor = 0xffff;
+	len = sizeof(vendor);
 	if (pp->geom->rank == 1)
 		g_io_getattr("GEOM::hba_vendor", cp, &len, &vendor);
 	meta = intel_meta_read(cp);
 	g_topology_lock();
-	g_access(cp, -1, 0, 0);
 	if (meta == NULL) {
 		if (g_raid_aggressive_spare) {
 			if (vendor != 0x8086) {
@@ -1476,7 +1581,11 @@
 		G_RAID_DEBUG1(1, sc, "root_mount_hold %p", mdi->mdio_rootmount);
 	}
 
+	/* There is no return after this point, so we close passed consumer. */
+	g_access(cp, -1, 0, 0);
+
 	rcp = g_new_consumer(geom);
+	rcp->flags |= G_CF_DIRECT_RECEIVE;
 	g_attach(rcp, pp);
 	if (g_access(rcp, 1, 1, 1) != 0)
 		; //goto fail1;
@@ -1511,7 +1620,6 @@
 	return (result);
 fail2:
 	g_topology_lock();
-	g_access(cp, -1, 0, 0);
 fail1:
 	free(meta, M_MD_INTEL);
 	return (G_RAID_MD_TASTE_FAIL);

Modified: trunk/sys/geom/raid/md_jmicron.c
===================================================================
--- trunk/sys/geom/raid/md_jmicron.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/md_jmicron.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * Copyright (c) 2000 - 2008 Søren Schmidt <sos at FreeBSD.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/md_jmicron.c 286759 2015-08-14 02:45:22Z pfg $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -494,7 +495,7 @@
 		if (olddisk == NULL)
 			panic("No disk at position %d!", disk_pos);
 		if (olddisk->d_state != G_RAID_DISK_S_OFFLINE) {
-			G_RAID_DEBUG1(1, sc, "More then one disk for pos %d",
+			G_RAID_DEBUG1(1, sc, "More than one disk for pos %d",
 			    disk_pos);
 			g_raid_change_disk_state(disk, G_RAID_DISK_S_STALE);
 			return (0);
@@ -836,16 +837,13 @@
 
 	/* Read metadata from device. */
 	meta = NULL;
+	g_topology_unlock();
 	vendor = 0xffff;
-	if (g_access(cp, 1, 0, 0) != 0)
-		return (G_RAID_MD_TASTE_FAIL);
-	g_topology_unlock();
-	len = 2;
+	len = sizeof(vendor);
 	if (pp->geom->rank == 1)
 		g_io_getattr("GEOM::hba_vendor", cp, &len, &vendor);
 	meta = jmicron_meta_read(cp);
 	g_topology_lock();
-	g_access(cp, -1, 0, 0);
 	if (meta == NULL) {
 		if (g_raid_aggressive_spare) {
 			if (vendor == 0x197b) {
@@ -922,7 +920,11 @@
 		G_RAID_DEBUG1(1, sc, "root_mount_hold %p", mdi->mdio_rootmount);
 	}
 
+	/* There is no return after this point, so we close passed consumer. */
+	g_access(cp, -1, 0, 0);
+
 	rcp = g_new_consumer(geom);
+	rcp->flags |= G_CF_DIRECT_RECEIVE;
 	g_attach(rcp, pp);
 	if (g_access(rcp, 1, 1, 1) != 0)
 		; //goto fail1;

Modified: trunk/sys/geom/raid/md_nvidia.c
===================================================================
--- trunk/sys/geom/raid/md_nvidia.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/md_nvidia.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Alexander Motin <mav at FreeBSD.org>
  * Copyright (c) 2000 - 2008 Søren Schmidt <sos at FreeBSD.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/md_nvidia.c 286759 2015-08-14 02:45:22Z pfg $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -256,14 +257,12 @@
 		    pp->name, error);
 		return (NULL);
 	}
-	meta = malloc(sizeof(*meta), M_MD_NVIDIA, M_WAITOK);
-	memcpy(meta, buf, min(sizeof(*meta), pp->sectorsize));
-	g_free(buf);
+	meta = (struct nvidia_raid_conf *)buf;
 
 	/* Check if this is an NVIDIA RAID struct */
 	if (strncmp(meta->nvidia_id, NVIDIA_MAGIC, strlen(NVIDIA_MAGIC))) {
 		G_RAID_DEBUG(1, "NVIDIA signature check failed on %s", pp->name);
-		free(meta, M_MD_NVIDIA);
+		g_free(buf);
 		return (NULL);
 	}
 	if (meta->config_size > 128 ||
@@ -270,9 +269,12 @@
 	    meta->config_size < 30) {
 		G_RAID_DEBUG(1, "NVIDIA metadata size looks wrong: %d",
 		    meta->config_size);
-		free(meta, M_MD_NVIDIA);
+		g_free(buf);
 		return (NULL);
 	}
+	meta = malloc(sizeof(*meta), M_MD_NVIDIA, M_WAITOK);
+	memcpy(meta, buf, min(sizeof(*meta), pp->sectorsize));
+	g_free(buf);
 
 	/* Check metadata checksum. */
 	for (checksum = 0, ptr = (uint32_t *)meta,
@@ -497,7 +499,7 @@
 		if (olddisk == NULL)
 			panic("No disk at position %d!", disk_pos);
 		if (olddisk->d_state != G_RAID_DISK_S_OFFLINE) {
-			G_RAID_DEBUG1(1, sc, "More then one disk for pos %d",
+			G_RAID_DEBUG1(1, sc, "More than one disk for pos %d",
 			    disk_pos);
 			g_raid_change_disk_state(disk, G_RAID_DISK_S_STALE);
 			return (0);
@@ -840,16 +842,13 @@
 
 	/* Read metadata from device. */
 	meta = NULL;
+	g_topology_unlock();
 	vendor = 0xffff;
-	if (g_access(cp, 1, 0, 0) != 0)
-		return (G_RAID_MD_TASTE_FAIL);
-	g_topology_unlock();
-	len = 2;
+	len = sizeof(vendor);
 	if (pp->geom->rank == 1)
 		g_io_getattr("GEOM::hba_vendor", cp, &len, &vendor);
 	meta = nvidia_meta_read(cp);
 	g_topology_lock();
-	g_access(cp, -1, 0, 0);
 	if (meta == NULL) {
 		if (g_raid_aggressive_spare) {
 			if (vendor == 0x10de) {
@@ -918,7 +917,11 @@
 		G_RAID_DEBUG1(1, sc, "root_mount_hold %p", mdi->mdio_rootmount);
 	}
 
+	/* There is no return after this point, so we close passed consumer. */
+	g_access(cp, -1, 0, 0);
+
 	rcp = g_new_consumer(geom);
+	rcp->flags |= G_CF_DIRECT_RECEIVE;
 	g_attach(rcp, pp);
 	if (g_access(rcp, 1, 1, 1) != 0)
 		; //goto fail1;

Modified: trunk/sys/geom/raid/md_promise.c
===================================================================
--- trunk/sys/geom/raid/md_promise.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/md_promise.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Alexander Motin <mav at FreeBSD.org>
  * Copyright (c) 2000 - 2008 Søren Schmidt <sos at FreeBSD.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/md_promise.c 299397 2016-05-11 00:36:31Z pfg $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -893,7 +894,7 @@
 	struct g_raid_md_promise_perdisk *pd;
 	struct g_raid_md_promise_pervolume *pv;
 	struct promise_raid_conf *meta;
-	int i;
+	u_int i;
 
 	sc = vol->v_softc;
 	md = sc->sc_md;
@@ -1105,16 +1106,13 @@
 
 	/* Read metadata from device. */
 	meta = NULL;
+	g_topology_unlock();
 	vendor = 0xffff;
-	if (g_access(cp, 1, 0, 0) != 0)
-		return (G_RAID_MD_TASTE_FAIL);
-	g_topology_unlock();
-	len = 2;
+	len = sizeof(vendor);
 	if (pp->geom->rank == 1)
 		g_io_getattr("GEOM::hba_vendor", cp, &len, &vendor);
 	subdisks = promise_meta_read(cp, metaarr);
 	g_topology_lock();
-	g_access(cp, -1, 0, 0);
 	if (subdisks == 0) {
 		if (g_raid_aggressive_spare) {
 			if (vendor == 0x105a || vendor == 0x1002) {
@@ -1175,7 +1173,11 @@
 		geom = sc->sc_geom;
 	}
 
+	/* There is no return after this point, so we close passed consumer. */
+	g_access(cp, -1, 0, 0);
+
 	rcp = g_new_consumer(geom);
+	rcp->flags |= G_CF_DIRECT_RECEIVE;
 	g_attach(rcp, pp);
 	if (g_access(rcp, 1, 1, 1) != 0)
 		; //goto fail1;

Modified: trunk/sys/geom/raid/md_sii.c
===================================================================
--- trunk/sys/geom/raid/md_sii.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/md_sii.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2011 Alexander Motin <mav at FreeBSD.org>
  * Copyright (c) 2000 - 2008 Søren Schmidt <sos at FreeBSD.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/md_sii.c 299397 2016-05-11 00:36:31Z pfg $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -277,15 +278,13 @@
 		    pp->name, error);
 		return (NULL);
 	}
-	meta = malloc(sizeof(*meta), M_MD_SII, M_WAITOK);
-	memcpy(meta, buf, min(sizeof(*meta), pp->sectorsize));
-	g_free(buf);
+	meta = (struct sii_raid_conf *)buf;
 
 	/* Check vendor ID. */
 	if (meta->vendor_id != 0x1095) {
 		G_RAID_DEBUG(1, "SiI vendor ID check failed on %s (0x%04x)",
 		    pp->name, meta->vendor_id);
-		free(meta, M_MD_SII);
+		g_free(buf);
 		return (NULL);
 	}
 
@@ -293,9 +292,12 @@
 	if (meta->version_major != 2) {
 		G_RAID_DEBUG(1, "SiI version check failed on %s (%d.%d)",
 		    pp->name, meta->version_major, meta->version_minor);
-		free(meta, M_MD_SII);
+		g_free(buf);
 		return (NULL);
 	}
+	meta = malloc(sizeof(*meta), M_MD_SII, M_WAITOK);
+	memcpy(meta, buf, min(sizeof(*meta), pp->sectorsize));
+	g_free(buf);
 
 	/* Check metadata checksum. */
 	for (checksum = 0, ptr = (uint16_t *)meta, i = 0; i <= 159; i++)
@@ -548,7 +550,7 @@
 		if (olddisk == NULL)
 			panic("No disk at position %d!", disk_pos);
 		if (olddisk->d_state != G_RAID_DISK_S_OFFLINE) {
-			G_RAID_DEBUG1(1, sc, "More then one disk for pos %d",
+			G_RAID_DEBUG1(1, sc, "More than one disk for pos %d",
 			    disk_pos);
 			g_raid_change_disk_state(disk, G_RAID_DISK_S_STALE);
 			return (0);
@@ -922,16 +924,13 @@
 
 	/* Read metadata from device. */
 	meta = NULL;
+	g_topology_unlock();
 	vendor = 0xffff;
-	if (g_access(cp, 1, 0, 0) != 0)
-		return (G_RAID_MD_TASTE_FAIL);
-	g_topology_unlock();
-	len = 2;
+	len = sizeof(vendor);
 	if (pp->geom->rank == 1)
 		g_io_getattr("GEOM::hba_vendor", cp, &len, &vendor);
 	meta = sii_meta_read(cp);
 	g_topology_lock();
-	g_access(cp, -1, 0, 0);
 	if (meta == NULL) {
 		if (g_raid_aggressive_spare) {
 			if (vendor == 0x1095) {
@@ -1011,7 +1010,11 @@
 		G_RAID_DEBUG1(1, sc, "root_mount_hold %p", mdi->mdio_rootmount);
 	}
 
+	/* There is no return after this point, so we close passed consumer. */
+	g_access(cp, -1, 0, 0);
+
 	rcp = g_new_consumer(geom);
+	rcp->flags |= G_CF_DIRECT_RECEIVE;
 	g_attach(rcp, pp);
 	if (g_access(rcp, 1, 1, 1) != 0)
 		; //goto fail1;
@@ -1480,7 +1483,7 @@
 	struct g_raid_md_sii_object *mdi;
 	struct g_raid_md_sii_perdisk *pd;
 	struct sii_raid_conf *meta;
-	int i;
+	u_int i;
 
 	sc = md->mdo_softc;
 	mdi = (struct g_raid_md_sii_object *)md;

Modified: trunk/sys/geom/raid/tr_concat.c
===================================================================
--- trunk/sys/geom/raid/tr_concat.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/tr_concat.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/tr_concat.c 326745 2017-12-10 13:45:41Z eugen $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -74,7 +75,8 @@
 	g_raid_tr_concat_methods,
 	sizeof(struct g_raid_tr_concat_object),
 	.trc_enable = 1,
-	.trc_priority = 50
+	.trc_priority = 50,
+	.trc_accept_unmapped = 1
 };
 
 static int
@@ -227,7 +229,10 @@
 
 	offset = bp->bio_offset;
 	remain = bp->bio_length;
-	addr = bp->bio_data;
+	if ((bp->bio_flags & BIO_UNMAPPED) != 0)
+		addr = NULL;
+	else
+		addr = bp->bio_data;
 	no = 0;
 	while (no < vol->v_disks_count &&
 	    offset >= vol->v_subdisks[no].sd_size) {
@@ -244,8 +249,16 @@
 		if (cbp == NULL)
 			goto failure;
 		cbp->bio_offset = offset;
-		cbp->bio_data = addr;
 		cbp->bio_length = length;
+		if ((bp->bio_flags & BIO_UNMAPPED) != 0 &&
+		    bp->bio_cmd != BIO_DELETE) {
+			cbp->bio_ma_offset += (uintptr_t)addr;
+			cbp->bio_ma += cbp->bio_ma_offset / PAGE_SIZE;
+			cbp->bio_ma_offset %= PAGE_SIZE;
+			cbp->bio_ma_n = round_page(cbp->bio_ma_offset +
+			    cbp->bio_length) / PAGE_SIZE;
+		} else
+			cbp->bio_data = addr;
 		cbp->bio_caller1 = sd;
 		bioq_insert_tail(&queue, cbp);
 		remain -= length;
@@ -257,9 +270,7 @@
 		    ("Request ends after volume end (%ju, %ju)",
 			bp->bio_offset, bp->bio_length));
 	} while (remain > 0);
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL) {
 		sd = cbp->bio_caller1;
 		cbp->bio_caller1 = NULL;
 		g_raid_subdisk_iostart(sd, cbp);
@@ -266,11 +277,8 @@
 	}
 	return;
 failure:
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL)
 		g_destroy_bio(cbp);
-	}
 	if (bp->bio_error == 0)
 		bp->bio_error = ENOMEM;
 	g_raid_iodone(bp, bp->bio_error);
@@ -332,7 +340,7 @@
 	pbp->bio_inbed++;
 	if (pbp->bio_children == pbp->bio_inbed) {
 		pbp->bio_completed = pbp->bio_length;
-		g_raid_iodone(pbp, bp->bio_error);
+		g_raid_iodone(pbp, pbp->bio_error);
 	}
 }
 

Modified: trunk/sys/geom/raid/tr_raid0.c
===================================================================
--- trunk/sys/geom/raid/tr_raid0.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/tr_raid0.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/tr_raid0.c 260385 2014-01-07 01:32:23Z scottl $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -74,7 +75,8 @@
 	g_raid_tr_raid0_methods,
 	sizeof(struct g_raid_tr_raid0_object),
 	.trc_enable = 1,
-	.trc_priority = 100
+	.trc_priority = 100,
+	.trc_accept_unmapped = 1
 };
 
 static int
@@ -204,7 +206,10 @@
 		g_raid_tr_flush_common(tr, bp);
 		return;
 	}
-	addr = bp->bio_data;
+	if ((bp->bio_flags & BIO_UNMAPPED) != 0)
+		addr = NULL;
+	else
+		addr = bp->bio_data;
 	strip_size = vol->v_strip_size;
 
 	/* Stripe number. */
@@ -225,8 +230,16 @@
 		if (cbp == NULL)
 			goto failure;
 		cbp->bio_offset = offset + start;
-		cbp->bio_data = addr;
 		cbp->bio_length = length;
+		if ((bp->bio_flags & BIO_UNMAPPED) != 0 &&
+		    bp->bio_cmd != BIO_DELETE) {
+			cbp->bio_ma_offset += (uintptr_t)addr;
+			cbp->bio_ma += cbp->bio_ma_offset / PAGE_SIZE;
+			cbp->bio_ma_offset %= PAGE_SIZE;
+			cbp->bio_ma_n = round_page(cbp->bio_ma_offset +
+			    cbp->bio_length) / PAGE_SIZE;
+		} else
+			cbp->bio_data = addr;
 		cbp->bio_caller1 = &vol->v_subdisks[no];
 		bioq_insert_tail(&queue, cbp);
 		if (++no >= vol->v_disks_count) {
@@ -238,9 +251,7 @@
 			addr += length;
 		start = 0;
 	} while (remain > 0);
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL) {
 		sd = cbp->bio_caller1;
 		cbp->bio_caller1 = NULL;
 		g_raid_subdisk_iostart(sd, cbp);
@@ -247,11 +258,8 @@
 	}
 	return;
 failure:
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL)
 		g_destroy_bio(cbp);
-	}
 	if (bp->bio_error == 0)
 		bp->bio_error = ENOMEM;
 	g_raid_iodone(bp, bp->bio_error);

Modified: trunk/sys/geom/raid/tr_raid1.c
===================================================================
--- trunk/sys/geom/raid/tr_raid1.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/tr_raid1.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/tr_raid1.c 260385 2014-01-07 01:32:23Z scottl $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -130,7 +131,8 @@
 	g_raid_tr_raid1_methods,
 	sizeof(struct g_raid_tr_raid1_object),
 	.trc_enable = 1,
-	.trc_priority = 100
+	.trc_priority = 100,
+	.trc_accept_unmapped = 1
 };
 
 static void g_raid_tr_raid1_rebuild_abort(struct g_raid_tr_object *tr);
@@ -594,9 +596,7 @@
 		cbp->bio_caller1 = sd;
 		bioq_insert_tail(&queue, cbp);
 	}
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL) {
 		sd = cbp->bio_caller1;
 		cbp->bio_caller1 = NULL;
 		g_raid_subdisk_iostart(sd, cbp);
@@ -603,11 +603,8 @@
 	}
 	return;
 failure:
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL)
 		g_destroy_bio(cbp);
-	}
 	if (bp->bio_error == 0)
 		bp->bio_error = ENOMEM;
 	g_raid_iodone(bp, bp->bio_error);

Modified: trunk/sys/geom/raid/tr_raid1e.c
===================================================================
--- trunk/sys/geom/raid/tr_raid1e.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/tr_raid1e.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/tr_raid1e.c 261455 2014-02-04 03:36:42Z eadler $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -134,7 +135,8 @@
 	g_raid_tr_raid1e_methods,
 	sizeof(struct g_raid_tr_raid1e_object),
 	.trc_enable = 1,
-	.trc_priority = 200
+	.trc_priority = 200,
+	.trc_accept_unmapped = 1
 };
 
 static void g_raid_tr_raid1e_rebuild_abort(struct g_raid_tr_object *tr);
@@ -701,7 +703,10 @@
 	int best;
 
 	vol = tr->tro_volume;
-	addr = bp->bio_data;
+	if ((bp->bio_flags & BIO_UNMAPPED) != 0)
+		addr = NULL;
+	else
+		addr = bp->bio_data;
 	strip_size = vol->v_strip_size;
 	V2P(vol, bp->bio_offset, &no, &offset, &start);
 	remain = bp->bio_length;
@@ -721,8 +726,15 @@
 		if (cbp == NULL)
 			goto failure;
 		cbp->bio_offset = offset + start;
-		cbp->bio_data = addr;
 		cbp->bio_length = length;
+		if ((bp->bio_flags & BIO_UNMAPPED) != 0) {
+			cbp->bio_ma_offset += (uintptr_t)addr;
+			cbp->bio_ma += cbp->bio_ma_offset / PAGE_SIZE;
+			cbp->bio_ma_offset %= PAGE_SIZE;
+			cbp->bio_ma_n = round_page(cbp->bio_ma_offset +
+			    cbp->bio_length) / PAGE_SIZE;
+		} else
+			cbp->bio_data = addr;
 		cbp->bio_caller1 = &vol->v_subdisks[no];
 		bioq_insert_tail(&queue, cbp);
 		no += N - best;
@@ -734,9 +746,7 @@
 		addr += length;
 		start = 0;
 	}
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL) {
 		sd = cbp->bio_caller1;
 		cbp->bio_caller1 = NULL;
 		g_raid_subdisk_iostart(sd, cbp);
@@ -743,11 +753,8 @@
 	}
 	return;
 failure:
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL)
 		g_destroy_bio(cbp);
-	}
 	if (bp->bio_error == 0)
 		bp->bio_error = ENOMEM;
 	g_raid_iodone(bp, bp->bio_error);
@@ -766,7 +773,10 @@
 	int i;
 
 	vol = tr->tro_volume;
-	addr = bp->bio_data;
+	if ((bp->bio_flags & BIO_UNMAPPED) != 0)
+		addr = NULL;
+	else
+		addr = bp->bio_data;
 	strip_size = vol->v_strip_size;
 	V2P(vol, bp->bio_offset, &no, &offset, &start);
 	remain = bp->bio_length;
@@ -791,8 +801,16 @@
 			if (cbp == NULL)
 				goto failure;
 			cbp->bio_offset = offset + start;
-			cbp->bio_data = addr;
 			cbp->bio_length = length;
+			if ((bp->bio_flags & BIO_UNMAPPED) != 0 &&
+			    bp->bio_cmd != BIO_DELETE) {
+				cbp->bio_ma_offset += (uintptr_t)addr;
+				cbp->bio_ma += cbp->bio_ma_offset / PAGE_SIZE;
+				cbp->bio_ma_offset %= PAGE_SIZE;
+				cbp->bio_ma_n = round_page(cbp->bio_ma_offset +
+				    cbp->bio_length) / PAGE_SIZE;
+			} else
+				cbp->bio_data = addr;
 			cbp->bio_caller1 = sd;
 			bioq_insert_tail(&queue, cbp);
 nextdisk:
@@ -806,9 +824,7 @@
 			addr += length;
 		start = 0;
 	}
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL) {
 		sd = cbp->bio_caller1;
 		cbp->bio_caller1 = NULL;
 		g_raid_subdisk_iostart(sd, cbp);
@@ -815,11 +831,8 @@
 	}
 	return;
 failure:
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL)
 		g_destroy_bio(cbp);
-	}
 	if (bp->bio_error == 0)
 		bp->bio_error = ENOMEM;
 	g_raid_iodone(bp, bp->bio_error);
@@ -1030,6 +1043,9 @@
 			cbp->bio_offset = offset + start;
 			cbp->bio_length = bp->bio_length;
 			cbp->bio_data = bp->bio_data;
+			cbp->bio_ma = bp->bio_ma;
+			cbp->bio_ma_offset = bp->bio_ma_offset;
+			cbp->bio_ma_n = bp->bio_ma_n;
 			g_destroy_bio(bp);
 			nsd = &vol->v_subdisks[disk];
 			G_RAID_LOGREQ(2, cbp, "Retrying read from %d",
@@ -1036,7 +1052,7 @@
 			    nsd->sd_pos);
 			if (do_write)
 				mask |= 1 << 31;
-			if ((mask & (1 << 31)) != 0)
+			if ((mask & (1U << 31)) != 0)
 				sd->sd_recovery++;
 			cbp->bio_caller2 = (void *)mask;
 			if (do_write) {
@@ -1059,7 +1075,7 @@
 	}
 	if (bp->bio_cmd == BIO_READ &&
 	    bp->bio_error == 0 &&
-	    (mask & (1 << 31)) != 0) {
+	    (mask & (1U << 31)) != 0) {
 		G_RAID_LOGREQ(3, bp, "Recovered data from other drive");
 
 		/* Restore what we were doing. */
@@ -1076,8 +1092,6 @@
 				offset += vol->v_strip_size;
 			}
 			cbp->bio_offset = offset + start;
-			cbp->bio_length = bp->bio_length;
-			cbp->bio_data = bp->bio_data;
 			cbp->bio_cmd = BIO_WRITE;
 			cbp->bio_cflags = G_RAID_BIO_FLAG_REMAP;
 			cbp->bio_caller2 = (void *)mask;
@@ -1088,7 +1102,7 @@
 			return;
 		}
 	}
-	if ((mask & (1 << 31)) != 0) {
+	if ((mask & (1U << 31)) != 0) {
 		/*
 		 * We're done with a recovery, mark the range as unlocked.
 		 * For any write errors, we agressively fail the disk since

Modified: trunk/sys/geom/raid/tr_raid5.c
===================================================================
--- trunk/sys/geom/raid/tr_raid5.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid/tr_raid5.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2012 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid/tr_raid5.c 326745 2017-12-10 13:45:41Z eugen $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -106,7 +107,8 @@
 	trs = (struct g_raid_tr_raid5_object *)tr;
 	qual = tr->tro_volume->v_raid_level_qualifier;
 	if (tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID4 &&
-	    qual >= 0 && qual <= 1) {
+	    (qual == G_RAID_VOLUME_RLQ_R4P0 ||
+	     qual == G_RAID_VOLUME_RLQ_R4PN)) {
 		/* RAID4 */
 	} else if ((tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5 ||
 	     tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5E ||
@@ -114,7 +116,10 @@
 	     tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5R ||
 	     tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID6 ||
 	     tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAIDMDF) &&
-	    qual >= 0 && qual <= 3) {
+	    (qual == G_RAID_VOLUME_RLQ_R5RA ||
+	     qual == G_RAID_VOLUME_RLQ_R5RS ||
+	     qual == G_RAID_VOLUME_RLQ_R5LA ||
+	     qual == G_RAID_VOLUME_RLQ_R5LS)) {
 		/* RAID5/5E/5EE/5R/6/MDF */
 	} else
 		return (G_RAID_TR_TASTE_FAIL);
@@ -181,8 +186,9 @@
 	struct g_raid_volume *vol;
 
 	trs = (struct g_raid_tr_raid5_object *)tr;
+	trs->trso_starting = 0;
 	vol = tr->tro_volume;
-	trs->trso_starting = 0;
+	vol->v_read_only = 1;
 	g_raid_tr_update_state_raid5(vol, NULL);
 	return (0);
 }
@@ -319,9 +325,7 @@
 		addr += length;
 		start = 0;
 	} while (remain > 0);
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL) {
 		sd = cbp->bio_caller1;
 		cbp->bio_caller1 = NULL;
 		g_raid_subdisk_iostart(sd, cbp);
@@ -328,11 +332,8 @@
 	}
 	return;
 failure:
-	for (cbp = bioq_first(&queue); cbp != NULL;
-	    cbp = bioq_first(&queue)) {
-		bioq_remove(&queue, cbp);
+	while ((cbp = bioq_takefirst(&queue)) != NULL)
 		g_destroy_bio(cbp);
-	}
 	if (bp->bio_error == 0)
 		bp->bio_error = ENOMEM;
 	g_raid_iodone(bp, bp->bio_error);
@@ -371,15 +372,15 @@
     struct g_raid_subdisk *sd, struct bio *bp)
 {
 	struct bio *pbp;
-	int error;
 
 	pbp = bp->bio_parent;
+	if (pbp->bio_error == 0)
+		pbp->bio_error = bp->bio_error;
 	pbp->bio_inbed++;
-	error = bp->bio_error;
 	g_destroy_bio(bp);
 	if (pbp->bio_children == pbp->bio_inbed) {
 		pbp->bio_completed = pbp->bio_length;
-		g_raid_iodone(pbp, error);
+		g_raid_iodone(pbp, pbp->bio_error);
 	}
 }
 

Modified: trunk/sys/geom/raid3/g_raid3.c
===================================================================
--- trunk/sys/geom/raid3/g_raid3.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/raid3/g_raid3.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$FreeBSD: src/sys/geom/raid3/g_raid3.c,v 1.81.2.3 2010/09/19 20:08:45 mav Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/raid3/g_raid3.c 314667 2017-03-04 13:03:31Z avg $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2379,8 +2379,7 @@
 	mtx_unlock(&sc->sc_queue_mtx);
 	G_RAID3_DEBUG(0, "Device %s: provider %s destroyed.", sc->sc_name,
 	    sc->sc_provider->name);
-	sc->sc_provider->flags |= G_PF_WITHER;
-	g_orphan_provider(sc->sc_provider, ENXIO);
+	g_wither_provider(sc->sc_provider, ENXIO);
 	g_topology_unlock();
 	sc->sc_provider = NULL;
 	if (sc->sc_syncdisk != NULL)
@@ -3167,7 +3166,7 @@
 	bioq_init(&sc->sc_sync_delayed);
 	TAILQ_INIT(&sc->sc_events);
 	mtx_init(&sc->sc_events_mtx, "graid3:events", NULL, MTX_DEF);
-	callout_init(&sc->sc_callout, CALLOUT_MPSAFE);
+	callout_init(&sc->sc_callout, 1);
 	sc->sc_state = G_RAID3_DEVICE_STATE_STARTING;
 	gp->softc = sc;
 	sc->sc_geom = gp;

Modified: trunk/sys/geom/sched/g_sched.c
===================================================================
--- trunk/sys/geom/sched/g_sched.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/sched/g_sched.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009-2010 Fabio Checconi
  * Copyright (c) 2009-2010 Luigi Rizzo, Universita` di Pisa
@@ -26,8 +27,8 @@
  */
 
 /*
- * $Id: g_sched.c,v 1.1.1.1 2012-07-21 15:17:20 laffer1 Exp $
- * $FreeBSD$
+ * $Id$
+ * $FreeBSD: stable/10/sys/geom/sched/g_sched.c 243333 2012-11-20 12:32:18Z jh $
  *
  * Main control module for geom-based disk schedulers ('sched').
  *

Modified: trunk/sys/geom/sched/g_sched.h
===================================================================
--- trunk/sys/geom/sched/g_sched.h	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/sched/g_sched.h	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009-2010 Fabio Checconi
  * Copyright (c) 2009-2010 Luigi Rizzo, Universita` di Pisa
@@ -29,8 +30,8 @@
 #define	_G_SCHED_H_
 
 /*
- * $Id: g_sched.h,v 1.1.1.1 2012-07-21 15:17:20 laffer1 Exp $
- * $FreeBSD$
+ * $Id$
+ * $FreeBSD: stable/10/sys/geom/sched/g_sched.h 206552 2010-04-13 09:56:17Z luigi $
  *
  * Header for the geom_sched class (userland library and kernel part).
  * See g_sched.c for documentation.

Modified: trunk/sys/geom/sched/gs_rr.c
===================================================================
--- trunk/sys/geom/sched/gs_rr.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/sched/gs_rr.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009-2010 Fabio Checconi
  * Copyright (c) 2009-2010 Luigi Rizzo, Universita` di Pisa
@@ -26,8 +27,8 @@
  */
 
 /*
- * $Id: gs_rr.c,v 1.1.1.1 2012-07-21 15:17:20 laffer1 Exp $
- * $FreeBSD$
+ * $Id$
+ * $FreeBSD: stable/10/sys/geom/sched/gs_rr.c 314667 2017-03-04 13:03:31Z avg $
  *
  * A round-robin (RR) anticipatory scheduler, with per-client queues.
  *
@@ -602,7 +603,7 @@
 	sc = malloc(sizeof *sc, M_GEOM_SCHED, M_NOWAIT | M_ZERO);
 	sc->sc_geom = geom;
 	TAILQ_INIT(&sc->sc_rr_tailq);
-	callout_init(&sc->sc_wait, CALLOUT_MPSAFE);
+	callout_init(&sc->sc_wait, 1);
 	LIST_INSERT_HEAD(&me.sc_head, sc, sc_next);
 	me.units++;
 

Modified: trunk/sys/geom/sched/gs_scheduler.h
===================================================================
--- trunk/sys/geom/sched/gs_scheduler.h	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/sched/gs_scheduler.h	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2009-2010 Fabio Checconi
  * Copyright (c) 2009-2010 Luigi Rizzo, Universita` di Pisa
@@ -26,8 +27,8 @@
  */
 
 /*
- * $Id: gs_scheduler.h,v 1.1.1.1 2012-07-21 15:17:20 laffer1 Exp $
- * $FreeBSD$
+ * $Id$
+ * $FreeBSD: stable/10/sys/geom/sched/gs_scheduler.h 218909 2011-02-21 09:01:34Z brucec $
  *
  * Prototypes for GEOM-based disk scheduling algorithms.
  * See g_sched.c for generic documentation.

Modified: trunk/sys/geom/sched/subr_disk.c
===================================================================
--- trunk/sys/geom/sched/subr_disk.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/sched/subr_disk.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * ----------------------------------------------------------------------------
  * "THE BEER-WARE LICENSE" (Revision 42):
@@ -12,7 +13,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/geom/sched/subr_disk.c 212160 2010-09-02 19:40:28Z gibbs $");
 
 //#include "opt_geom.h"
 

Modified: trunk/sys/geom/shsec/g_shsec.c
===================================================================
--- trunk/sys/geom/shsec/g_shsec.c	2018-05-26 15:19:25 UTC (rev 9967)
+++ trunk/sys/geom/shsec/g_shsec.c	2018-05-26 15:23:19 UTC (rev 9968)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/geom/shsec/g_shsec.c,v 1.6 2006/11/01 12:30:51 pjd Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/geom/shsec/g_shsec.c 306765 2016-10-06 15:36:13Z mav $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -159,7 +159,7 @@
 
 	sc->sc_disks[no] = NULL;
 	if (sc->sc_provider != NULL) {
-		g_orphan_provider(sc->sc_provider, ENXIO);
+		g_wither_provider(sc->sc_provider, ENXIO);
 		sc->sc_provider = NULL;
 		G_SHSEC_DEBUG(0, "Device %s removed.", sc->sc_name);
 	}



More information about the Midnightbsd-cvs mailing list