zdb -k does not work on Linux when used with -e

This minor bug was introduced with the port of the feature from
OpenZFS to ZoL. This patch fixes the issue that was caused by
a minor re-ordering from the original code.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tim Chase <tim@chase2k.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #8001
This commit is contained in:
Serapheim Dimitropoulos
2018-10-30 09:46:18 -07:00
committed by Brian Behlendorf
parent 63a77ae3cf
commit 0a544c174d
3 changed files with 50 additions and 16 deletions
+18 -11
View File
@@ -6057,17 +6057,6 @@ main(int argc, char **argv)
error = 0;
target = argv[0];
char *checkpoint_pool = NULL;
char *checkpoint_target = NULL;
if (dump_opt['k']) {
checkpoint_pool = import_checkpointed_state(target, cfg,
&checkpoint_target);
if (checkpoint_target != NULL)
target = checkpoint_target;
}
if (strpbrk(target, "/@") != NULL) {
size_t targetlen;
@@ -6113,6 +6102,24 @@ main(int argc, char **argv)
}
}
/*
* import_checkpointed_state makes the assumption that the
* target pool that we pass it is already part of the spa
* namespace. Because of that we need to make sure to call
* it always after the -e option has been processed, which
* imports the pool to the namespace if it's not in the
* cachefile.
*/
char *checkpoint_pool = NULL;
char *checkpoint_target = NULL;
if (dump_opt['k']) {
checkpoint_pool = import_checkpointed_state(target, cfg,
&checkpoint_target);
if (checkpoint_target != NULL)
target = checkpoint_target;
}
if (target_pool != target)
free(target_pool);