summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2016-10-14 07:28:43 +0000
committermav <mav@FreeBSD.org>2016-10-14 07:28:43 +0000
commit21556701ea35bd542f1a869dced7e295fde0f1d9 (patch)
tree39f38b5eb3e506e0ba82b8995fdda0bffac11889 /cddl
parentc7df998ee09fb6b939ff6ab674f7d8610b9b6405 (diff)
downloadFreeBSD-src-21556701ea35bd542f1a869dced7e295fde0f1d9.zip
FreeBSD-src-21556701ea35bd542f1a869dced7e295fde0f1d9.tar.gz
MFC r305332: MFV r304159: 7277 zdb should be able to print zfs_dbgmsg's
illumos/illumos-gate@29bdd2f916366ece37c4748bca6b3d61f57a223b https://github.com/illumos/illumos-gate/commit/29bdd2f916366ece37c4748bca6b3d61f 57a223b https://www.illumos.org/issues/7277 ztest always prints the debug messages (zfs_dbgmsg()) by calling zfs_dbgmsg_print(). We should add a flag to zdb to make it do this as well before exiting. Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com> Approved by: Dan McDonald <danmcd@omniti.com> Author: Pavel Zakharov <pavel.zakharov@delphix.com>
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/cmd/zdb/zdb.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
index 1ae92c0..d44fe37 100644
--- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c
+++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
*/
@@ -117,7 +117,7 @@ static void
usage(void)
{
(void) fprintf(stderr,
- "Usage: %s [-CumMdibcsDvhLXFPA] [-t txg] [-e [-p path...]] "
+ "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] "
"[-U config] [-I inflight I/Os] [-x dumpdir] poolname [object...]\n"
" %s [-divPA] [-e -p path...] [-U config] dataset "
"[object...]\n"
@@ -178,12 +178,23 @@ usage(void)
(void) fprintf(stderr, " -I <number of inflight I/Os> -- "
"specify the maximum number of "
"checksumming I/Os [default is 200]\n");
+ (void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before "
+ "exiting\n");
(void) fprintf(stderr, "Specify an option more than once (e.g. -bb) "
"to make only that option verbose\n");
(void) fprintf(stderr, "Default is to dump everything non-verbosely\n");
exit(1);
}
+static void
+dump_debug_buffer()
+{
+ if (dump_opt['G']) {
+ (void) printf("\n");
+ zfs_dbgmsg_print("zdb");
+ }
+}
+
/*
* Called for usage errors that are discovered after a call to spa_open(),
* dmu_bonus_hold(), or pool_match(). abort() is called for other errors.
@@ -200,6 +211,8 @@ fatal(const char *fmt, ...)
va_end(ap);
(void) fprintf(stderr, "\n");
+ dump_debug_buffer();
+
exit(1);
}
@@ -3103,8 +3116,10 @@ dump_zpool(spa_t *spa)
if (dump_opt['h'])
dump_history(spa);
- if (rc != 0)
+ if (rc != 0) {
+ dump_debug_buffer();
exit(rc);
+ }
}
#define ZDB_FLAG_CHECKSUM 0x0001
@@ -3575,7 +3590,7 @@ main(int argc, char **argv)
spa_config_path = spa_config_path_env;
while ((c = getopt(argc, argv,
- "bcdhilmMI:suCDRSAFLXx:evp:t:U:P")) != -1) {
+ "bcdhilmMI:suCDRSAFLXx:evp:t:U:PG")) != -1) {
switch (c) {
case 'b':
case 'c':
@@ -3591,6 +3606,7 @@ main(int argc, char **argv)
case 'M':
case 'R':
case 'S':
+ case 'G':
dump_opt[c]++;
dump_all = 0;
break;
@@ -3826,6 +3842,8 @@ main(int argc, char **argv)
fuid_table_destroy();
sa_loaded = B_FALSE;
+ dump_debug_buffer();
+
libzfs_fini(g_zfs);
kernel_fini();
OpenPOWER on IntegriCloud