summaryrefslogtreecommitdiffstats
path: root/include/sys/sdt.h
diff options
context:
space:
mode:
authorNed Bass <[email protected]>2017-07-25 23:09:48 -0700
committerBrian Behlendorf <[email protected]>2017-07-25 23:09:48 -0700
commit8740cf4a2f5f7ff7fb6c214e0baf06356b2870b8 (patch)
treeb653cfe22dfd57e65f29206a0b73563811893414 /include/sys/sdt.h
parent9ff13dbe921c7177faee3f10c832e88bded39920 (diff)
Add line info and SET_ERROR() to ZFS debug log
Redefine the SET_ERROR macro in terms of __dprintf() so the error return codes get logged as both tracepoint events (if tracepoints are enabled) and as ZFS debug log entries. This also allows us to use the same definition of SET_ERROR() in kernel and user space. Define a new debug flag ZFS_DEBUG_SET_ERROR=512 that may be bitwise or'd into zfs_flags. Setting this flag enables both dprintf() and SET_ERROR() messages in the debug log. That is, setting ZFS_DEBUG_SET_ERROR and ZFS_DEBUG_DPRINTF|ZFS_DEBUG_SET_ERROR are equivalent (this was done for sake of simplicity). Leaving ZFS_DEBUG_SET_ERROR unset suppresses the SET_ERROR() messages which helps avoid cluttering up the logs. To enable SET_ERROR() logging, run: echo 1 > /sys/module/zfs/parameters/zfs_dbgmsg_enable echo 512 > /sys/module/zfs/parameters/zfs_flags Remove the zfs_set_error_class tracepoints event class since SET_ERROR() now uses __dprintf(). This sacrifices a bit of granularity when selecting individual tracepoint events to enable but it makes the code simpler. Include file, function, and line number information in debug log entries. The information is now added to the message buffer in __dprintf() and as a result the zfs_dprintf_class tracepoints event class was changed from a 4 parameter interface to a single parameter. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ned Bass <[email protected]> Closes #6400
Diffstat (limited to 'include/sys/sdt.h')
-rw-r--r--include/sys/sdt.h20
1 files changed, 4 insertions, 16 deletions
diff --git a/include/sys/sdt.h b/include/sys/sdt.h
index 56efa1b39..9704072cb 100644
--- a/include/sys/sdt.h
+++ b/include/sys/sdt.h
@@ -34,13 +34,8 @@
#define ZFS_PROBE2(a, c, e) ((void) 0)
#define ZFS_PROBE3(a, c, e, g) ((void) 0)
#define ZFS_PROBE4(a, c, e, g, i) ((void) 0)
-#define ZFS_SET_ERROR(err) ((void) 0)
-#else
-
-#if defined(HAVE_DECLARE_EVENT_CLASS)
-
-#include <sys/trace.h>
+#endif /* _KERNEL */
/*
* The set-error SDT probe is extra static, in that we declare its fake
@@ -55,16 +50,9 @@
* twice, so it should not have side effects (e.g. something like:
* "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice).
*/
-#define SET_ERROR(err) \
- (trace_zfs_set__error(__FILE__, __func__, __LINE__, err), err)
-
-#else
-
+extern void __set_error(const char *file, const char *func, int line, int err);
#undef SET_ERROR
-#define SET_ERROR(err) (err)
-
-#endif /* HAVE_DECLARE_EVENT_CLASS */
-
-#endif /* _KERNEL */
+#define SET_ERROR(err) \
+ (__set_error(__FILE__, __func__, __LINE__, err), err)
#endif /* _SYS_SDT_H */