aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_zil.h
blob: ae1caa3ac47342c0c927031c9763daf434173b35 (plain) (blame)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or https://opensource.org/licenses/CDDL-1.0.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

#if defined(_KERNEL)
#if defined(HAVE_DECLARE_EVENT_CLASS)

#undef TRACE_SYSTEM
#define	TRACE_SYSTEM zfs

#undef TRACE_SYSTEM_VAR
#define	TRACE_SYSTEM_VAR zfs_zil

#if !defined(_TRACE_ZIL_H) || defined(TRACE_HEADER_MULTI_READ)
#define	_TRACE_ZIL_H

#include <linux/tracepoint.h>
#include <sys/types.h>

#define	ZILOG_TP_STRUCT_ENTRY						    \
		__field(uint64_t,	zl_lr_seq)			    \
		__field(uint64_t,	zl_commit_lr_seq)		    \
		__field(uint64_t,	zl_destroy_txg)			    \
		__field(uint64_t,	zl_replaying_seq)		    \
		__field(uint32_t,	zl_suspend)			    \
		__field(uint8_t,	zl_suspending)			    \
		__field(uint8_t,	zl_keep_first)			    \
		__field(uint8_t,	zl_replay)			    \
		__field(uint8_t,	zl_stop_sync)			    \
		__field(uint8_t,	zl_logbias)			    \
		__field(uint8_t,	zl_sync)			    \
		__field(int,		zl_parse_error)			    \
		__field(uint64_t,	zl_parse_blk_seq)		    \
		__field(uint64_t,	zl_parse_lr_seq)		    \
		__field(uint64_t,	zl_parse_blk_count)		    \
		__field(uint64_t,	zl_parse_lr_count)		    \
		__field(uint64_t,	zl_cur_size)			    \
		__field(uint64_t,	zl_cur_left)			    \
		__field(uint64_t,	zl_cur_max)			    \
		__field(clock_t,	zl_replay_time)			    \
		__field(uint64_t,	zl_replay_blks)

#define	ZILOG_TP_FAST_ASSIGN						    \
		__entry->zl_lr_seq		= zilog->zl_lr_seq;	    \
		__entry->zl_commit_lr_seq	= zilog->zl_commit_lr_seq;  \
		__entry->zl_destroy_txg	= zilog->zl_destroy_txg;	    \
		__entry->zl_replaying_seq	= zilog->zl_replaying_seq;  \
		__entry->zl_suspend		= zilog->zl_suspend;	    \
		__entry->zl_suspending	= zilog->zl_suspending;		    \
		__entry->zl_keep_first	= zilog->zl_keep_first;		    \
		__entry->zl_replay		= zilog->zl_replay;	    \
		__entry->zl_stop_sync	= zilog->zl_stop_sync;		    \
		__entry->zl_logbias		= zilog->zl_logbias;	    \
		__entry->zl_sync		= zilog->zl_sync;	    \
		__entry->zl_parse_error	= zilog->zl_parse_error;	    \
		__entry->zl_parse_blk_seq	= zilog->zl_parse_blk_seq;  \
		__entry->zl_parse_lr_seq	= zilog->zl_parse_lr_seq;   \
		__entry->zl_parse_blk_count	= zilog->zl_parse_blk_count;\
		__entry->zl_parse_lr_count	= zilog->zl_parse_lr_count; \
		__entry->zl_cur_size	= zilog->zl_cur_size;		    \
		__entry->zl_cur_left	= zilog->zl_cur_left;		    \
		__entry->zl_cur_max	= zilog->zl_cur_max;		    \
		__entry->zl_replay_time	= zilog->zl_replay_time;	    \
		__entry->zl_replay_blks	= zilog->zl_replay_blks;

#define	ZILOG_TP_PRINTK_FMT						    \
	"zl { lr_seq %llu commit_lr_seq %llu destroy_txg %llu "		    \
	"replaying_seq %llu suspend %u suspending %u keep_first %u "	    \
	"replay %u stop_sync %u logbias %u sync %u "			    \
	"parse_error %u parse_blk_seq %llu parse_lr_seq %llu "		    \
	"parse_blk_count %llu parse_lr_count %llu "			    \
	"cur_size %llu cur_left %llu cur_max %llu replay_time %lu "	    \
	"replay_blks %llu }"

#define	ZILOG_TP_PRINTK_ARGS						    \
	    __entry->zl_lr_seq, __entry->zl_commit_lr_seq,		    \
	    __entry->zl_destroy_txg, __entry->zl_replaying_seq,		    \
	    __entry->zl_suspend, __entry->zl_suspending,		    \
	    __entry->zl_keep_first, __entry->zl_replay,			    \
	    __entry->zl_stop_sync, __entry->zl_logbias, __entry->zl_sync,   \
	    __entry->zl_parse_error, __entry->zl_parse_blk_seq,		    \
	    __entry->zl_parse_lr_seq, __entry->zl_parse_blk_count,	    \
	    __entry->zl_parse_lr_count, __entry->zl_cur_size,		    \
	    __entry->zl_cur_left, __entry->zl_cur_max,			    \
	    __entry->zl_replay_time, __entry->zl_replay_blks

#define	ITX_TP_STRUCT_ENTRY						    \
		__field(itx_wr_state_t,	itx_wr_state)			    \
		__field(uint8_t,	itx_sync)			    \
		__field(zil_callback_t,	itx_callback)			    \
		__field(void *,		itx_callback_data)		    \
		__field(uint64_t,	itx_oid)			    \
									    \
		__field(uint64_t,	lrc_txtype)			    \
		__field(uint64_t,	lrc_reclen)			    \
		__field(uint64_t,	lrc_txg)			    \
		__field(uint64_t,	lrc_seq)

#define	ITX_TP_FAST_ASSIGN						    \
		__entry->itx_wr_state		= itx->itx_wr_state;	    \
		__entry->itx_sync		= itx->itx_sync;	    \
		__entry->itx_callback		= itx->itx_callback;	    \
		__entry->itx_callback_data	= itx->itx_callback_data;   \
		__entry->itx_oid		= itx->itx_oid;		    \
									    \
		__entry->lrc_txtype		= itx->itx_lr.lrc_txtype;   \
		__entry->lrc_reclen		= itx->itx_lr.lrc_reclen;   \
		__entry->lrc_txg		= itx->itx_lr.lrc_txg;	    \
		__entry->lrc_seq		= itx->itx_lr.lrc_seq;

#define	ITX_TP_PRINTK_FMT						    \
	"itx { wr_state %u sync %u callback %p callback_data %p oid %llu"   \
	" { txtype %llu reclen %llu txg %llu seq %llu } }"

#define	ITX_TP_PRINTK_ARGS						    \
	    __entry->itx_wr_state, __entry->itx_sync, __entry->itx_callback,\
	    __entry->itx_callback_data, __entry->itx_oid,		    \
	    __entry->lrc_txtype, __entry->lrc_reclen, __entry->lrc_txg,	    \
	    __entry->lrc_seq

#define	ZCW_TP_STRUCT_ENTRY						    \
		__field(lwb_t *,	zcw_lwb)			    \
		__field(boolean_t,	zcw_done)			    \
		__field(int,		zcw_zio_error)			    \

#define	ZCW_TP_FAST_ASSIGN						    \
		__entry->zcw_lwb		= zcw->zcw_lwb;		    \
		__entry->zcw_done		= zcw->zcw_done;	    \
		__entry->zcw_zio_error		= zcw->zcw_zio_error;

#define	ZCW_TP_PRINTK_FMT						    \
	"zcw { lwb %p done %u error %u }"

#define	ZCW_TP_PRINTK_ARGS						    \
	    __entry->zcw_lwb, __entry->zcw_done, __entry->zcw_zio_error

/*
 * Generic support for two argument tracepoints of the form:
 *
 * DTRACE_PROBE2(...,
 *     zilog_t *, ...,
 *     itx_t *, ...);
 */

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wordered-compare-function-pointers"
#endif
/* BEGIN CSTYLED */
DECLARE_EVENT_CLASS(zfs_zil_process_itx_class,
	TP_PROTO(zilog_t *zilog, itx_t *itx),
	TP_ARGS(zilog, itx),
	TP_STRUCT__entry(
	    ZILOG_TP_STRUCT_ENTRY
	    ITX_TP_STRUCT_ENTRY
	),
	TP_fast_assign(
	    ZILOG_TP_FAST_ASSIGN
	    ITX_TP_FAST_ASSIGN
	),
	TP_printk(
	    ZILOG_TP_PRINTK_FMT " " ITX_TP_PRINTK_FMT,
	    ZILOG_TP_PRINTK_ARGS, ITX_TP_PRINTK_ARGS)
);
/* END CSTYLED */
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

#define	DEFINE_ZIL_PROCESS_ITX_EVENT(name) \
DEFINE_EVENT(zfs_zil_process_itx_class, name, \
    TP_PROTO(zilog_t *zilog, itx_t *itx), \
    TP_ARGS(zilog, itx))
DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__commit__itx);
DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__normal__itx);

/*
 * Generic support for two argument tracepoints of the form:
 *
 * DTRACE_PROBE2(...,
 *     zilog_t *, ...,
 *     zil_commit_waiter_t *, ...);
 */
/* BEGIN CSTYLED */
DECLARE_EVENT_CLASS(zfs_zil_commit_io_error_class,
	TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw),
	TP_ARGS(zilog, zcw),
	TP_STRUCT__entry(
	    ZILOG_TP_STRUCT_ENTRY
	    ZCW_TP_STRUCT_ENTRY
	),
	TP_fast_assign(
	    ZILOG_TP_FAST_ASSIGN
	    ZCW_TP_FAST_ASSIGN
	),
	TP_printk(
	    ZILOG_TP_PRINTK_FMT " " ZCW_TP_PRINTK_FMT,
	    ZILOG_TP_PRINTK_ARGS, ZCW_TP_PRINTK_ARGS)
);

#define	DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(name) \
DEFINE_EVENT(zfs_zil_commit_io_error_class, name, \
    TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw), \
    TP_ARGS(zilog, zcw))
DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(zfs_zil__commit__io__error);

/*
 * Generic support for three argument tracepoints of the form:
 *
 * DTRACE_PROBE3(...,
 *     zilog_t *, ...,
 *     uint64_t, ...,
 *     uint64_t, ...);
 */
/* BEGIN CSTYLED */
DECLARE_EVENT_CLASS(zfs_zil_block_size_class,
	TP_PROTO(zilog_t *zilog, uint64_t res, uint64_t s1),
	TP_ARGS(zilog, res, s1),
	TP_STRUCT__entry(
	    ZILOG_TP_STRUCT_ENTRY
	    __field(uint64_t, res)
	    __field(uint64_t, s1)
	),
	TP_fast_assign(
	    ZILOG_TP_FAST_ASSIGN
	    __entry->res = res;
	    __entry->s1 = s1;
	),
	TP_printk(
	    ZILOG_TP_PRINTK_FMT " res %llu s1 %llu",
	    ZILOG_TP_PRINTK_ARGS, __entry->res, __entry->s1)
);

#define	DEFINE_ZIL_BLOCK_SIZE_EVENT(name) \
DEFINE_EVENT(zfs_zil_block_size_class, name, \
    TP_PROTO(zilog_t *zilog, uint64_t res, uint64_t s1), \
    TP_ARGS(zilog, res, s1))
DEFINE_ZIL_BLOCK_SIZE_EVENT(zfs_zil__block__size);

#endif /* _TRACE_ZIL_H */

#undef TRACE_INCLUDE_PATH
#undef TRACE_INCLUDE_FILE
#define	TRACE_INCLUDE_PATH sys
#define	TRACE_INCLUDE_FILE trace_zil
#include <trace/define_trace.h>

#else

DEFINE_DTRACE_PROBE2(zil__process__commit__itx);
DEFINE_DTRACE_PROBE2(zil__process__normal__itx);
DEFINE_DTRACE_PROBE2(zil__commit__io__error);
DEFINE_DTRACE_PROBE3(zil__block__size);

#endif /* HAVE_DECLARE_EVENT_CLASS */
#endif /* _KERNEL */