]> git.proxmox.com Git - mirror_zfs.git/blame - include/os/linux/zfs/sys/trace_arc.h
FreeBSD: Add zfs_link_create() error handling
[mirror_zfs.git] / include / os / linux / zfs / sys / trace_arc.h
CommitLineData
49ee64e5
NB
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1d3ba0bf 9 * or https://opensource.org/licenses/CDDL-1.0.
49ee64e5
NB
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22#include <sys/list.h>
23
cb709642
BL
24#if defined(_KERNEL)
25#if defined(HAVE_DECLARE_EVENT_CLASS)
49ee64e5
NB
26
27#undef TRACE_SYSTEM
28#define TRACE_SYSTEM zfs
29
c1718e95
FV
30#undef TRACE_SYSTEM_VAR
31#define TRACE_SYSTEM_VAR zfs_arc
32
49ee64e5
NB
33#if !defined(_TRACE_ARC_H) || defined(TRACE_HEADER_MULTI_READ)
34#define _TRACE_ARC_H
35
36#include <linux/tracepoint.h>
37#include <sys/types.h>
26ef0cc7 38#include <sys/trace_common.h> /* For ZIO macros */
49ee64e5
NB
39
40/*
41 * Generic support for one argument tracepoints of the form:
42 *
43 * DTRACE_PROBE1(...,
44 * arc_buf_hdr_t *, ...);
45 */
02730c33 46/* BEGIN CSTYLED */
49ee64e5
NB
47DECLARE_EVENT_CLASS(zfs_arc_buf_hdr_class,
48 TP_PROTO(arc_buf_hdr_t *ab),
49 TP_ARGS(ab),
50 TP_STRUCT__entry(
51 __array(uint64_t, hdr_dva_word, 2)
52 __field(uint64_t, hdr_birth)
49ee64e5 53 __field(uint32_t, hdr_flags)
49ee64e5 54 __field(arc_buf_contents_t, hdr_type)
d3c2ae1c
GW
55 __field(uint16_t, hdr_psize)
56 __field(uint16_t, hdr_lsize)
49ee64e5
NB
57 __field(uint64_t, hdr_spa)
58 __field(arc_state_type_t, hdr_state_type)
59 __field(clock_t, hdr_access)
60 __field(uint32_t, hdr_mru_hits)
61 __field(uint32_t, hdr_mru_ghost_hits)
62 __field(uint32_t, hdr_mfu_hits)
63 __field(uint32_t, hdr_mfu_ghost_hits)
64 __field(uint32_t, hdr_l2_hits)
65 __field(int64_t, hdr_refcount)
66 ),
67 TP_fast_assign(
68 __entry->hdr_dva_word[0] = ab->b_dva.dva_word[0];
69 __entry->hdr_dva_word[1] = ab->b_dva.dva_word[1];
70 __entry->hdr_birth = ab->b_birth;
49ee64e5 71 __entry->hdr_flags = ab->b_flags;
d3c2ae1c
GW
72 __entry->hdr_psize = ab->b_psize;
73 __entry->hdr_lsize = ab->b_lsize;
49ee64e5 74 __entry->hdr_spa = ab->b_spa;
b9541d6b
CW
75 __entry->hdr_state_type = ab->b_l1hdr.b_state->arcs_state;
76 __entry->hdr_access = ab->b_l1hdr.b_arc_access;
77 __entry->hdr_mru_hits = ab->b_l1hdr.b_mru_hits;
78 __entry->hdr_mru_ghost_hits = ab->b_l1hdr.b_mru_ghost_hits;
79 __entry->hdr_mfu_hits = ab->b_l1hdr.b_mfu_hits;
80 __entry->hdr_mfu_ghost_hits = ab->b_l1hdr.b_mfu_ghost_hits;
cfe8e960 81 __entry->hdr_l2_hits = ab->b_l2hdr.b_hits;
b9541d6b 82 __entry->hdr_refcount = ab->b_l1hdr.b_refcnt.rc_count;
49ee64e5 83 ),
b9541d6b 84 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
96b9cf42 85 "flags 0x%x type %u psize %u lsize %u spa %llu "
49ee64e5
NB
86 "state_type %u access %lu mru_hits %u mru_ghost_hits %u "
87 "mfu_hits %u mfu_ghost_hits %u l2_hits %u refcount %lli }",
88 __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
b9541d6b 89 __entry->hdr_birth, __entry->hdr_flags,
96b9cf42 90 __entry->hdr_type, __entry->hdr_psize,
d3c2ae1c 91 __entry->hdr_lsize, __entry->hdr_spa, __entry->hdr_state_type,
49ee64e5
NB
92 __entry->hdr_access, __entry->hdr_mru_hits,
93 __entry->hdr_mru_ghost_hits, __entry->hdr_mfu_hits,
94 __entry->hdr_mfu_ghost_hits, __entry->hdr_l2_hits,
95 __entry->hdr_refcount)
96);
02730c33 97/* END CSTYLED */
49ee64e5 98
e82dbae1 99#define DEFINE_ARC_BUF_HDR_EVENT(name) \
49ee64e5 100DEFINE_EVENT(zfs_arc_buf_hdr_class, name, \
7ada752a
AZ
101 TP_PROTO(arc_buf_hdr_t *ab), \
102 TP_ARGS(ab))
49ee64e5 103DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__hit);
c935fe2e 104DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__iohit);
49ee64e5
NB
105DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__evict);
106DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__delete);
107DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mru);
108DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__mfu);
ed2f7ba0 109DEFINE_ARC_BUF_HDR_EVENT(zfs_new_state__uncached);
a8b2e306 110DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__async__upgrade__sync);
49ee64e5
NB
111DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__hit);
112DEFINE_ARC_BUF_HDR_EVENT(zfs_l2arc__miss);
113
114/*
115 * Generic support for two argument tracepoints of the form:
116 *
117 * DTRACE_PROBE2(...,
118 * vdev_t *, ...,
119 * zio_t *, ...);
120 */
02730c33 121/* BEGIN CSTYLED */
49ee64e5
NB
122DECLARE_EVENT_CLASS(zfs_l2arc_rw_class,
123 TP_PROTO(vdev_t *vd, zio_t *zio),
124 TP_ARGS(vd, zio),
125 TP_STRUCT__entry(
126 __field(uint64_t, vdev_id)
127 __field(uint64_t, vdev_guid)
128 __field(uint64_t, vdev_state)
129 ZIO_TP_STRUCT_ENTRY
130 ),
131 TP_fast_assign(
132 __entry->vdev_id = vd->vdev_id;
133 __entry->vdev_guid = vd->vdev_guid;
134 __entry->vdev_state = vd->vdev_state;
135 ZIO_TP_FAST_ASSIGN
136 ),
137 TP_printk("vdev { id %llu guid %llu state %llu } "
138 ZIO_TP_PRINTK_FMT, __entry->vdev_id, __entry->vdev_guid,
139 __entry->vdev_state, ZIO_TP_PRINTK_ARGS)
140);
02730c33 141/* END CSTYLED */
49ee64e5 142
e82dbae1 143#define DEFINE_L2ARC_RW_EVENT(name) \
49ee64e5 144DEFINE_EVENT(zfs_l2arc_rw_class, name, \
7ada752a
AZ
145 TP_PROTO(vdev_t *vd, zio_t *zio), \
146 TP_ARGS(vd, zio))
49ee64e5
NB
147DEFINE_L2ARC_RW_EVENT(zfs_l2arc__read);
148DEFINE_L2ARC_RW_EVENT(zfs_l2arc__write);
149
150
151/*
152 * Generic support for two argument tracepoints of the form:
153 *
154 * DTRACE_PROBE2(...,
155 * zio_t *, ...,
156 * l2arc_write_callback_t *, ...);
157 */
02730c33 158/* BEGIN CSTYLED */
49ee64e5
NB
159DECLARE_EVENT_CLASS(zfs_l2arc_iodone_class,
160 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb),
161 TP_ARGS(zio, cb),
162 TP_STRUCT__entry(ZIO_TP_STRUCT_ENTRY),
163 TP_fast_assign(ZIO_TP_FAST_ASSIGN),
164 TP_printk(ZIO_TP_PRINTK_FMT, ZIO_TP_PRINTK_ARGS)
165);
02730c33 166/* END CSTYLED */
49ee64e5 167
e82dbae1 168#define DEFINE_L2ARC_IODONE_EVENT(name) \
49ee64e5 169DEFINE_EVENT(zfs_l2arc_iodone_class, name, \
7ada752a
AZ
170 TP_PROTO(zio_t *zio, l2arc_write_callback_t *cb), \
171 TP_ARGS(zio, cb))
49ee64e5
NB
172DEFINE_L2ARC_IODONE_EVENT(zfs_l2arc__iodone);
173
174
175/*
176 * Generic support for four argument tracepoints of the form:
177 *
178 * DTRACE_PROBE4(...,
179 * arc_buf_hdr_t *, ...,
180 * const blkptr_t *,
181 * uint64_t,
182 * const zbookmark_phys_t *);
183 */
02730c33 184/* BEGIN CSTYLED */
49ee64e5
NB
185DECLARE_EVENT_CLASS(zfs_arc_miss_class,
186 TP_PROTO(arc_buf_hdr_t *hdr,
187 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb),
188 TP_ARGS(hdr, bp, size, zb),
189 TP_STRUCT__entry(
190 __array(uint64_t, hdr_dva_word, 2)
191 __field(uint64_t, hdr_birth)
49ee64e5 192 __field(uint32_t, hdr_flags)
49ee64e5 193 __field(arc_buf_contents_t, hdr_type)
d3c2ae1c
GW
194 __field(uint16_t, hdr_psize)
195 __field(uint16_t, hdr_lsize)
49ee64e5
NB
196 __field(uint64_t, hdr_spa)
197 __field(arc_state_type_t, hdr_state_type)
198 __field(clock_t, hdr_access)
199 __field(uint32_t, hdr_mru_hits)
200 __field(uint32_t, hdr_mru_ghost_hits)
201 __field(uint32_t, hdr_mfu_hits)
202 __field(uint32_t, hdr_mfu_ghost_hits)
203 __field(uint32_t, hdr_l2_hits)
204 __field(int64_t, hdr_refcount)
205
206 __array(uint64_t, bp_dva0, 2)
207 __array(uint64_t, bp_dva1, 2)
208 __array(uint64_t, bp_dva2, 2)
209 __array(uint64_t, bp_cksum, 4)
210
211 __field(uint64_t, bp_lsize)
212
213 __field(uint64_t, zb_objset)
214 __field(uint64_t, zb_object)
215 __field(int64_t, zb_level)
216 __field(uint64_t, zb_blkid)
217 ),
218 TP_fast_assign(
219 __entry->hdr_dva_word[0] = hdr->b_dva.dva_word[0];
220 __entry->hdr_dva_word[1] = hdr->b_dva.dva_word[1];
221 __entry->hdr_birth = hdr->b_birth;
49ee64e5 222 __entry->hdr_flags = hdr->b_flags;
d3c2ae1c
GW
223 __entry->hdr_psize = hdr->b_psize;
224 __entry->hdr_lsize = hdr->b_lsize;
49ee64e5 225 __entry->hdr_spa = hdr->b_spa;
b9541d6b
CW
226 __entry->hdr_state_type = hdr->b_l1hdr.b_state->arcs_state;
227 __entry->hdr_access = hdr->b_l1hdr.b_arc_access;
228 __entry->hdr_mru_hits = hdr->b_l1hdr.b_mru_hits;
229 __entry->hdr_mru_ghost_hits = hdr->b_l1hdr.b_mru_ghost_hits;
230 __entry->hdr_mfu_hits = hdr->b_l1hdr.b_mfu_hits;
231 __entry->hdr_mfu_ghost_hits = hdr->b_l1hdr.b_mfu_ghost_hits;
cfe8e960 232 __entry->hdr_l2_hits = hdr->b_l2hdr.b_hits;
b9541d6b 233 __entry->hdr_refcount = hdr->b_l1hdr.b_refcnt.rc_count;
49ee64e5
NB
234
235 __entry->bp_dva0[0] = bp->blk_dva[0].dva_word[0];
236 __entry->bp_dva0[1] = bp->blk_dva[0].dva_word[1];
237 __entry->bp_dva1[0] = bp->blk_dva[1].dva_word[0];
238 __entry->bp_dva1[1] = bp->blk_dva[1].dva_word[1];
239 __entry->bp_dva2[0] = bp->blk_dva[2].dva_word[0];
240 __entry->bp_dva2[1] = bp->blk_dva[2].dva_word[1];
241 __entry->bp_cksum[0] = bp->blk_cksum.zc_word[0];
242 __entry->bp_cksum[1] = bp->blk_cksum.zc_word[1];
243 __entry->bp_cksum[2] = bp->blk_cksum.zc_word[2];
244 __entry->bp_cksum[3] = bp->blk_cksum.zc_word[3];
245
246 __entry->bp_lsize = size;
247
248 __entry->zb_objset = zb->zb_objset;
249 __entry->zb_object = zb->zb_object;
250 __entry->zb_level = zb->zb_level;
251 __entry->zb_blkid = zb->zb_blkid;
252 ),
b9541d6b 253 TP_printk("hdr { dva 0x%llx:0x%llx birth %llu "
96b9cf42 254 "flags 0x%x psize %u lsize %u spa %llu state_type %u "
49ee64e5
NB
255 "access %lu mru_hits %u mru_ghost_hits %u mfu_hits %u "
256 "mfu_ghost_hits %u l2_hits %u refcount %lli } "
257 "bp { dva0 0x%llx:0x%llx dva1 0x%llx:0x%llx dva2 "
258 "0x%llx:0x%llx cksum 0x%llx:0x%llx:0x%llx:0x%llx "
259 "lsize %llu } zb { objset %llu object %llu level %lli "
260 "blkid %llu }",
261 __entry->hdr_dva_word[0], __entry->hdr_dva_word[1],
b9541d6b 262 __entry->hdr_birth, __entry->hdr_flags,
96b9cf42 263 __entry->hdr_psize, __entry->hdr_lsize,
49ee64e5
NB
264 __entry->hdr_spa, __entry->hdr_state_type, __entry->hdr_access,
265 __entry->hdr_mru_hits, __entry->hdr_mru_ghost_hits,
266 __entry->hdr_mfu_hits, __entry->hdr_mfu_ghost_hits,
267 __entry->hdr_l2_hits, __entry->hdr_refcount,
268 __entry->bp_dva0[0], __entry->bp_dva0[1],
269 __entry->bp_dva1[0], __entry->bp_dva1[1],
270 __entry->bp_dva2[0], __entry->bp_dva2[1],
271 __entry->bp_cksum[0], __entry->bp_cksum[1],
272 __entry->bp_cksum[2], __entry->bp_cksum[3],
273 __entry->bp_lsize, __entry->zb_objset, __entry->zb_object,
274 __entry->zb_level, __entry->zb_blkid)
275);
02730c33 276/* END CSTYLED */
49ee64e5 277
e82dbae1 278#define DEFINE_ARC_MISS_EVENT(name) \
49ee64e5 279DEFINE_EVENT(zfs_arc_miss_class, name, \
7ada752a
AZ
280 TP_PROTO(arc_buf_hdr_t *hdr, \
281 const blkptr_t *bp, uint64_t size, const zbookmark_phys_t *zb), \
282 TP_ARGS(hdr, bp, size, zb))
49ee64e5
NB
283DEFINE_ARC_MISS_EVENT(zfs_arc__miss);
284
285/*
286 * Generic support for four argument tracepoints of the form:
287 *
288 * DTRACE_PROBE4(...,
289 * l2arc_dev_t *, ...,
290 * list_t *, ...,
291 * uint64_t, ...,
292 * boolean_t, ...);
293 */
02730c33 294/* BEGIN CSTYLED */
49ee64e5
NB
295DECLARE_EVENT_CLASS(zfs_l2arc_evict_class,
296 TP_PROTO(l2arc_dev_t *dev,
297 list_t *buflist, uint64_t taddr, boolean_t all),
298 TP_ARGS(dev, buflist, taddr, all),
299 TP_STRUCT__entry(
300 __field(uint64_t, vdev_id)
301 __field(uint64_t, vdev_guid)
302 __field(uint64_t, vdev_state)
303
304 __field(uint64_t, l2ad_hand)
305 __field(uint64_t, l2ad_start)
306 __field(uint64_t, l2ad_end)
49ee64e5
NB
307 __field(boolean_t, l2ad_first)
308 __field(boolean_t, l2ad_writing)
309
310 __field(uint64_t, taddr)
311 __field(boolean_t, all)
312 ),
313 TP_fast_assign(
314 __entry->vdev_id = dev->l2ad_vdev->vdev_id;
315 __entry->vdev_guid = dev->l2ad_vdev->vdev_guid;
316 __entry->vdev_state = dev->l2ad_vdev->vdev_state;
317
318 __entry->l2ad_hand = dev->l2ad_hand;
319 __entry->l2ad_start = dev->l2ad_start;
320 __entry->l2ad_end = dev->l2ad_end;
49ee64e5
NB
321 __entry->l2ad_first = dev->l2ad_first;
322 __entry->l2ad_writing = dev->l2ad_writing;
323
324 __entry->taddr = taddr;
325 __entry->all = all;
326 ),
327 TP_printk("l2ad { vdev { id %llu guid %llu state %llu } "
84045c2d 328 "hand %llu start %llu end %llu "
49ee64e5
NB
329 "first %d writing %d } taddr %llu all %d",
330 __entry->vdev_id, __entry->vdev_guid, __entry->vdev_state,
331 __entry->l2ad_hand, __entry->l2ad_start,
84045c2d 332 __entry->l2ad_end, __entry->l2ad_first, __entry->l2ad_writing,
49ee64e5
NB
333 __entry->taddr, __entry->all)
334);
02730c33 335/* END CSTYLED */
49ee64e5 336
e82dbae1 337#define DEFINE_L2ARC_EVICT_EVENT(name) \
49ee64e5 338DEFINE_EVENT(zfs_l2arc_evict_class, name, \
7ada752a
AZ
339 TP_PROTO(l2arc_dev_t *dev, list_t *buflist, uint64_t taddr, boolean_t all),\
340 TP_ARGS(dev, buflist, taddr, all))
49ee64e5
NB
341DEFINE_L2ARC_EVICT_EVENT(zfs_l2arc__evict);
342
3442c2a0
MA
343/*
344 * Generic support for three argument tracepoints of the form:
345 *
346 * DTRACE_PROBE3(...,
347 * uint64_t, ...,
348 * uint64_t, ...,
349 * uint64_t, ...);
350 */
351/* BEGIN CSTYLED */
352DECLARE_EVENT_CLASS(zfs_arc_wait_for_eviction_class,
353 TP_PROTO(uint64_t amount, uint64_t arc_evict_count, uint64_t aew_count),
354 TP_ARGS(amount, arc_evict_count, aew_count),
355 TP_STRUCT__entry(
356 __field(uint64_t, amount)
357 __field(uint64_t, arc_evict_count)
358 __field(uint64_t, aew_count)
359 ),
360 TP_fast_assign(
361 __entry->amount = amount;
362 __entry->arc_evict_count = arc_evict_count;
363 __entry->aew_count = aew_count;
364 ),
365 TP_printk("amount %llu arc_evict_count %llu aew_count %llu",
366 __entry->amount, __entry->arc_evict_count, __entry->aew_count)
367);
368/* END CSTYLED */
369
3442c2a0
MA
370#define DEFINE_ARC_WAIT_FOR_EVICTION_EVENT(name) \
371DEFINE_EVENT(zfs_arc_wait_for_eviction_class, name, \
7ada752a
AZ
372 TP_PROTO(uint64_t amount, uint64_t arc_evict_count, uint64_t aew_count), \
373 TP_ARGS(amount, arc_evict_count, aew_count))
3442c2a0
MA
374DEFINE_ARC_WAIT_FOR_EVICTION_EVENT(zfs_arc__wait__for__eviction);
375
49ee64e5
NB
376#endif /* _TRACE_ARC_H */
377
378#undef TRACE_INCLUDE_PATH
379#undef TRACE_INCLUDE_FILE
380#define TRACE_INCLUDE_PATH sys
381#define TRACE_INCLUDE_FILE trace_arc
382#include <trace/define_trace.h>
383
cb709642
BL
384#else
385
386DEFINE_DTRACE_PROBE1(arc__hit);
c935fe2e 387DEFINE_DTRACE_PROBE1(arc__iohit);
cb709642
BL
388DEFINE_DTRACE_PROBE1(arc__evict);
389DEFINE_DTRACE_PROBE1(arc__delete);
390DEFINE_DTRACE_PROBE1(new_state__mru);
391DEFINE_DTRACE_PROBE1(new_state__mfu);
ed2f7ba0 392DEFINE_DTRACE_PROBE1(new_state__uncached);
cb709642 393DEFINE_DTRACE_PROBE1(arc__async__upgrade__sync);
cb709642
BL
394DEFINE_DTRACE_PROBE1(l2arc__hit);
395DEFINE_DTRACE_PROBE1(l2arc__miss);
396DEFINE_DTRACE_PROBE2(l2arc__read);
397DEFINE_DTRACE_PROBE2(l2arc__write);
398DEFINE_DTRACE_PROBE2(l2arc__iodone);
3442c2a0 399DEFINE_DTRACE_PROBE3(arc__wait__for__eviction);
cb709642
BL
400DEFINE_DTRACE_PROBE4(arc__miss);
401DEFINE_DTRACE_PROBE4(l2arc__evict);
402
403#endif /* HAVE_DECLARE_EVENT_CLASS */
404#endif /* _KERNEL */