]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/os/linux/zfs/sys/trace_dbuf.h
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / include / os / linux / zfs / sys / trace_dbuf.h
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 #undef TRACE_SYSTEM
26 #define TRACE_SYSTEM zfs
27
28 #undef TRACE_SYSTEM_VAR
29 #define TRACE_SYSTEM_VAR zfs_dbuf
30
31 #if !defined(_TRACE_DBUF_H) || defined(TRACE_HEADER_MULTI_READ)
32 #define _TRACE_DBUF_H
33
34 #include <linux/tracepoint.h>
35 #include <sys/types.h>
36
37 #ifndef TRACE_DBUF_MSG_MAX
38 #define TRACE_DBUF_MSG_MAX      512
39 #endif
40
41 /*
42  * Generic support for two argument tracepoints of the form:
43  *
44  * DTRACE_PROBE2(...,
45  *     dmu_buf_impl_t *, ...,
46  *     zio_t *, ...);
47  */
48
49 #define DBUF_TP_STRUCT_ENTRY                                    \
50         __dynamic_array(char,   os_spa, TRACE_DBUF_MSG_MAX)     \
51         __field(uint64_t,       ds_object)                      \
52         __field(uint64_t,       db_object)                      \
53         __field(uint64_t,       db_level)                       \
54         __field(uint64_t,       db_blkid)                       \
55         __field(uint64_t,       db_offset)                      \
56         __field(uint64_t,       db_size)                        \
57         __field(uint64_t,       db_state)                       \
58         __field(int64_t,        db_holds)                       \
59         __dynamic_array(char,   msg,    TRACE_DBUF_MSG_MAX)
60
61 #define DBUF_TP_FAST_ASSIGN                                             \
62         if (db != NULL) {                                               \
63                 __assign_str(os_spa,                                    \
64                 spa_name(DB_DNODE(db)->dn_objset->os_spa));             \
65                                                                         \
66                 __entry->ds_object = db->db_objset->os_dsl_dataset ?    \
67                 db->db_objset->os_dsl_dataset->ds_object : 0;           \
68                                                                         \
69                 __entry->db_object = db->db.db_object;                  \
70                 __entry->db_level  = db->db_level;                      \
71                 __entry->db_blkid  = db->db_blkid;                      \
72                 __entry->db_offset = db->db.db_offset;                  \
73                 __entry->db_size   = db->db.db_size;                    \
74                 __entry->db_state  = db->db_state;                      \
75                 __entry->db_holds  = zfs_refcount_count(&db->db_holds); \
76                 snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX,            \
77                     DBUF_TP_PRINTK_FMT, DBUF_TP_PRINTK_ARGS);           \
78         } else {                                                        \
79                 __assign_str(os_spa, "NULL")                            \
80                 __entry->ds_object = 0;                                 \
81                 __entry->db_object = 0;                                 \
82                 __entry->db_level  = 0;                                 \
83                 __entry->db_blkid  = 0;                                 \
84                 __entry->db_offset = 0;                                 \
85                 __entry->db_size   = 0;                                 \
86                 __entry->db_state  = 0;                                 \
87                 __entry->db_holds  = 0;                                 \
88                 snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX,            \
89                     "dbuf { NULL }");                                   \
90         }
91
92 #define DBUF_TP_PRINTK_FMT                                              \
93         "dbuf { spa \"%s\" objset %llu object %llu level %llu "         \
94         "blkid %llu offset %llu size %llu state %llu holds %lld }"
95
96 #define DBUF_TP_PRINTK_ARGS                                     \
97         __get_str(os_spa), __entry->ds_object,                  \
98         __entry->db_object, __entry->db_level,                  \
99         __entry->db_blkid, __entry->db_offset,                  \
100         __entry->db_size, __entry->db_state, __entry->db_holds
101
102 /* BEGIN CSTYLED */
103 DECLARE_EVENT_CLASS(zfs_dbuf_class,
104         TP_PROTO(dmu_buf_impl_t *db, zio_t *zio),
105         TP_ARGS(db, zio),
106         TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY),
107         TP_fast_assign(DBUF_TP_FAST_ASSIGN),
108         TP_printk("%s", __get_str(msg))
109 );
110
111 DECLARE_EVENT_CLASS(zfs_dbuf_state_class,
112         TP_PROTO(dmu_buf_impl_t *db, const char *why),
113         TP_ARGS(db, why),
114         TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY),
115         TP_fast_assign(DBUF_TP_FAST_ASSIGN),
116         TP_printk("%s", __get_str(msg))
117 );
118 /* END CSTYLED */
119
120 /* BEGIN CSTYLED */
121 #define DEFINE_DBUF_EVENT(name) \
122 DEFINE_EVENT(zfs_dbuf_class, name, \
123         TP_PROTO(dmu_buf_impl_t *db, zio_t *zio), \
124         TP_ARGS(db, zio))
125 /* END CSTYLED */
126 DEFINE_DBUF_EVENT(zfs_blocked__read);
127
128 /* BEGIN CSTYLED */
129 #define DEFINE_DBUF_STATE_EVENT(name) \
130 DEFINE_EVENT(zfs_dbuf_state_class, name, \
131         TP_PROTO(dmu_buf_impl_t *db, const char *why), \
132         TP_ARGS(db, why))
133 /* END CSTYLED */
134 DEFINE_DBUF_STATE_EVENT(zfs_dbuf__state_change);
135
136 /* BEGIN CSTYLED */
137 DECLARE_EVENT_CLASS(zfs_dbuf_evict_one_class,
138         TP_PROTO(dmu_buf_impl_t *db, multilist_sublist_t *mls),
139         TP_ARGS(db, mls),
140         TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY),
141         TP_fast_assign(DBUF_TP_FAST_ASSIGN),
142         TP_printk("%s", __get_str(msg))
143 );
144 /* END CSTYLED */
145
146 /* BEGIN CSTYLED */
147 #define DEFINE_DBUF_EVICT_ONE_EVENT(name) \
148 DEFINE_EVENT(zfs_dbuf_evict_one_class, name, \
149         TP_PROTO(dmu_buf_impl_t *db, multilist_sublist_t *mls), \
150         TP_ARGS(db, mls))
151 /* END CSTYLED */
152 DEFINE_DBUF_EVICT_ONE_EVENT(zfs_dbuf__evict__one);
153
154 #endif /* _TRACE_DBUF_H */
155
156 #undef TRACE_INCLUDE_PATH
157 #undef TRACE_INCLUDE_FILE
158 #define TRACE_INCLUDE_PATH sys
159 #define TRACE_INCLUDE_FILE trace_dbuf
160 #include <trace/define_trace.h>
161
162 #else
163
164 DEFINE_DTRACE_PROBE2(blocked__read);
165 DEFINE_DTRACE_PROBE2(dbuf__evict__one);
166 DEFINE_DTRACE_PROBE2(dbuf__state_change);
167
168 #endif /* HAVE_DECLARE_EVENT_CLASS */
169 #endif /* _KERNEL */