Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Mar 2018 20:43:43 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r330524 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201803052043.w25Khh9v089474@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Mon Mar  5 20:43:43 2018
New Revision: 330524
URL: https://svnweb.freebsd.org/changeset/base/330524

Log:
  MFC r324940:
  
  Fix the error message when creating a zpool on a too-small device
  
  Don't check for SPA_MINDEVSIZE in vdev_geom_attach when opening by path.
  It's redundant with the check in vdev_open, and failing to attach here
  results in the wrong error message being printed.  However, still check for
  it in some other situations:
  
  * When opening by guids, so we don't get bogged down reading from slow
    devices like floppy drives.
  * In vdev_geom_read_pool_label for the same reason, because we iterate over
    all providers.
  * If the caller requests that we verify the guid, because then we'll have to
    read from the device before vdev_open verifies the size.
  
  PR:		222227
  Reported by:	Marie Helene Kvello-Aune <marieheleneka@gmail.com>
  Reviewed by:	avg, mav
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D12531

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Mon Mar  5 20:37:54 2018	(r330523)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c	Mon Mar  5 20:43:43 2018	(r330524)
@@ -195,7 +195,7 @@ vdev_geom_orphan(struct g_consumer *cp)
 }
 
 static struct g_consumer *
-vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
+vdev_geom_attach(struct g_provider *pp, vdev_t *vd, boolean_t sanity)
 {
 	struct g_geom *gp;
 	struct g_consumer *cp;
@@ -205,14 +205,18 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
 
 	ZFS_LOG(1, "Attaching to %s.", pp->name);
 
-	if (pp->sectorsize > VDEV_PAD_SIZE || !ISP2(pp->sectorsize)) {
-		ZFS_LOG(1, "Failing attach of %s. Incompatible sectorsize %d\n",
-		    pp->name, pp->sectorsize);
-		return (NULL);
-	} else if (pp->mediasize < SPA_MINDEVSIZE) {
-		ZFS_LOG(1, "Failing attach of %s. Incompatible mediasize %ju\n",
-		    pp->name, pp->mediasize);
-		return (NULL);
+	if (sanity) {
+		if (pp->sectorsize > VDEV_PAD_SIZE || !ISP2(pp->sectorsize)) {
+			ZFS_LOG(1, "Failing attach of %s. "
+				   "Incompatible sectorsize %d\n",
+			    pp->name, pp->sectorsize);
+			return (NULL);
+		} else if (pp->mediasize < SPA_MINDEVSIZE) {
+			ZFS_LOG(1, "Failing attach of %s. "
+				   "Incompatible mediasize %ju\n",
+			    pp->name, pp->mediasize);
+			return (NULL);
+		}
 	}
 
 	/* Do we have geom already? No? Create one. */
@@ -589,7 +593,7 @@ vdev_geom_read_pool_label(const char *name,
 			LIST_FOREACH(pp, &gp->provider, provider) {
 				if (pp->flags & G_PF_WITHER)
 					continue;
-				zcp = vdev_geom_attach(pp, NULL);
+				zcp = vdev_geom_attach(pp, NULL, B_TRUE);
 				if (zcp == NULL)
 					continue;
 				g_topology_unlock();
@@ -629,7 +633,7 @@ vdev_attach_ok(vdev_t *vd, struct g_provider *pp)
 	struct g_consumer *cp;
 	int nlabels;
 
-	cp = vdev_geom_attach(pp, NULL);
+	cp = vdev_geom_attach(pp, NULL, B_TRUE);
 	if (cp == NULL) {
 		ZFS_LOG(1, "Unable to attach tasting instance to %s.",
 		    pp->name);
@@ -637,14 +641,12 @@ vdev_attach_ok(vdev_t *vd, struct g_provider *pp)
 	}
 	g_topology_unlock();
 	nlabels = vdev_geom_read_config(cp, &config);
+	g_topology_lock();
+	vdev_geom_detach(cp, B_TRUE);
 	if (nlabels == 0) {
-		g_topology_lock();
-		vdev_geom_detach(cp, B_TRUE);
 		ZFS_LOG(1, "Unable to read config from %s.", pp->name);
 		return (NO_MATCH);
 	}
-	g_topology_lock();
-	vdev_geom_detach(cp, B_TRUE);
 
 	pool_guid = 0;
 	(void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &pool_guid);
@@ -716,7 +718,7 @@ vdev_geom_attach_by_guids(vdev_t *vd)
 
 out:
 	if (best_pp) {
-		cp = vdev_geom_attach(best_pp, vd);
+		cp = vdev_geom_attach(best_pp, vd, B_TRUE);
 		if (cp == NULL) {
 			printf("ZFS WARNING: Unable to attach to %s.\n",
 			    best_pp->name);
@@ -770,7 +772,7 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid)
 	if (pp != NULL) {
 		ZFS_LOG(1, "Found provider by name %s.", vd->vdev_path);
 		if (!check_guid || vdev_attach_ok(vd, pp) == FULL_MATCH)
-			cp = vdev_geom_attach(pp, vd);
+			cp = vdev_geom_attach(pp, vd, B_FALSE);
 	}
 
 	return (cp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803052043.w25Khh9v089474>