changeset 10000:241a51d8720c

6848242 zdb -e no longer works as expected
author Victor Latushkin <Victor.Latushkin@Sun.COM>
date Tue, 30 Jun 2009 04:09:23 -0700
parents d5e89571de4e
children d540bbbe2461
files usr/src/cmd/zpool/zpool_main.c usr/src/uts/common/fs/zfs/spa.c usr/src/uts/common/fs/zfs/spa_config.c usr/src/uts/common/fs/zfs/sys/spa_impl.h usr/src/uts/common/fs/zfs/vdev.c
diffstat 5 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/zpool/zpool_main.c	Tue Jun 30 15:05:56 2009 +0800
+++ b/usr/src/cmd/zpool/zpool_main.c	Tue Jun 30 04:09:23 2009 -0700
@@ -1469,7 +1469,7 @@
  */
 static int
 do_import(nvlist_t *config, const char *newname, const char *mntopts,
-    int force, nvlist_t *props, boolean_t allowfaulted)
+    int force, nvlist_t *props, boolean_t do_verbatim)
 {
 	zpool_handle_t *zhp;
 	char *name;
@@ -1522,14 +1522,14 @@
 		}
 	}
 
-	if (zpool_import_props(g_zfs, config, newname, props,
-	    allowfaulted) != 0)
+	if (zpool_import_props(g_zfs, config, newname, props, do_verbatim) != 0)
 		return (1);
 
 	if (newname != NULL)
 		name = (char *)newname;
 
-	verify((zhp = zpool_open_canfail(g_zfs, name)) != NULL);
+	if ((zhp = zpool_open_canfail(g_zfs, name)) == NULL)
+		return (1);
 
 	if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL &&
 	    zpool_enable_datasets(zhp, mntopts, 0) != 0) {
@@ -1566,7 +1566,8 @@
  *       -F	Import even in the presence of faulted vdevs.  This is an
  *       	intentionally undocumented option for testing purposes, and
  *       	treats the pool configuration as complete, leaving any bad
- *		vdevs in the FAULTED state.
+ *		vdevs in the FAULTED state. In other words, it does verbatim
+ *		import.
  *
  *       -a	Import all pools found.
  *
@@ -1595,7 +1596,7 @@
 	nvlist_t *found_config;
 	nvlist_t *props = NULL;
 	boolean_t first;
-	boolean_t allow_faulted = B_FALSE;
+	boolean_t do_verbatim = B_FALSE;
 	uint64_t pool_state;
 	char *cachefile = NULL;
 
@@ -1628,7 +1629,7 @@
 			do_force = B_TRUE;
 			break;
 		case 'F':
-			allow_faulted = B_TRUE;
+			do_verbatim = B_TRUE;
 			break;
 		case 'o':
 			if ((propval = strchr(optarg, '=')) != NULL) {
@@ -1778,7 +1779,7 @@
 
 			if (do_all)
 				err |= do_import(config, NULL, mntopts,
-				    do_force, props, allow_faulted);
+				    do_force, props, do_verbatim);
 			else
 				show_import(config);
 		} else if (searchname != NULL) {
@@ -1826,7 +1827,7 @@
 			err = B_TRUE;
 		} else {
 			err |= do_import(found_config, argc == 1 ? NULL :
-			    argv[1], mntopts, do_force, props, allow_faulted);
+			    argv[1], mntopts, do_force, props, do_verbatim);
 		}
 	}
 
--- a/usr/src/uts/common/fs/zfs/spa.c	Tue Jun 30 15:05:56 2009 +0800
+++ b/usr/src/uts/common/fs/zfs/spa.c	Tue Jun 30 04:09:23 2009 -0700
@@ -2493,6 +2493,8 @@
 	    zpool_prop_to_name(ZPOOL_PROP_ALTROOT), &altroot);
 	spa = spa_add(pool, altroot);
 
+	spa->spa_inactive_states_ok = B_TRUE;
+
 	VERIFY(nvlist_dup(config, &spa->spa_config, 0) == 0);
 
 	if (props != NULL)
--- a/usr/src/uts/common/fs/zfs/spa_config.c	Tue Jun 30 15:05:56 2009 +0800
+++ b/usr/src/uts/common/fs/zfs/spa_config.c	Tue Jun 30 04:09:23 2009 -0700
@@ -209,7 +209,7 @@
 
 	ASSERT(MUTEX_HELD(&spa_namespace_lock));
 
-	if (rootdir == NULL)
+	if (rootdir == NULL || !(spa_mode_global & FWRITE))
 		return;
 
 	/*
--- a/usr/src/uts/common/fs/zfs/sys/spa_impl.h	Tue Jun 30 15:05:56 2009 +0800
+++ b/usr/src/uts/common/fs/zfs/sys/spa_impl.h	Tue Jun 30 04:09:23 2009 -0700
@@ -105,6 +105,7 @@
 	int		spa_inject_ref;		/* injection references */
 	uint8_t		spa_sync_on;		/* sync threads are running */
 	spa_load_state_t spa_load_state;	/* current load operation */
+	boolean_t	spa_inactive_states_ok;	/* ok to open inactive state? */
 	taskq_t		*spa_zio_taskq[ZIO_TYPES][ZIO_TASKQ_TYPES];
 	dsl_pool_t	*spa_dsl_pool;
 	metaslab_class_t *spa_normal_class;	/* normal data class */
--- a/usr/src/uts/common/fs/zfs/vdev.c	Tue Jun 30 15:05:56 2009 +0800
+++ b/usr/src/uts/common/fs/zfs/vdev.c	Tue Jun 30 04:09:23 2009 -0700
@@ -1187,6 +1187,7 @@
 	nvlist_t *label;
 	uint64_t guid, top_guid;
 	uint64_t state;
+	boolean_t inactive_state;
 
 	for (int c = 0; c < vd->vdev_children; c++)
 		if (vdev_validate(vd->vdev_child[c]) != 0)
@@ -1243,8 +1244,12 @@
 
 		nvlist_free(label);
 
+		inactive_state = (state == POOL_STATE_EXPORTED ||
+		    state == POOL_STATE_DESTROYED);
+
 		if (spa->spa_load_state == SPA_LOAD_OPEN &&
-		    state != POOL_STATE_ACTIVE)
+		    !(state == POOL_STATE_ACTIVE) &&
+		    !(spa->spa_inactive_states_ok && inactive_state))
 			return (EBADF);
 
 		/*