/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2011 by Delphix. All rights reserved.
*/
#include <sys/spa.h>
* This can be overridden in userland to preserve an alternate namespace for
* userland pools when doing testing.
*/
-const char *spa_config_path = ZPOOL_CACHE;
+char *spa_config_path = ZPOOL_CACHE;
/*
* Called when the module is first loaded, this routine loads the configuration
/*
* Open the configuration file.
*/
- pathname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
+ pathname = kmem_alloc(MAXPATHLEN, KM_PUSHPAGE);
(void) snprintf(pathname, MAXPATHLEN, "%s%s",
(rootdir != NULL) ? "./" : "", spa_config_path);
if (kobj_get_filesize(file, &fsize) != 0)
goto out;
- buf = kmem_alloc(fsize, KM_SLEEP);
+ buf = kmem_alloc(fsize, KM_PUSHPAGE | KM_NODEBUG);
/*
* Read the nvlist from the file.
/*
* Unpack the nvlist.
*/
- if (nvlist_unpack(buf, fsize, &nvlist, KM_SLEEP) != 0)
+ if (nvlist_unpack(buf, fsize, &nvlist, KM_PUSHPAGE) != 0)
goto out;
/*
*/
VERIFY(nvlist_size(nvl, &buflen, NV_ENCODE_XDR) == 0);
- buf = kmem_alloc(buflen, KM_SLEEP);
- temp = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
+ buf = kmem_alloc(buflen, KM_PUSHPAGE | KM_NODEBUG);
+ temp = kmem_zalloc(MAXPATHLEN, KM_PUSHPAGE);
VERIFY(nvlist_pack(nvl, &buf, &buflen, NV_ENCODE_XDR,
- KM_SLEEP) == 0);
+ KM_PUSHPAGE) == 0);
/*
* Write the configuration to disk. We need to do the traditional
(void) vn_rename(temp, dp->scd_path, UIO_SYSSPACE);
}
(void) VOP_CLOSE(vp, oflags, 1, 0, kcred, NULL);
- VN_RELE(vp);
}
(void) vn_remove(temp, UIO_SYSSPACE, RMFILE);
if (nvl == NULL)
VERIFY(nvlist_alloc(&nvl, NV_UNIQUE_NAME,
- KM_SLEEP) == 0);
+ KM_PUSHPAGE) == 0);
VERIFY(nvlist_add_nvlist(nvl, spa->spa_name,
spa->spa_config) == 0);
spa_config_generation++;
if (postsysevent)
- spa_event_notify(target, NULL, ESC_ZFS_CONFIG_SYNC);
+ spa_event_notify(target, NULL, FM_EREPORT_ZFS_CONFIG_SYNC);
}
/*
if (*generation == spa_config_generation)
return (NULL);
- VERIFY(nvlist_alloc(&pools, NV_UNIQUE_NAME, KM_SLEEP) == 0);
+ VERIFY(nvlist_alloc(&pools, NV_UNIQUE_NAME, KM_PUSHPAGE) == 0);
mutex_enter(&spa_namespace_lock);
while ((spa = spa_next(spa)) != NULL) {
mutex_exit(&spa->spa_props_lock);
}
-/* Add discovered rewind info, if any to the provided nvlist */
-void
-spa_rewind_data_to_nvlist(spa_t *spa, nvlist_t *tonvl)
-{
- int64_t loss = 0;
-
- if (tonvl == NULL || spa->spa_load_txg == 0)
- return;
-
- VERIFY(nvlist_add_uint64(tonvl, ZPOOL_CONFIG_LOAD_TIME,
- spa->spa_load_txg_ts) == 0);
- if (spa->spa_last_ubsync_txg)
- loss = spa->spa_last_ubsync_txg_ts - spa->spa_load_txg_ts;
- VERIFY(nvlist_add_int64(tonvl, ZPOOL_CONFIG_REWIND_TIME, loss) == 0);
- VERIFY(nvlist_add_uint64(tonvl, ZPOOL_CONFIG_LOAD_DATA_ERRORS,
- spa->spa_load_data_errors) == 0);
-}
-
/*
* Generate the pool's configuration based on the current in-core state.
* We infer whether to generate a complete config or just one top-level config
if (txg == -1ULL)
txg = spa->spa_config_txg;
- VERIFY(nvlist_alloc(&config, NV_UNIQUE_NAME, KM_SLEEP) == 0);
+ VERIFY(nvlist_alloc(&config, NV_UNIQUE_NAME, KM_PUSHPAGE) == 0);
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_VERSION,
spa_version(spa)) == 0);
txg) == 0);
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID,
spa_guid(spa)) == 0);
+ VERIFY(spa->spa_comment == NULL || nvlist_add_string(config,
+ ZPOOL_CONFIG_COMMENT, spa->spa_comment) == 0);
+
+
#ifdef _KERNEL
hostid = zone_get_hostid(NULL);
#else /* _KERNEL */
/*
* Add the top-level config. We even add this on pools which
- * don't support holes in the namespace as older pools will
- * just ignore it.
+ * don't support holes in the namespace.
*/
vdev_top_config_generate(spa, config);
ddt_stat_t *dds;
ddt_object_t *ddo;
- ddh = kmem_zalloc(sizeof (ddt_histogram_t), KM_SLEEP);
+ ddh = kmem_zalloc(sizeof (ddt_histogram_t), KM_PUSHPAGE);
ddt_get_dedup_histogram(spa, ddh);
VERIFY(nvlist_add_uint64_array(config,
ZPOOL_CONFIG_DDT_HISTOGRAM,
(uint64_t *)ddh, sizeof (*ddh) / sizeof (uint64_t)) == 0);
kmem_free(ddh, sizeof (ddt_histogram_t));
- ddo = kmem_zalloc(sizeof (ddt_object_t), KM_SLEEP);
+ ddo = kmem_zalloc(sizeof (ddt_object_t), KM_PUSHPAGE);
ddt_get_dedup_object_stats(spa, ddo);
VERIFY(nvlist_add_uint64_array(config,
ZPOOL_CONFIG_DDT_OBJ_STATS,
(uint64_t *)ddo, sizeof (*ddo) / sizeof (uint64_t)) == 0);
kmem_free(ddo, sizeof (ddt_object_t));
- dds = kmem_zalloc(sizeof (ddt_stat_t), KM_SLEEP);
+ dds = kmem_zalloc(sizeof (ddt_stat_t), KM_PUSHPAGE);
ddt_get_dedup_stats(spa, dds);
VERIFY(nvlist_add_uint64_array(config,
ZPOOL_CONFIG_DDT_STATS,
kmem_free(dds, sizeof (ddt_stat_t));
}
- spa_rewind_data_to_nvlist(spa, config);
-
if (locked)
spa_config_exit(spa, SCL_CONFIG | SCL_STATE, FTAG);
if (what == SPA_CONFIG_UPDATE_POOL)
spa_config_update(spa, SPA_CONFIG_UPDATE_VDEVS);
}
+
+#if defined(_KERNEL) && defined(HAVE_SPL)
+EXPORT_SYMBOL(spa_config_sync);
+EXPORT_SYMBOL(spa_config_load);
+EXPORT_SYMBOL(spa_all_configs);
+EXPORT_SYMBOL(spa_config_set);
+EXPORT_SYMBOL(spa_config_generate);
+EXPORT_SYMBOL(spa_config_update);
+
+module_param(spa_config_path, charp, 0444);
+MODULE_PARM_DESC(spa_config_path, "SPA config file (/etc/zfs/zpool.cache)");
+#endif