diff options
author | Matthew Ahrens <[email protected]> | 2013-03-08 10:41:28 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-10-31 14:58:04 -0700 |
commit | 2e528b49f8a0f8f2f51536a00fdf3ea9343bf302 (patch) | |
tree | 5c7c906ca4a8a6f52d6aafbf4eddefc8e872e42f /include/sys/zfs_context.h | |
parent | 7011fb6004b2227ff9e89894ed69ab83d36c1696 (diff) |
Illumos #3598
3598 want to dtrace when errors are generated in zfs
Reviewed by: Dan Kimmel <[email protected]>
Reviewed by: Adam Leventhal <[email protected]>
Reviewed by: Christopher Siden <[email protected]>
Approved by: Garrett D'Amore <[email protected]>
References:
https://www.illumos.org/issues/3598
illumos/illumos-gate@be6fd75a69ae679453d9cda5bff3326111e6d1ca
Ported-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #1775
Porting notes:
1. include/sys/zfs_context.h has been modified to render some new
macros inert until dtrace is available on Linux.
2. Linux-specific changes have been adapted to use SET_ERROR().
3. I'm NOT happy about this change. It does nothing but ugly
up the code under Linux. Unfortunately we need to take it to
avoid more merge conflicts in the future. -Brian
Diffstat (limited to 'include/sys/zfs_context.h')
-rw-r--r-- | include/sys/zfs_context.h | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 7910e08aa..dac74386d 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -59,6 +59,7 @@ #include <sys/time.h> #include <vm/seg_kmem.h> #include <sys/zone.h> +#include <sys/sdt.h> #include <sys/zfs_debug.h> #include <sys/fm/fs/zfs.h> #include <sys/sunddi.h> @@ -117,7 +118,7 @@ * Stack */ -#define noinline __attribute__((noinline)) +#define noinline __attribute__((noinline)) /* * Debugging @@ -149,6 +150,7 @@ extern void vpanic(const char *, __va_list); #define fm_panic panic +#ifdef __sun /* * DTrace SDT probes have different signatures in userland than they do in * kernel. If they're being used in kernel code, re-define them out of @@ -157,30 +159,47 @@ extern void vpanic(const char *, __va_list); #ifdef DTRACE_PROBE #undef DTRACE_PROBE -#define DTRACE_PROBE(a) ((void)0) #endif /* DTRACE_PROBE */ +#define DTRACE_PROBE(a) \ + ZFS_PROBE0(#a) #ifdef DTRACE_PROBE1 #undef DTRACE_PROBE1 -#define DTRACE_PROBE1(a, b, c) ((void)0) #endif /* DTRACE_PROBE1 */ +#define DTRACE_PROBE1(a, b, c) \ + ZFS_PROBE1(#a, (unsigned long)c) #ifdef DTRACE_PROBE2 #undef DTRACE_PROBE2 -#define DTRACE_PROBE2(a, b, c, d, e) ((void)0) #endif /* DTRACE_PROBE2 */ +#define DTRACE_PROBE2(a, b, c, d, e) \ + ZFS_PROBE2(#a, (unsigned long)c, (unsigned long)e) #ifdef DTRACE_PROBE3 #undef DTRACE_PROBE3 -#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void)0) #endif /* DTRACE_PROBE3 */ +#define DTRACE_PROBE3(a, b, c, d, e, f, g) \ + ZFS_PROBE3(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g) #ifdef DTRACE_PROBE4 #undef DTRACE_PROBE4 -#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void)0) #endif /* DTRACE_PROBE4 */ +#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) \ + ZFS_PROBE4(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g, \ + (unsigned long)i) /* + * We use the comma operator so that this macro can be used without much + * additional code. For example, "return (EINVAL);" becomes + * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated + * 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) (ZFS_SET_ERROR(err), err) +#else +#define SET_ERROR(err) (err) +#endif +/* * Threads */ #define TS_MAGIC 0x72f158ab4261e538ull @@ -214,9 +233,9 @@ typedef struct kthread { #define thread_exit zk_thread_exit #define thread_create(stk, stksize, func, arg, len, pp, state, pri) \ zk_thread_create(stk, stksize, (thread_func_t)func, arg, \ - len, NULL, state, pri, PTHREAD_CREATE_DETACHED) + len, NULL, state, pri, PTHREAD_CREATE_DETACHED) #define thread_join(t) zk_thread_join(t) -#define newproc(f,a,cid,pri,ctp,pid) (ENOSYS) +#define newproc(f, a, cid, pri, ctp, pid) (ENOSYS) extern kthread_t *zk_thread_current(void); extern void zk_thread_exit(void); @@ -247,7 +266,7 @@ typedef struct kmutex { } kmutex_t; #define MUTEX_DEFAULT 0 -#define MUTEX_HELD(m) ((m)->m_owner == curthread) +#define MUTEX_HELD(m) ((m)->m_owner == curthread) #define MUTEX_NOT_HELD(m) (!MUTEX_HELD(m)) extern void mutex_init(kmutex_t *mp, char *name, int type, void *cookie); @@ -277,7 +296,7 @@ typedef int krw_t; #define RW_READER 0 #define RW_WRITER 1 -#define RW_DEFAULT RW_READER +#define RW_DEFAULT RW_READER #define RW_READ_HELD(x) ((x)->rw_readers > 0) #define RW_WRITE_HELD(x) ((x)->rw_wr_owner == curthread) @@ -306,7 +325,7 @@ extern gid_t *crgetgroups(cred_t *cr); /* * Condition variables */ -#define CV_MAGIC 0xd31ea9a83b1b30c4ull +#define CV_MAGIC 0xd31ea9a83b1b30c4ull typedef struct kcondvar { uint64_t cv_magic; @@ -321,9 +340,9 @@ extern void cv_wait(kcondvar_t *cv, kmutex_t *mp); extern clock_t cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime); extern void cv_signal(kcondvar_t *cv); extern void cv_broadcast(kcondvar_t *cv); -#define cv_timedwait_interruptible(cv, mp, at) cv_timedwait(cv, mp, at) -#define cv_wait_interruptible(cv, mp) cv_wait(cv, mp) -#define cv_wait_io(cv, mp) cv_wait(cv, mp) +#define cv_timedwait_interruptible(cv, mp, at) cv_timedwait(cv, mp, at) +#define cv_wait_interruptible(cv, mp) cv_wait(cv, mp) +#define cv_wait_io(cv, mp) cv_wait(cv, mp) /* * Thread-specific data |