1 Disable debug code on userspace
3 Index: zfs+chaos4/lib/libzfscommon/include/sys/arc.h
4 ===================================================================
5 --- zfs+chaos4.orig/lib/libzfscommon/include/sys/arc.h
6 +++ zfs+chaos4/lib/libzfscommon/include/sys/arc.h
7 @@ -82,7 +82,7 @@ int arc_released(arc_buf_t *buf);
8 int arc_has_callback(arc_buf_t *buf);
9 void arc_buf_freeze(arc_buf_t *buf);
10 void arc_buf_thaw(arc_buf_t *buf);
12 +#if defined(ZFS_DEBUG) || (!defined(_KERNEL) && !defined(NDEBUG))
13 int arc_referenced(arc_buf_t *buf);
16 Index: zfs+chaos4/lib/libzfscommon/include/sys/refcount.h
17 ===================================================================
18 --- zfs+chaos4.orig/lib/libzfscommon/include/sys/refcount.h
19 +++ zfs+chaos4/lib/libzfscommon/include/sys/refcount.h
20 @@ -43,7 +43,7 @@ extern "C" {
22 #define FTAG ((char *)__func__)
24 -#if defined(DEBUG) || !defined(_KERNEL)
26 typedef struct reference {
29 Index: zfs+chaos4/lib/libzfscommon/include/sys/zfs_context_user.h
30 ===================================================================
31 --- zfs+chaos4.orig/lib/libzfscommon/include/sys/zfs_context_user.h
32 +++ zfs+chaos4/lib/libzfscommon/include/sys/zfs_context_user.h
33 @@ -96,6 +96,8 @@ extern "C" {
36 extern void dprintf_setup(int *argc, char **argv);
38 +#define dprintf_setup(ac,av) ((void) 0)
39 #endif /* ZFS_DEBUG */
41 extern void cmn_err(int, const char *, ...);
42 @@ -105,21 +107,26 @@ extern void vpanic(const char *, __va_li
44 #define fm_panic panic
47 /* This definition is copied from assert.h. */
49 #if __STDC_VERSION__ - 0 >= 199901L
50 -#define verify(EX) (void)((EX) || \
51 +#define zp_verify(EX) (void)((EX) || \
52 (__assert_c99(#EX, __FILE__, __LINE__, __func__), 0))
54 -#define verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
55 +#define zp_verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
56 #endif /* __STDC_VERSION__ - 0 >= 199901L */
58 -#define verify(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
59 +#define zp_verify(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
64 -#define VERIFY verify
66 +#define VERIFY zp_verify
72 extern void __assert(const char *, const char *, int);
74 @@ -332,6 +339,7 @@ extern int taskq_member(taskq_t *, void
75 typedef struct vnode {
82 Index: zfs+chaos4/lib/libzfscommon/include/sys/zfs_debug.h
83 ===================================================================
84 --- zfs+chaos4.orig/lib/libzfscommon/include/sys/zfs_debug.h
85 +++ zfs+chaos4/lib/libzfscommon/include/sys/zfs_debug.h
86 @@ -44,7 +44,7 @@ extern "C" {
90 -#if defined(DEBUG) || !defined(_KERNEL)
95 Index: zfs+chaos4/lib/libzpool/arc.c
96 ===================================================================
97 --- zfs+chaos4.orig/lib/libzpool/arc.c
98 +++ zfs+chaos4/lib/libzpool/arc.c
99 @@ -1802,7 +1802,7 @@ arc_reclaim_needed(void)
104 +#elif defined(ZFS_DEBUG)
105 if (spa_get_random(100) == 0)
108 @@ -2881,7 +2881,7 @@ arc_has_callback(arc_buf_t *buf)
109 return (buf->b_efunc != NULL);
113 +#if defined(ZFS_DEBUG) || (!defined(_KERNEL) && !defined(NDEBUG))
115 arc_referenced(arc_buf_t *buf)
117 Index: zfs+chaos4/lib/libzpool/kernel.c
118 ===================================================================
119 --- zfs+chaos4.orig/lib/libzpool/kernel.c
120 +++ zfs+chaos4/lib/libzpool/kernel.c
121 @@ -384,6 +384,7 @@ vn_open(char *path, int x1, int flags, i
124 vp->v_size = st.st_size;
125 + vp->v_mode = st.st_mode;
126 vp->v_path = spa_strdup(path);
129 @@ -422,10 +423,17 @@ vn_rdwr(int uio, vnode_t *vp, void *addr
130 * To simulate partial disk writes, we split writes into two
131 * system calls so that the process can be killed in between.
133 - split = (len > 0 ? rand() % len : 0);
134 - iolen = pwrite64(vp->v_fd, addr, split, offset);
135 - iolen += pwrite64(vp->v_fd, (char *)addr + split,
136 - len - split, offset + split);
138 + if (!S_ISBLK(vp->v_mode) && !S_ISCHR(vp->v_mode)) {
139 + split = (len > 0 ? rand() % len : 0);
140 + iolen = pwrite64(vp->v_fd, addr, split, offset);
141 + iolen += pwrite64(vp->v_fd, (char *)addr + split,
142 + len - split, offset + split);
144 + iolen = pwrite64(vp->v_fd, addr, len, offset);
146 + iolen = pwrite64(vp->v_fd, addr, len, offset);
151 Index: zfs+chaos4/lib/libzpool/refcount.c
152 ===================================================================
153 --- zfs+chaos4.orig/lib/libzpool/refcount.c
154 +++ zfs+chaos4/lib/libzpool/refcount.c
156 #include <sys/zfs_context.h>
157 #include <sys/refcount.h>
159 -#if defined(DEBUG) || !defined(_KERNEL)
163 int reference_tracking_enable = FALSE; /* runs out of memory too easily */
164 Index: zfs+chaos4/lib/libzpool/spa_misc.c
165 ===================================================================
166 --- zfs+chaos4.orig/lib/libzpool/spa_misc.c
167 +++ zfs+chaos4/lib/libzpool/spa_misc.c
168 @@ -178,11 +178,15 @@ kmem_cache_t *spa_buffer_pool;
173 /* Everything except dprintf is on by default in debug builds */
174 int zfs_flags = ~ZFS_DEBUG_DPRINTF;
177 +#endif /* _KERNEL */
181 +#endif /* ZFS_DEBUG */
184 * zfs_recover can be set to nonzero to attempt to recover from