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 #define	DEFINE_REMOVE_FREE_EVENT(name) \
72 DEFINE_EVENT(zfs_removing_class_3, name, \
73     TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size), \
74     TP_ARGS(spa, offset, size))
75 DEFINE_REMOVE_FREE_EVENT(zfs_remove__free__synced);
76 DEFINE_REMOVE_FREE_EVENT(zfs_remove__free__unvisited);
77 
78 /*
79  * Generic support for four argument tracepoints of the form:
80  *
81  * DTRACE_PROBE4(...,
82  *     spa_t *, ...,
83  *     uint64_t, ...,
84  *     uint64_t, ...,
85  *     uint64_t, ...);
86  */
87 /* BEGIN CSTYLED */
88 DECLARE_EVENT_CLASS(zfs_removing_class_4,
89 	TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size, uint64_t txg),
90 	TP_ARGS(spa, offset, size, txg),
91 	TP_STRUCT__entry(
92 	    __field(spa_t *,	vdev_spa)
93 	    __field(uint64_t,	vdev_offset)
94 	    __field(uint64_t,	vdev_size)
95 	    __field(uint64_t,	vdev_txg)
96 	),
97 	TP_fast_assign(
98 	    __entry->vdev_spa	= spa;
99 	    __entry->vdev_offset = offset;
100 	    __entry->vdev_size	= size;
101 	    __entry->vdev_txg	= txg;
102 	),
103 	TP_printk("spa %p offset %llu size %llu txg %llu",
104 	    __entry->vdev_spa, __entry->vdev_offset,
105 	    __entry->vdev_size, __entry->vdev_txg)
106 );
107 
108 #define DEFINE_REMOVE_FREE_EVENT_TXG(name) \
109 DEFINE_EVENT(zfs_removing_class_4, name, \
110     TP_PROTO(spa_t *spa, uint64_t offset, uint64_t size,uint64_t txg), \
111     TP_ARGS(spa, offset, size, txg))
112 DEFINE_REMOVE_FREE_EVENT_TXG(zfs_remove__free__inflight);
113 
114 #endif /* _TRACE_VDEV_H */
115 
116 #undef TRACE_INCLUDE_PATH
117 #undef TRACE_INCLUDE_FILE
118 #define	TRACE_INCLUDE_PATH sys
119 #define	TRACE_INCLUDE_FILE trace_vdev
120 #include <trace/define_trace.h>
121 
122 #else
123 
124 /*
125  * When tracepoints are not available, a DEFINE_DTRACE_PROBE* macro is
126  * needed for each DTRACE_PROBE.  These will be used to generate stub
127  * tracing functions and prototypes for those functions.  See
128  * include/os/linux/spl/sys/trace.h.
129  */
130 
131 DEFINE_DTRACE_PROBE3(remove__free__synced);
132 DEFINE_DTRACE_PROBE3(remove__free__unvisited);
133 DEFINE_DTRACE_PROBE4(remove__free__inflight);
134 
135 #endif /* HAVE_DECLARE_EVENT_CLASS */
136 #endif /* _KERNEL */
137