summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorOlaf Faaland <[email protected]>2018-08-20 10:05:23 -0700
committerTony Hutter <[email protected]>2018-11-08 14:38:28 -0800
commit9014da2b0163fc5f308f213754ad63d7801b5d81 (patch)
tree33da0a5ff3fb51e48d421c057fbf63adf96e67b9 /cmd
parent45579c951587c5856ea3db7e429be4866c4dfe85 (diff)
Skip import activity test in more zdb code paths
Since zdb opens the pools read-only, it cannot damage the pool in the event the pool is already imported either on the same host or on another one. If the pool vdev structure is changing while zdb is importing the pool, it may cause zdb to crash. However this is unlikely, and in any case it's a user space process and can simply be run again. For this reason, zdb should disable the multihost activity test on import that is normally run. This commit fixes a few zdb code paths where that had been overlooked. It also adds tests to ensure that several common use cases handle this properly in the future. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Gu Zheng <[email protected]> Signed-off-by: Olaf Faaland <[email protected]> Closes #7797 Closes #7801
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zdb/zdb.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index 17a0ae251..bb9fd3f18 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -24,7 +24,7 @@
* Copyright (c) 2011, 2016 by Delphix. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2016 Nexenta Systems, Inc.
- * Copyright (c) 2017 Lawrence Livermore National Security, LLC.
+ * Copyright (c) 2017, 2018 Lawrence Livermore National Security, LLC.
* Copyright (c) 2015, 2017, Intel Corporation.
*/
@@ -3660,6 +3660,22 @@ dump_simulated_ddt(spa_t *spa)
}
static void
+zdb_set_skip_mmp(char *target)
+{
+ spa_t *spa;
+
+ /*
+ * Disable the activity check to allow examination of
+ * active pools.
+ */
+ mutex_enter(&spa_namespace_lock);
+ if ((spa = spa_lookup(target)) != NULL) {
+ spa->spa_import_flags |= ZFS_IMPORT_SKIP_MMP;
+ }
+ mutex_exit(&spa_namespace_lock);
+}
+
+static void
dump_zpool(spa_t *spa)
{
dsl_pool_t *dp = spa_get_dsl(spa);
@@ -4412,14 +4428,15 @@ main(int argc, char **argv)
target, strerror(ENOMEM));
}
- /*
- * Disable the activity check to allow examination of
- * active pools.
- */
if (dump_opt['C'] > 1) {
(void) printf("\nConfiguration for import:\n");
dump_nvlist(cfg, 8);
}
+
+ /*
+ * Disable the activity check to allow examination of
+ * active pools.
+ */
error = spa_import(target_pool, cfg, NULL,
flags | ZFS_IMPORT_SKIP_MMP);
}
@@ -4430,16 +4447,7 @@ main(int argc, char **argv)
if (error == 0) {
if (target_is_spa || dump_opt['R']) {
- /*
- * Disable the activity check to allow examination of
- * active pools.
- */
- mutex_enter(&spa_namespace_lock);
- if ((spa = spa_lookup(target)) != NULL) {
- spa->spa_import_flags |= ZFS_IMPORT_SKIP_MMP;
- }
- mutex_exit(&spa_namespace_lock);
-
+ zdb_set_skip_mmp(target);
error = spa_open_rewind(target, &spa, FTAG, policy,
NULL);
if (error) {
@@ -4462,6 +4470,7 @@ main(int argc, char **argv)
}
}
} else {
+ zdb_set_skip_mmp(target);
error = open_objset(target, DMU_OST_ANY, FTAG, &os);
}
}