6899159 injection isn't trashing pools
authorTim Haley <Tim.Haley@Sun.COM>
Mon, 09 Nov 2009 23:34:30 -0700
changeset 11026 e8e10df16a8f
parent 11025 96e66bda9446
child 11027 331e3aa86967
6899159 injection isn't trashing pools 6899160 pool recovery info sometimes not appearing
usr/src/lib/libzfs/common/libzfs_pool.c
usr/src/uts/common/fs/zfs/metaslab.c
usr/src/uts/common/fs/zfs/spa.c
usr/src/uts/common/fs/zfs/zio.c
usr/src/uts/common/fs/zfs/zio_inject.c
--- a/usr/src/lib/libzfs/common/libzfs_pool.c	Tue Nov 10 11:43:02 2009 +0530
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c	Mon Nov 09 23:34:30 2009 -0700
@@ -1355,8 +1355,8 @@
 		}
 	}
 	(void) printf(dgettext(TEXT_DOMAIN,
-	    "Recovery can be\n\tattempted by executing "
-	    "'zpool %s -F %s'.  "), reason >= 0 ? "clear" : "import", name);
+	    "Recovery can be attempted\n\tby executing 'zpool %s -F %s'.  "),
+	    reason >= 0 ? "clear" : "import", name);
 
 	(void) printf(dgettext(TEXT_DOMAIN,
 	    "A scrub of the pool\n"
--- a/usr/src/uts/common/fs/zfs/metaslab.c	Tue Nov 10 11:43:02 2009 +0530
+++ b/usr/src/uts/common/fs/zfs/metaslab.c	Mon Nov 09 23:34:30 2009 -0700
@@ -196,7 +196,12 @@
 {
 	ASSERT(mg->mg_prev == NULL);
 	ASSERT(mg->mg_next == NULL);
-	ASSERT(mg->mg_activation_count + mg->mg_vd->vdev_removing == 0);
+	/*
+	 * We may have gone below zero with the activation count
+	 * either because we never activated in the first place or
+	 * because we're done, and possibly removing the vdev.
+	 */
+	ASSERT(mg->mg_activation_count <= 0);
 
 	avl_destroy(&mg->mg_metaslab_tree);
 	mutex_destroy(&mg->mg_lock);
--- a/usr/src/uts/common/fs/zfs/spa.c	Tue Nov 10 11:43:02 2009 +0530
+++ b/usr/src/uts/common/fs/zfs/spa.c	Mon Nov 09 23:34:30 2009 -0700
@@ -1245,6 +1245,8 @@
 		verify_ok = B_TRUE;
 		spa->spa_load_txg = spa->spa_uberblock.ub_txg;
 		spa->spa_load_txg_ts = spa->spa_uberblock.ub_timestamp;
+	} else {
+		spa->spa_load_max_txg = spa->spa_uberblock.ub_txg;
 	}
 
 	if (error) {
@@ -1822,10 +1824,12 @@
 	uint64_t safe_rollback_txg;
 	uint64_t min_txg;
 
-	if (spa->spa_load_txg && state == SPA_LOAD_RECOVER)
+	if (spa->spa_load_txg && state == SPA_LOAD_RECOVER) {
 		spa->spa_load_max_txg = spa->spa_load_txg;
-	else
+		spa->spa_log_state = SPA_LOG_CLEAR;
+	} else {
 		spa->spa_load_max_txg = max_request;
+	}
 
 	load_error = rewind_error = spa_load(spa, state, mosconfig);
 	if (load_error == 0)
@@ -1977,16 +1981,16 @@
 
 	spa_open_ref(spa, tag);
 
-	spa->spa_last_open_failed = 0;
 
 	if (config != NULL)
 		*config = spa_config_generate(spa, NULL, -1ULL, B_TRUE);
 
-	spa->spa_last_ubsync_txg = 0;
-	spa->spa_load_txg = 0;
-
-	if (locked)
+	if (locked) {
+		spa->spa_last_open_failed = 0;
+		spa->spa_last_ubsync_txg = 0;
+		spa->spa_load_txg = 0;
 		mutex_exit(&spa_namespace_lock);
+	}
 
 	*spapp = spa;
 
--- a/usr/src/uts/common/fs/zfs/zio.c	Tue Nov 10 11:43:02 2009 +0530
+++ b/usr/src/uts/common/fs/zfs/zio.c	Mon Nov 09 23:34:30 2009 -0700
@@ -1008,10 +1008,6 @@
 			arc_free(zio->io_spa, bp);
 	}
 
-	if (zio_injection_enabled &&
-	    zio->io_spa->spa_syncing_txg == zio->io_txg)
-		zio_handle_ignored_writes(zio);
-
 	return (ZIO_PIPELINE_CONTINUE);
 }
 
@@ -2573,6 +2569,10 @@
 		}
 	}
 
+	if (zio_injection_enabled &&
+	    zio->io_spa->spa_syncing_txg == zio->io_txg)
+		zio_handle_ignored_writes(zio);
+
 	return (ZIO_PIPELINE_CONTINUE);
 }
 
--- a/usr/src/uts/common/fs/zfs/zio_inject.c	Tue Nov 10 11:43:02 2009 +0530
+++ b/usr/src/uts/common/fs/zfs/zio_inject.c	Mon Nov 09 23:34:30 2009 -0700
@@ -322,7 +322,10 @@
 			else
 				handler->zi_record.zi_timer = zio->io_txg;
 		}
-		zio->io_pipeline &= ~ZIO_VDEV_IO_STAGES;
+
+		/* Have a "problem" writing 60% of the time */
+		if (spa_get_random(100) < 60)
+			zio->io_pipeline &= ~ZIO_VDEV_IO_STAGES;
 		break;
 	}