mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-26 20:22:14 +03:00
Add dbgmsg kstat
Internally ZFS keeps a small log to facilitate debugging. By default the log is disabled, to enable it set zfs_dbgmsg_enable=1. The contents of the log can be accessed by reading the /proc/spl/kstat/zfs/dbgmsg file. Writing 0 to this proc file clears the log. $ echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable $ echo 0 >/proc/spl/kstat/zfs/dbgmsg $ zpool import tank $ cat /proc/spl/kstat/zfs/dbgmsg 1 0 0x01 -1 0 2492357525542 2525836565501 timestamp message 1441141408 spa=tank async request task=1 1441141408 txg 70 open pool version 5000; software version 5000/5; ... 1441141409 spa=tank async request task=32 1441141409 txg 72 import pool version 5000; software version 5000/5; ... 1441141414 command: lt-zpool import tank Note the zfs_dbgmsg() and dprintf() functions are both now mapped to the same log. As mentioned above the kernel debug log can be accessed though the /proc/spl/kstat/zfs/dbgmsg kstat. For user space consumers log messages are immediately written to stdout after applying the ZFS_DEBUG environment variable. $ ZFS_DEBUG=on ./cmd/ztest/ztest -V Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ned Bass <bass6@llnl.gov> Closes #3728
This commit is contained in:
@@ -247,55 +247,6 @@ static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
|
||||
int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t *);
|
||||
static int get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp);
|
||||
|
||||
#if defined(HAVE_DECLARE_EVENT_CLASS)
|
||||
void
|
||||
__dprintf(const char *file, const char *func, int line, const char *fmt, ...)
|
||||
{
|
||||
const char *newfile;
|
||||
size_t size = 4096;
|
||||
char *buf = kmem_alloc(size, KM_SLEEP);
|
||||
char *nl;
|
||||
va_list adx;
|
||||
|
||||
/*
|
||||
* Get rid of annoying prefix to filename.
|
||||
*/
|
||||
newfile = strrchr(file, '/');
|
||||
if (newfile != NULL) {
|
||||
newfile = newfile + 1; /* Get rid of leading / */
|
||||
} else {
|
||||
newfile = file;
|
||||
}
|
||||
|
||||
va_start(adx, fmt);
|
||||
(void) vsnprintf(buf, size, fmt, adx);
|
||||
va_end(adx);
|
||||
|
||||
/*
|
||||
* Get rid of trailing newline.
|
||||
*/
|
||||
nl = strrchr(buf, '\n');
|
||||
if (nl != NULL)
|
||||
*nl = '\0';
|
||||
|
||||
/*
|
||||
* To get this data enable the zfs__dprintf trace point as shown:
|
||||
*
|
||||
* # Enable zfs__dprintf tracepoint, clear the tracepoint ring buffer
|
||||
* $ echo 1 > /sys/module/zfs/parameters/zfs_flags
|
||||
* $ echo 1 > /sys/kernel/debug/tracing/events/zfs/enable
|
||||
* $ echo 0 > /sys/kernel/debug/tracing/trace
|
||||
*
|
||||
* # Dump the ring buffer.
|
||||
* $ cat /sys/kernel/debug/tracing/trace
|
||||
*/
|
||||
DTRACE_PROBE4(zfs__dprintf,
|
||||
char *, newfile, char *, func, int, line, char *, buf);
|
||||
|
||||
kmem_free(buf, size);
|
||||
}
|
||||
#endif /* HAVE_DECLARE_EVENT_CLASS */
|
||||
|
||||
static void
|
||||
history_str_free(char *buf)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user