--- a/usr/src/uts/common/fs/zfs/spa.c Thu Apr 05 11:27:36 2007 -0700
+++ b/usr/src/uts/common/fs/zfs/spa.c Thu Apr 05 13:22:27 2007 -0700
@@ -57,6 +57,8 @@
#include <sys/dsl_synctask.h>
#include <sys/fs/zfs.h>
#include <sys/callb.h>
+#include <sys/systeminfo.h>
+#include <sys/sunddi.h>
int zio_taskq_threads = 8;
@@ -572,6 +574,7 @@
if (!mosconfig) {
nvlist_t *newconfig;
+ uint64_t hostid;
if (load_nvlist(spa, spa->spa_config_object, &newconfig) != 0) {
vdev_set_state(rvd, B_TRUE, VDEV_STATE_CANT_OPEN,
@@ -580,6 +583,27 @@
goto out;
}
+ if (nvlist_lookup_uint64(newconfig, ZPOOL_CONFIG_HOSTID,
+ &hostid) == 0) {
+ char *hostname;
+ unsigned long myhostid = 0;
+
+ VERIFY(nvlist_lookup_string(newconfig,
+ ZPOOL_CONFIG_HOSTNAME, &hostname) == 0);
+
+ (void) ddi_strtoul(hw_serial, NULL, 10, &myhostid);
+ if ((unsigned long)hostid != myhostid) {
+ cmn_err(CE_WARN, "pool '%s' could not be "
+ "loaded as it was last accessed by "
+ "another system (host: %s hostid: 0x%lx). "
+ "See: http://www.sun.com/msg/ZFS-8000-EY",
+ spa->spa_name, hostname,
+ (unsigned long)hostid);
+ error = EBADF;
+ goto out;
+ }
+ }
+
spa_config_set(spa, newconfig);
spa_unload(spa);
spa_deactivate(spa);
@@ -1359,6 +1383,8 @@
poolname) == 0);
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE,
state) == 0);
+ VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_TIMESTAMP,
+ spa->spa_uberblock.ub_timestamp) == 0);
/*
* Add the list of hot spares.