summaryrefslogtreecommitdiffstats
path: root/patches/no-debug-userspace.patch
blob: 616a69153cb0109061b03c5b6f6cd1d90dc622a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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