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
9  * or http://www.opensolaris.org/os/licensing.
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 #if defined(_KERNEL)
23 #if defined(HAVE_DECLARE_EVENT_CLASS)
24 
25 /*
26  * If tracepoints are available define dtrace_probe events for vdev
27  * related probes.  Definitions in include/os/linux/spl/sys/trace.h
28  * will map DTRACE_PROBE* calls to tracepoints.
29  */
30 
31 #undef TRACE_SYSTEM
32 #define	TRACE_SYSTEM zfs
33 
34 #undef TRACE_SYSTEM_VAR
35 #define	TRACE_SYSTEM_VAR zfs_vdev
36 
37 #if !defined(_TRACE_VDEV_H) || defined(TRACE_HEADER_MULTI_READ)
38 #define	_TRACE_VDEV_H
39 
40 #include <linux/tracepoint.h>
41 #include <sys/types.h>
42 
43 /*
44  * Generic support for three argument tracepoints of the form:
45  *
46  * DTRACE_PROBE3(...,
47  *     spa_t *, ...,
48  *     uint64_t, ...,
49  *     uint64_t, ...);
50  */
51 /* BEGIN CSTYLED */
52 DECLARE_EVENT_CLASS(zfs_removing_class_3,
53 	TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size),
54 	TP_ARGS(spa, offset, size),
55 	TP_STRUCT__entry(
56 	    __field(spa_t *,	vdev_spa)
57 	    __field(uint64_t,	vdev_offset)
58 	    __field(uint64_t,	vdev_size)
59 	),
60 	TP_fast_assign(
61 	    __entry->vdev_spa	= spa;
62 	    __entry->vdev_offset = offset;
63 	    __entry->vdev_size	= size;
64 	),
65 	TP_printk("spa %p offset %llu size %llu",
66 	    __entry->vdev_spa, __entry->vdev_offset,
67 	    __entry->vdev_size)
68 );
69 /* END CSTYLED */
70 
71 /* BEGIN CSTYLED */
72 #define DEFINE_REMOVE_FREE_EVENT(name) \
73 DEFINE_EVENT(zfs_removing_class_3, name, \
74 	TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size), \
75 	TP_ARGS(spa, offset, size))
76 /* END CSTYLED */
77 DEFINE_REMOVE_FREE_EVENT(zfs_remove__free__synced);
78 DEFINE_REMOVE_FREE_EVENT(zfs_remove__free__unvisited);
79 
80 /*
81  * Generic support for four argument tracepoints of the form:
82  *
83  * DTRACE_PROBE4(...,
84  *     spa_t *, ...,
85  *     uint64_t, ...,
86  *     uint64_t, ...,
87  *     uint64_t, ...);
88  */
89 /* BEGIN CSTYLED */
90 DECLARE_EVENT_CLASS(zfs_removing_class_4,
91 	TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size, uint64_t txg),
92 	TP_ARGS(spa, offset, size, txg),
93 	TP_STRUCT__entry(
94 	    __field(spa_t *,	vdev_spa)
95 	    __field(uint64_t,	vdev_offset)
96 	    __field(uint64_t,	vdev_size)
97 	    __field(uint64_t,	vdev_txg)
98 	),
99 	TP_fast_assign(
100 	    __entry->vdev_spa	= spa;
101 	    __entry->vdev_offset = offset;
102 	    __entry->vdev_size	= size;
103 	    __entry->vdev_txg	= txg;
104 	),
105 	TP_printk("spa %p offset %llu size %llu txg %llu",
106 	    __entry->vdev_spa, __entry->vdev_offset,
107 	    __entry->vdev_size, __entry->vdev_txg)
108 );
109 
110 /* BEGIN CSTYLED */
111 #define DEFINE_REMOVE_FREE_EVENT_TXG(name) \
112 DEFINE_EVENT(zfs_removing_class_4, name, \
113 	TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size,uint64_t txg), \
114 	TP_ARGS(spa, offset, size, txg))
115 /* END CSTYLED */
116 DEFINE_REMOVE_FREE_EVENT_TXG(zfs_remove__free__inflight);
117 
118 #endif /* _TRACE_VDEV_H */
119 
120 #undef TRACE_INCLUDE_PATH
121 #undef TRACE_INCLUDE_FILE
122 #define	TRACE_INCLUDE_PATH sys
123 #define	TRACE_INCLUDE_FILE trace_vdev
124 #include <trace/define_trace.h>
125 
126 #else
127 
128 /*
129  * When tracepoints are not available, a DEFINE_DTRACE_PROBE* macro is
130  * needed for each DTRACE_PROBE.  These will be used to generate stub
131  * tracing functions and prototypes for those functions.  See
132  * include/os/linux/spl/sys/trace.h.
133  */
134 
135 DEFINE_DTRACE_PROBE3(remove__free__synced);
136 DEFINE_DTRACE_PROBE3(remove__free__unvisited);
137 DEFINE_DTRACE_PROBE4(remove__free__inflight);
138 
139 #endif /* HAVE_DECLARE_EVENT_CLASS */
140 #endif /* _KERNEL */
141