aboutsummaryrefslogtreecommitdiffstats
path: root/patches/no-debug-userspace.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/no-debug-userspace.patch')
-rw-r--r--patches/no-debug-userspace.patch184
1 files changed, 184 insertions, 0 deletions
diff --git a/patches/no-debug-userspace.patch b/patches/no-debug-userspace.patch
new file mode 100644
index 000000000..616a69153
--- /dev/null
+++ b/patches/no-debug-userspace.patch
@@ -0,0 +1,184 @@
+Disable debug code on userspace
+
+Index: zfs+chaos4/lib/libzfscommon/include/sys/arc.h
+===================================================================
+--- zfs+chaos4.orig/lib/libzfscommon/include/sys/arc.h
++++ zfs+chaos4/lib/libzfscommon/include/sys/arc.h
+@@ -82,7 +82,7 @@ int arc_released(arc_buf_t *buf);
+ int arc_has_callback(arc_buf_t *buf);
+ void arc_buf_freeze(arc_buf_t *buf);
+ void arc_buf_thaw(arc_buf_t *buf);
+-#ifdef ZFS_DEBUG
++#if defined(ZFS_DEBUG) || (!defined(_KERNEL) && !defined(NDEBUG))
+ int arc_referenced(arc_buf_t *buf);
+ #endif
+
+Index: zfs+chaos4/lib/libzfscommon/include/sys/refcount.h
+===================================================================
+--- zfs+chaos4.orig/lib/libzfscommon/include/sys/refcount.h
++++ zfs+chaos4/lib/libzfscommon/include/sys/refcount.h
+@@ -43,7 +43,7 @@ extern "C" {
+ */
+ #define FTAG ((char *)__func__)
+
+-#if defined(DEBUG) || !defined(_KERNEL)
++#if defined(DEBUG)
+ typedef struct reference {
+ list_node_t ref_link;
+ void *ref_holder;
+Index: zfs+chaos4/lib/libzfscommon/include/sys/zfs_context_user.h
+===================================================================
+--- zfs+chaos4.orig/lib/libzfscommon/include/sys/zfs_context_user.h
++++ zfs+chaos4/lib/libzfscommon/include/sys/zfs_context_user.h
+@@ -96,6 +96,8 @@ extern "C" {
+
+ #ifdef ZFS_DEBUG
+ extern void dprintf_setup(int *argc, char **argv);
++#else
++#define dprintf_setup(ac,av) ((void) 0)
+ #endif /* ZFS_DEBUG */
+
+ extern void cmn_err(int, const char *, ...);
+@@ -105,21 +107,26 @@ extern void vpanic(const char *, __va_li
+
+ #define fm_panic panic
+
++#ifndef zp_verify
+ /* This definition is copied from assert.h. */
+ #if defined(__STDC__)
+ #if __STDC_VERSION__ - 0 >= 199901L
+-#define verify(EX) (void)((EX) || \
++#define zp_verify(EX) (void)((EX) || \
+ (__assert_c99(#EX, __FILE__, __LINE__, __func__), 0))
+ #else
+-#define verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
++#define zp_verify(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
+ #endif /* __STDC_VERSION__ - 0 >= 199901L */
+ #else
+-#define verify(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
++#define zp_verify(EX) (void)((EX) || (_assert("EX", __FILE__, __LINE__), 0))
+ #endif /* __STDC__ */
++#endif
+
+-
+-#define VERIFY verify
++#ifndef VERIFY
++#define VERIFY zp_verify
++#endif
++#ifndef ASSERT
+ #define ASSERT assert
++#endif
+
+ extern void __assert(const char *, const char *, int);
+
+@@ -332,6 +339,7 @@ extern int taskq_member(taskq_t *, void
+ typedef struct vnode {
+ uint64_t v_size;
+ int v_fd;
++ mode_t v_mode;
+ char *v_path;
+ } vnode_t;
+
+Index: zfs+chaos4/lib/libzfscommon/include/sys/zfs_debug.h
+===================================================================
+--- zfs+chaos4.orig/lib/libzfscommon/include/sys/zfs_debug.h
++++ zfs+chaos4/lib/libzfscommon/include/sys/zfs_debug.h
+@@ -44,7 +44,7 @@ extern "C" {
+ * ZFS debugging
+ */
+
+-#if defined(DEBUG) || !defined(_KERNEL)
++#if defined(DEBUG)
+ #define ZFS_DEBUG
+ #endif
+
+Index: zfs+chaos4/lib/libzpool/arc.c
+===================================================================
+--- zfs+chaos4.orig/lib/libzpool/arc.c
++++ zfs+chaos4/lib/libzpool/arc.c
+@@ -1802,7 +1802,7 @@ arc_reclaim_needed(void)
+ return (1);
+ #endif
+
+-#else
++#elif defined(ZFS_DEBUG)
+ if (spa_get_random(100) == 0)
+ return (1);
+ #endif
+@@ -2881,7 +2881,7 @@ arc_has_callback(arc_buf_t *buf)
+ return (buf->b_efunc != NULL);
+ }
+
+-#ifdef ZFS_DEBUG
++#if defined(ZFS_DEBUG) || (!defined(_KERNEL) && !defined(NDEBUG))
+ int
+ arc_referenced(arc_buf_t *buf)
+ {
+Index: zfs+chaos4/lib/libzpool/kernel.c
+===================================================================
+--- zfs+chaos4.orig/lib/libzpool/kernel.c
++++ zfs+chaos4/lib/libzpool/kernel.c
+@@ -384,6 +384,7 @@ vn_open(char *path, int x1, int flags, i
+
+ vp->v_fd = fd;
+ vp->v_size = st.st_size;
++ vp->v_mode = st.st_mode;
+ vp->v_path = spa_strdup(path);
+
+ return (0);
+@@ -422,10 +423,17 @@ vn_rdwr(int uio, vnode_t *vp, void *addr
+ * To simulate partial disk writes, we split writes into two
+ * system calls so that the process can be killed in between.
+ */
+- split = (len > 0 ? rand() % len : 0);
+- iolen = pwrite64(vp->v_fd, addr, split, offset);
+- iolen += pwrite64(vp->v_fd, (char *)addr + split,
+- len - split, offset + split);
++#ifdef ZFS_DEBUG
++ if (!S_ISBLK(vp->v_mode) && !S_ISCHR(vp->v_mode)) {
++ split = (len > 0 ? rand() % len : 0);
++ iolen = pwrite64(vp->v_fd, addr, split, offset);
++ iolen += pwrite64(vp->v_fd, (char *)addr + split,
++ len - split, offset + split);
++ } else
++ iolen = pwrite64(vp->v_fd, addr, len, offset);
++#else
++ iolen = pwrite64(vp->v_fd, addr, len, offset);
++#endif
+ }
+
+ if (iolen < 0)
+Index: zfs+chaos4/lib/libzpool/refcount.c
+===================================================================
+--- zfs+chaos4.orig/lib/libzpool/refcount.c
++++ zfs+chaos4/lib/libzpool/refcount.c
+@@ -28,7 +28,7 @@
+ #include <sys/zfs_context.h>
+ #include <sys/refcount.h>
+
+-#if defined(DEBUG) || !defined(_KERNEL)
++#if defined(DEBUG)
+
+ #ifdef _KERNEL
+ int reference_tracking_enable = FALSE; /* runs out of memory too easily */
+Index: zfs+chaos4/lib/libzpool/spa_misc.c
+===================================================================
+--- zfs+chaos4.orig/lib/libzpool/spa_misc.c
++++ zfs+chaos4/lib/libzpool/spa_misc.c
+@@ -178,11 +178,15 @@ kmem_cache_t *spa_buffer_pool;
+ int spa_mode;
+
+ #ifdef ZFS_DEBUG
++#ifdef _KERNEL
+ /* Everything except dprintf is on by default in debug builds */
+ int zfs_flags = ~ZFS_DEBUG_DPRINTF;
+ #else
++int zfs_flags = ~0;
++#endif /* _KERNEL */
++#else
+ int zfs_flags = 0;
+-#endif
++#endif /* ZFS_DEBUG */
+
+ /*
+ * zfs_recover can be set to nonzero to attempt to recover from