aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zdb/zdb.c
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2014-06-08 14:10:14 -0400
committerBrian Behlendorf <[email protected]>2014-07-17 11:40:32 -0700
commita5778ea2427bd340e3b4f697d9b6e1452bd71909 (patch)
treec5270bdee99a5a45b8acad9407cc8cdfb96076a0 /cmd/zdb/zdb.c
parent2fbc542ebdee773ab45fd0d35029d6978aa5900b (diff)
zdb: Introduce -V for verbatim import
When given a pool name via -e, zdb would attempt an import. If it failed, then it would attempt a verbatim import. This behavior is not always desirable so a -V switch is added to zdb to control the behavior. When specified, a verbatim import is done. Otherwise, the behavior is as it was previously, except no verbatim import is done on failure. Signed-off-by: Richard Yao <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #2372
Diffstat (limited to 'cmd/zdb/zdb.c')
-rw-r--r--cmd/zdb/zdb.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index d815d2044..3c69a696d 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -3227,8 +3227,10 @@ main(int argc, char **argv)
char *target;
nvlist_t *policy = NULL;
uint64_t max_txg = UINT64_MAX;
+ int flags = ZFS_IMPORT_MISSING_LOG;
int rewind = ZPOOL_NEVER_REWIND;
char *spa_config_path_env;
+ const char *opts = "bcdhilmM:suCDRSAFLVXevp:t:U:P";
(void) setrlimit(RLIMIT_NOFILE, &rl);
(void) enable_extended_FILE_stdio(-1, -1);
@@ -3244,7 +3246,7 @@ main(int argc, char **argv)
if (spa_config_path_env != NULL)
spa_config_path = spa_config_path_env;
- while ((c = getopt(argc, argv, "bcdhilmM:suCDRSAFLXevp:t:U:P")) != -1) {
+ while ((c = getopt(argc, argv, opts)) != -1) {
switch (c) {
case 'b':
case 'c':
@@ -3270,6 +3272,9 @@ main(int argc, char **argv)
case 'P':
dump_opt[c]++;
break;
+ case 'V':
+ flags = ZFS_IMPORT_VERBATIM;
+ break;
case 'v':
verbose++;
break;
@@ -3381,11 +3386,7 @@ main(int argc, char **argv)
fatal("can't open '%s': %s",
target, strerror(ENOMEM));
}
- if ((error = spa_import(name, cfg, NULL,
- ZFS_IMPORT_MISSING_LOG)) != 0) {
- error = spa_import(name, cfg, NULL,
- ZFS_IMPORT_VERBATIM);
- }
+ error = spa_import(name, cfg, NULL, flags);
}
}