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