diff usr/src/uts/common/fs/zfs/spa.c @ 9946:86a051e72232

6842809 zfs history needs to record system info on import/create
author Mark J Musante <Mark.Musante@Sun.COM>
date Mon, 22 Jun 2009 21:15:44 -0400
parents 847676ec1c5b
children 241a51d8720c
line wrap: on
line diff
--- a/usr/src/uts/common/fs/zfs/spa.c	Tue Jun 23 09:05:45 2009 +0800
+++ b/usr/src/uts/common/fs/zfs/spa.c	Mon Jun 22 21:15:44 2009 -0400
@@ -2271,6 +2271,7 @@
 
 	if (version >= SPA_VERSION_ZPOOL_HISTORY && history_str != NULL)
 		(void) spa_history_log(spa, history_str, LOG_CMD_POOL_CREATE);
+	spa_history_log_version(spa, LOG_POOL_CREATE);
 
 	spa->spa_minref = refcount_count(&spa->spa_refcount);
 
@@ -2459,6 +2460,7 @@
 
 	VERIFY(nvlist_dup(config, &spa->spa_config, 0) == 0);
 	error = 0;
+	spa_history_log_version(spa, LOG_POOL_IMPORT);
 out:
 	spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
 	vdev_free(rvd);
@@ -2499,6 +2501,7 @@
 	spa_config_sync(spa, B_FALSE, B_TRUE);
 
 	mutex_exit(&spa_namespace_lock);
+	spa_history_log_version(spa, LOG_POOL_IMPORT);
 
 	return (0);
 }
@@ -2634,6 +2637,7 @@
 	spa_async_request(spa, SPA_ASYNC_AUTOEXPAND);
 
 	mutex_exit(&spa_namespace_lock);
+	spa_history_log_version(spa, LOG_POOL_IMPORT);
 
 	return (0);
 }
@@ -2991,7 +2995,6 @@
 	vdev_t *rvd = spa->spa_root_vdev;
 	vdev_t *oldvd, *newvd, *newrootvd, *pvd, *tvd;
 	vdev_ops_t *pvops;
-	dmu_tx_t *tx;
 	char *oldvdpath, *newvdpath;
 	int newvd_isspare;
 	int error;
@@ -3147,17 +3150,11 @@
 
 	(void) spa_vdev_exit(spa, newrootvd, open_txg, 0);
 
-	tx = dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir);
-	if (dmu_tx_assign(tx, TXG_WAIT) == 0) {
-		spa_history_internal_log(LOG_POOL_VDEV_ATTACH, spa, tx,
-		    CRED(),  "%s vdev=%s %s vdev=%s",
-		    replacing && newvd_isspare ? "spare in" :
-		    replacing ? "replace" : "attach", newvdpath,
-		    replacing ? "for" : "to", oldvdpath);
-		dmu_tx_commit(tx);
-	} else {
-		dmu_tx_abort(tx);
-	}
+	spa_history_internal_log(LOG_POOL_VDEV_ATTACH, spa, NULL,
+	    CRED(),  "%s vdev=%s %s vdev=%s",
+	    replacing && newvd_isspare ? "spare in" :
+	    replacing ? "replace" : "attach", newvdpath,
+	    replacing ? "for" : "to", oldvdpath);
 
 	spa_strfree(oldvdpath);
 	spa_strfree(newvdpath);
@@ -3747,19 +3744,11 @@
 		 * then log an internal history event.
 		 */
 		if (space_update) {
-			dmu_tx_t *tx;
-
-			tx = dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir);
-			if (dmu_tx_assign(tx, TXG_WAIT) == 0) {
-				spa_history_internal_log(LOG_POOL_VDEV_ONLINE,
-				    spa, tx, CRED(),
-				    "pool '%s' size: %llu(+%llu)",
-				    spa_name(spa), spa_get_space(spa),
-				    space_update);
-				dmu_tx_commit(tx);
-			} else {
-				dmu_tx_abort(tx);
-			}
+			spa_history_internal_log(LOG_POOL_VDEV_ONLINE,
+			    spa, NULL, CRED(),
+			    "pool '%s' size: %llu(+%llu)",
+			    spa_name(spa), spa_get_space(spa),
+			    space_update);
 		}
 	}