]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/spa.c
Illumos #2882, #2883, #2900
[mirror_zfs.git] / module / zfs / spa.c
index 65f78b7846af4932f3f44808ed30c318aa8866fa..7c37ca426d4a67fbaf468a60393c2b7734cf0f63 100644 (file)
@@ -731,8 +731,8 @@ spa_change_guid_sync(void *arg1, void *arg2, dmu_tx_t *tx)
        vdev_config_dirty(rvd);
        spa_config_exit(spa, SCL_STATE, FTAG);
 
-       spa_history_log_internal(LOG_POOL_GUID_CHANGE, spa, tx,
-           "old=%lld new=%lld", oldguid, *newguid);
+       spa_history_log_internal(spa, "guid change", tx, "old=%llu new=%llu",
+           oldguid, *newguid);
 }
 
 /*
@@ -2715,6 +2715,12 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
                    vdev_resilver_needed(rvd, NULL, NULL))
                        spa_async_request(spa, SPA_ASYNC_RESILVER);
 
+               /*
+                * Log the fact that we booted up (so that we can detect if
+                * we rebooted in the middle of an operation).
+                */
+               spa_history_log_version(spa, "open");
+
                /*
                 * Delete any inconsistent datasets.
                 */
@@ -3399,7 +3405,7 @@ spa_l2cache_drop(spa_t *spa)
  */
 int
 spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
-    const char *history_str, nvlist_t *zplprops)
+    nvlist_t *zplprops)
 {
        spa_t *spa;
        char *altroot = NULL;
@@ -3620,9 +3626,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
 
        spa_config_sync(spa, B_FALSE, B_TRUE);
 
-       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_history_log_version(spa, "create");
 
        spa->spa_minref = refcount_count(&spa->spa_refcount);
 
@@ -3824,7 +3828,6 @@ spa_import_rootpool(char *devpath, char *devid)
        }
 
        error = 0;
-       spa_history_log_version(spa, LOG_POOL_IMPORT);
 out:
        spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
        vdev_free(rvd);
@@ -3886,7 +3889,7 @@ spa_import(const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
                spa_config_sync(spa, B_FALSE, B_TRUE);
 
                mutex_exit(&spa_namespace_lock);
-               spa_history_log_version(spa, LOG_POOL_IMPORT);
+               spa_history_log_version(spa, "import");
 
                return (0);
        }
@@ -4017,7 +4020,7 @@ spa_import(const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
        spa_async_request(spa, SPA_ASYNC_AUTOEXPAND);
 
        mutex_exit(&spa_namespace_lock);
-       spa_history_log_version(spa, LOG_POOL_IMPORT);
+       spa_history_log_version(spa, "import");
 
 #ifdef _KERNEL
        zvol_create_minors(pool);
@@ -4560,7 +4563,7 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing)
         */
        (void) spa_vdev_exit(spa, newrootvd, dtl_max_txg, 0);
 
-       spa_history_log_internal(LOG_POOL_VDEV_ATTACH, spa, NULL,
+       spa_history_log_internal(spa, "vdev attach", NULL,
            "%s vdev=%s %s vdev=%s",
            replacing && newvd_isspare ? "spare in" :
            replacing ? "replace" : "attach", newvdpath,
@@ -4778,7 +4781,7 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done)
 
        error = spa_vdev_exit(spa, vd, txg, 0);
 
-       spa_history_log_internal(LOG_POOL_VDEV_DETACH, spa, NULL,
+       spa_history_log_internal(spa, "detach", NULL,
            "vdev=%s", vdpath);
        spa_strfree(vdpath);
 
@@ -5047,9 +5050,8 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
                if (vml[c] != NULL) {
                        vdev_split(vml[c]);
                        if (error == 0)
-                               spa_history_log_internal(LOG_POOL_VDEV_DETACH,
-                                   spa, tx, "vdev=%s",
-                                   vml[c]->vdev_path);
+                               spa_history_log_internal(spa, "detach", tx,
+                                   "vdev=%s", vml[c]->vdev_path);
                        vdev_free(vml[c]);
                }
        }
@@ -5064,8 +5066,8 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
                zio_handle_panic_injection(spa, FTAG, 3);
 
        /* split is complete; log a history record */
-       spa_history_log_internal(LOG_POOL_SPLIT, newspa, NULL,
-           "split new pool %s from pool %s", newname, spa_name(spa));
+       spa_history_log_internal(newspa, "split", NULL,
+           "from pool %s", spa_name(spa));
 
        kmem_free(vml, children * sizeof (vdev_t *));
 
@@ -5647,8 +5649,7 @@ spa_async_thread(spa_t *spa)
                 * then log an internal history event.
                 */
                if (new_space != old_space) {
-                       spa_history_log_internal(LOG_POOL_VDEV_ONLINE,
-                           spa, NULL,
+                       spa_history_log_internal(spa, "vdev online", NULL,
                            "pool '%s' size: %llu(+%llu)",
                            spa_name(spa), new_space, new_space - old_space);
                }
@@ -5892,6 +5893,7 @@ spa_sync_version(void *arg1, void *arg2, dmu_tx_t *tx)
 
        spa->spa_uberblock.ub_version = version;
        vdev_config_dirty(spa->spa_root_vdev);
+       spa_history_log_internal(spa, "set", tx, "version=%lld", version);
 }
 
 /*
@@ -5927,6 +5929,8 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
                        VERIFY3U(0, ==, zfeature_lookup_name(fname, &feature));
 
                        spa_feature_enable(spa, feature, tx);
+                       spa_history_log_internal(spa, "set", tx,
+                           "%s=enabled", nvpair_name(elem));
                        break;
 
                case ZPOOL_PROP_VERSION:
@@ -5966,6 +5970,8 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
                         */
                        if (tx->tx_txg != TXG_INITIAL)
                                vdev_config_dirty(spa->spa_root_vdev);
+                       spa_history_log_internal(spa, "set", tx,
+                           "%s=%s", nvpair_name(elem), strval);
                        break;
                default:
                        /*
@@ -5988,7 +5994,8 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
                                VERIFY(zap_update(mos,
                                    spa->spa_pool_props_object, propname,
                                    1, strlen(strval) + 1, strval, tx) == 0);
-
+                               spa_history_log_internal(spa, "set", tx,
+                                   "%s=%s", nvpair_name(elem), strval);
                        } else if (nvpair_type(elem) == DATA_TYPE_UINT64) {
                                VERIFY(nvpair_value_uint64(elem, &intval) == 0);
 
@@ -6000,6 +6007,8 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
                                VERIFY(zap_update(mos,
                                    spa->spa_pool_props_object, propname,
                                    8, 1, &intval, tx) == 0);
+                               spa_history_log_internal(spa, "set", tx,
+                                   "%s=%lld", nvpair_name(elem), intval);
                        } else {
                                ASSERT(0); /* not allowed */
                        }
@@ -6028,13 +6037,6 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
                        }
                }
 
-               /* log internal history if this is not a zpool create */
-               if (spa_version(spa) >= SPA_VERSION_ZPOOL_HISTORY &&
-                   tx->tx_txg != TXG_INITIAL) {
-                       spa_history_log_internal(LOG_POOL_PROPSET,
-                           spa, tx, "%s %lld %s",
-                           nvpair_name(elem), intval, spa_name(spa));
-               }
        }
 
        mutex_exit(&spa->spa_props_lock);