aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorPavel Zakharov <[email protected]>2017-02-10 17:51:09 -0500
committerBrian Behlendorf <[email protected]>2018-06-04 14:54:20 -0700
commit8a393be353c3bfffbfbe0f4d2bc57210b658dcde (patch)
tree11a6990472970d151bed08414b7d86feb173777b /module
parent85912983a4ff12eab20b170c15eb26f7761b8be2 (diff)
OpenZFS 9235 - rename zpool_rewind_policy_t to zpool_load_policy_t
We want to be able to pass various settings during import/open of a pool, which are not only related to rewind. Instead of adding a new policy and duplicate a bunch of code, we should just rename rewind_policy to a more generic term like load_policy. For instance, we'd like to set spa->spa_import_flags from the nvlist, rather from a flags parameter passed to spa_import as in some cases we want those flags not only for the import case, but also for the open case. One such flag could be ZFS_IMPORT_MISSING_LOG (as used in zdb) which would allow zfs to open a pool when logs are missing. Authored by: Pavel Zakharov <[email protected]> Reviewed by: Matt Ahrens <[email protected]> Reviewed by: George Wilson <[email protected]> Approved by: Robert Mustacchi <[email protected]> Ported-by: Brian Behlendorf <[email protected]> OpenZFS-issue: https://illumos.org/issues/9235 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/d2b1e44 Closes #7532
Diffstat (limited to 'module')
-rw-r--r--module/zcommon/zfs_comutil.c42
-rw-r--r--module/zfs/spa.c54
2 files changed, 47 insertions, 49 deletions
diff --git a/module/zcommon/zfs_comutil.c b/module/zcommon/zfs_comutil.c
index b31e0ab27..1f74095cc 100644
--- a/module/zcommon/zfs_comutil.c
+++ b/module/zcommon/zfs_comutil.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
*/
/*
@@ -65,17 +65,17 @@ zfs_allocatable_devs(nvlist_t *nv)
}
void
-zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
+zpool_get_load_policy(nvlist_t *nvl, zpool_load_policy_t *zlpp)
{
nvlist_t *policy;
nvpair_t *elem;
char *nm;
/* Defaults */
- zrpp->zrp_request = ZPOOL_NO_REWIND;
- zrpp->zrp_maxmeta = 0;
- zrpp->zrp_maxdata = UINT64_MAX;
- zrpp->zrp_txg = UINT64_MAX;
+ zlpp->zlp_rewind = ZPOOL_NO_REWIND;
+ zlpp->zlp_maxmeta = 0;
+ zlpp->zlp_maxdata = UINT64_MAX;
+ zlpp->zlp_txg = UINT64_MAX;
if (nvl == NULL)
return;
@@ -83,24 +83,24 @@ zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
elem = NULL;
while ((elem = nvlist_next_nvpair(nvl, elem)) != NULL) {
nm = nvpair_name(elem);
- if (strcmp(nm, ZPOOL_REWIND_POLICY) == 0) {
+ if (strcmp(nm, ZPOOL_LOAD_POLICY) == 0) {
if (nvpair_value_nvlist(elem, &policy) == 0)
- zpool_get_rewind_policy(policy, zrpp);
+ zpool_get_load_policy(policy, zlpp);
return;
- } else if (strcmp(nm, ZPOOL_REWIND_REQUEST) == 0) {
- if (nvpair_value_uint32(elem, &zrpp->zrp_request) == 0)
- if (zrpp->zrp_request & ~ZPOOL_REWIND_POLICIES)
- zrpp->zrp_request = ZPOOL_NO_REWIND;
- } else if (strcmp(nm, ZPOOL_REWIND_REQUEST_TXG) == 0) {
- (void) nvpair_value_uint64(elem, &zrpp->zrp_txg);
- } else if (strcmp(nm, ZPOOL_REWIND_META_THRESH) == 0) {
- (void) nvpair_value_uint64(elem, &zrpp->zrp_maxmeta);
- } else if (strcmp(nm, ZPOOL_REWIND_DATA_THRESH) == 0) {
- (void) nvpair_value_uint64(elem, &zrpp->zrp_maxdata);
+ } else if (strcmp(nm, ZPOOL_LOAD_REWIND_POLICY) == 0) {
+ if (nvpair_value_uint32(elem, &zlpp->zlp_rewind) == 0)
+ if (zlpp->zlp_rewind & ~ZPOOL_REWIND_POLICIES)
+ zlpp->zlp_rewind = ZPOOL_NO_REWIND;
+ } else if (strcmp(nm, ZPOOL_LOAD_REQUEST_TXG) == 0) {
+ (void) nvpair_value_uint64(elem, &zlpp->zlp_txg);
+ } else if (strcmp(nm, ZPOOL_LOAD_META_THRESH) == 0) {
+ (void) nvpair_value_uint64(elem, &zlpp->zlp_maxmeta);
+ } else if (strcmp(nm, ZPOOL_LOAD_DATA_THRESH) == 0) {
+ (void) nvpair_value_uint64(elem, &zlpp->zlp_maxdata);
}
}
- if (zrpp->zrp_request == 0)
- zrpp->zrp_request = ZPOOL_NO_REWIND;
+ if (zlpp->zlp_rewind == 0)
+ zlpp->zlp_rewind = ZPOOL_NO_REWIND;
}
typedef struct zfs_version_spa_map {
@@ -206,7 +206,7 @@ const char *zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS] = {
#if defined(_KERNEL)
EXPORT_SYMBOL(zfs_allocatable_devs);
-EXPORT_SYMBOL(zpool_get_rewind_policy);
+EXPORT_SYMBOL(zpool_get_load_policy);
EXPORT_SYMBOL(zfs_zpl_version_map);
EXPORT_SYMBOL(zfs_spa_version_map);
EXPORT_SYMBOL(zfs_history_event_names);
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 50862adcd..45cb6eb00 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -2093,13 +2093,13 @@ spa_load_verify(spa_t *spa)
{
zio_t *rio;
spa_load_error_t sle = { 0 };
- zpool_rewind_policy_t policy;
+ zpool_load_policy_t policy;
boolean_t verify_ok = B_FALSE;
int error = 0;
- zpool_get_rewind_policy(spa->spa_config, &policy);
+ zpool_get_load_policy(spa->spa_config, &policy);
- if (policy.zrp_request & ZPOOL_NEVER_REWIND)
+ if (policy.zlp_rewind & ZPOOL_NEVER_REWIND)
return (0);
dsl_pool_config_enter(spa->spa_dsl_pool, FTAG);
@@ -2138,8 +2138,8 @@ spa_load_verify(spa_t *spa)
}
if (spa_load_verify_dryrun ||
- (!error && sle.sle_meta_count <= policy.zrp_maxmeta &&
- sle.sle_data_count <= policy.zrp_maxdata)) {
+ (!error && sle.sle_meta_count <= policy.zlp_maxmeta &&
+ sle.sle_data_count <= policy.zlp_maxdata)) {
int64_t loss = 0;
verify_ok = B_TRUE;
@@ -3020,17 +3020,17 @@ spa_ld_load_trusted_config(spa_t *spa, spa_import_type_t type,
/*
* We will use spa_config if we decide to reload the spa or if spa_load
* fails and we rewind. We must thus regenerate the config using the
- * MOS information with the updated paths. Rewind policy is an import
- * setting and is not in the MOS. We copy it over to our new, trusted
- * config.
+ * MOS information with the updated paths. ZPOOL_LOAD_POLICY is used to
+ * pass settings on how to load the pool and is not stored in the MOS.
+ * We copy it over to our new, trusted config.
*/
mos_config_txg = fnvlist_lookup_uint64(mos_config,
ZPOOL_CONFIG_POOL_TXG);
nvlist_free(mos_config);
mos_config = spa_config_generate(spa, NULL, mos_config_txg, B_FALSE);
- if (nvlist_lookup_nvlist(spa->spa_config, ZPOOL_REWIND_POLICY,
+ if (nvlist_lookup_nvlist(spa->spa_config, ZPOOL_LOAD_POLICY,
&policy) == 0)
- fnvlist_add_nvlist(mos_config, ZPOOL_REWIND_POLICY, policy);
+ fnvlist_add_nvlist(mos_config, ZPOOL_LOAD_POLICY, policy);
spa_config_set(spa, mos_config);
spa->spa_config_source = SPA_CONFIG_SRC_MOS;
@@ -4082,13 +4082,13 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
}
if (spa->spa_state == POOL_STATE_UNINITIALIZED) {
- zpool_rewind_policy_t policy;
+ zpool_load_policy_t policy;
firstopen = B_TRUE;
- zpool_get_rewind_policy(nvpolicy ? nvpolicy : spa->spa_config,
+ zpool_get_load_policy(nvpolicy ? nvpolicy : spa->spa_config,
&policy);
- if (policy.zrp_request & ZPOOL_DO_REWIND)
+ if (policy.zlp_rewind & ZPOOL_DO_REWIND)
state = SPA_LOAD_RECOVER;
spa_activate(spa, spa_mode_global);
@@ -4098,8 +4098,8 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy,
spa->spa_config_source = SPA_CONFIG_SRC_CACHEFILE;
zfs_dbgmsg("spa_open_common: opening %s", pool);
- error = spa_load_best(spa, state, policy.zrp_txg,
- policy.zrp_request);
+ error = spa_load_best(spa, state, policy.zlp_txg,
+ policy.zlp_rewind);
if (error == EBADF) {
/*
@@ -4960,7 +4960,7 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
spa_t *spa;
char *altroot = NULL;
spa_load_state_t state = SPA_LOAD_IMPORT;
- zpool_rewind_policy_t policy;
+ zpool_load_policy_t policy;
uint64_t mode = spa_mode_global;
uint64_t readonly = B_FALSE;
int error;
@@ -5011,8 +5011,8 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
*/
spa_async_suspend(spa);
- zpool_get_rewind_policy(config, &policy);
- if (policy.zrp_request & ZPOOL_DO_REWIND)
+ zpool_get_load_policy(config, &policy);
+ if (policy.zlp_rewind & ZPOOL_DO_REWIND)
state = SPA_LOAD_RECOVER;
spa->spa_config_source = SPA_CONFIG_SRC_TRYIMPORT;
@@ -5022,9 +5022,9 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
zfs_dbgmsg("spa_import: importing %s", pool);
} else {
zfs_dbgmsg("spa_import: importing %s, max_txg=%lld "
- "(RECOVERY MODE)", pool, (longlong_t)policy.zrp_txg);
+ "(RECOVERY MODE)", pool, (longlong_t)policy.zlp_txg);
}
- error = spa_load_best(spa, state, policy.zrp_txg, policy.zrp_request);
+ error = spa_load_best(spa, state, policy.zlp_txg, policy.zlp_rewind);
/*
* Propagate anything learned while loading the pool and pass it
@@ -5142,7 +5142,7 @@ spa_tryimport(nvlist_t *tryconfig)
spa_t *spa;
uint64_t state;
int error;
- zpool_rewind_policy_t policy;
+ zpool_load_policy_t policy;
if (nvlist_lookup_string(tryconfig, ZPOOL_CONFIG_POOL_NAME, &poolname))
return (NULL);
@@ -5158,16 +5158,14 @@ spa_tryimport(nvlist_t *tryconfig)
spa_activate(spa, FREAD);
/*
- * Rewind pool if a max txg was provided. Note that even though we
- * retrieve the complete rewind policy, only the rewind txg is relevant
- * for tryimport.
+ * Rewind pool if a max txg was provided.
*/
- zpool_get_rewind_policy(spa->spa_config, &policy);
- if (policy.zrp_txg != UINT64_MAX) {
- spa->spa_load_max_txg = policy.zrp_txg;
+ zpool_get_load_policy(spa->spa_config, &policy);
+ if (policy.zlp_txg != UINT64_MAX) {
+ spa->spa_load_max_txg = policy.zlp_txg;
spa->spa_extreme_rewind = B_TRUE;
zfs_dbgmsg("spa_tryimport: importing %s, max_txg=%lld",
- poolname, (longlong_t)policy.zrp_txg);
+ poolname, (longlong_t)policy.zlp_txg);
} else {
zfs_dbgmsg("spa_tryimport: importing %s", poolname);
}