]> git.proxmox.com Git - mirror_zfs.git/commit
Fix dbgmsg printing in ztest and zdb
authorTom Caputi <tcaputi@datto.com>
Mon, 15 Oct 2018 19:14:22 +0000 (15:14 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 24 Oct 2018 21:36:50 +0000 (14:36 -0700)
commitab4c009e3d0cf794bbe84aff3b9ac203eaed03c7
tree1c80fc0bd955e7b5acc9d8f375559e21fd3314bd
parentc04812f964a2a79ec501fb1ba995ef333ff79172
Fix dbgmsg printing in ztest and zdb

This patch resolves a problem where the -G option in both zdb and
ztest would cause the code to call __dprintf() to print zfs_dbgmsg
output. This function was not properly wired to add messages to the
dbgmsg log as it is in userspace and so the messages were simply
dropped. This patch also tries to add some degree of distinction to
dprintf() (which now prints directly to stdout) and zfs_dbgmsg()
(which adds messages to an internal list that can be dumped with
zfs_dbgmsg_print()).

In addition, this patch corrects an issue where ztest used a global
variable to decide whether to dump the dbgmsg buffer on a crash.
This did not work because ztest spins up more instances of itself
using execv(), which did not copy the global variable to the new
process. The option has been moved to the ztest_shared_opts_t
which already exists for interprocess communication.

This patch also changes zfs_dbgmsg_print() to use write() calls
instead of printf() so that it will not fail when used in a signal
handler.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #8010
cmd/zdb/zdb.c
cmd/ztest/ztest.c
include/sys/zfs_debug.h
lib/libzpool/kernel.c
module/zfs/zfs_debug.c