usr/src/uts/common/fs/zfs/spa.c
changeset 1986 628267397204
parent 1807 35c8b566d7af
child 2082 76b439ec3ac1
--- a/usr/src/uts/common/fs/zfs/spa.c	Tue May 16 09:55:08 2006 -0700
+++ b/usr/src/uts/common/fs/zfs/spa.c	Tue May 16 11:20:11 2006 -0700
@@ -313,6 +313,25 @@
 	}
 
 	/*
+	 * Validate the labels for all leaf vdevs.  We need to grab the config
+	 * lock because all label I/O is done with the ZIO_FLAG_CONFIG_HELD
+	 * flag.
+	 */
+	spa_config_enter(spa, RW_READER, FTAG);
+	error = vdev_validate(rvd);
+	spa_config_exit(spa, FTAG);
+
+	if (error != 0) {
+		error = EBADF;
+		goto out;
+	}
+
+	if (rvd->vdev_state <= VDEV_STATE_CANT_OPEN) {
+		error = ENXIO;
+		goto out;
+	}
+
+	/*
 	 * Find the best uberblock.
 	 */
 	bzero(ub, sizeof (uberblock_t));
@@ -444,16 +463,9 @@
 	}
 
 	/*
-	 * Load the vdev state for all top level vdevs.  We need to grab the
-	 * config lock because all label I/O is done with the
-	 * ZIO_FLAG_CONFIG_HELD flag.
+	 * Load the vdev state for all toplevel vdevs.
 	 */
-	spa_config_enter(spa, RW_READER, FTAG);
-	error = vdev_load(rvd);
-	spa_config_exit(spa, FTAG);
-
-	if (error)
-		goto out;
+	vdev_load(rvd);
 
 	/*
 	 * Propagate the leaf DTLs we just loaded all the way up the tree.
@@ -569,11 +581,11 @@
 
 		if (error == EBADF) {
 			/*
-			 * If vdev_load() returns EBADF, it indicates that one
-			 * of the vdevs indicates that the pool has been
-			 * exported or destroyed.  If this is the case, the
-			 * config cache is out of sync and we should remove the
-			 * pool from the namespace.
+			 * If vdev_validate() returns failure (indicated by
+			 * EBADF), it indicates that one of the vdevs indicates
+			 * that the pool has been exported or destroyed.  If
+			 * this is the case, the config cache is out of sync and
+			 * we should remove the pool from the namespace.
 			 */
 			spa_unload(spa);
 			spa_deactivate(spa);