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 https://opensource.org/licenses/CDDL-1.0. 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 if (POINTER_IS_VALID(DB_DNODE(db)->dn_objset)) { \ 64 __assign_str(os_spa, \ 65 spa_name(DB_DNODE(db)->dn_objset->os_spa)); \ 66 } else { \ 67 __assign_str(os_spa, "NULL"); \ 68 } \ 69 \ 70 __entry->ds_object = db->db_objset->os_dsl_dataset ? \ 71 db->db_objset->os_dsl_dataset->ds_object : 0; \ 72 \ 73 __entry->db_object = db->db.db_object; \ 74 __entry->db_level = db->db_level; \ 75 __entry->db_blkid = db->db_blkid; \ 76 __entry->db_offset = db->db.db_offset; \ 77 __entry->db_size = db->db.db_size; \ 78 __entry->db_state = db->db_state; \ 79 __entry->db_holds = zfs_refcount_count(&db->db_holds); \ 80 snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX, \ 81 DBUF_TP_PRINTK_FMT, DBUF_TP_PRINTK_ARGS); \ 82 } else { \ 83 __assign_str(os_spa, "NULL") \ 84 __entry->ds_object = 0; \ 85 __entry->db_object = 0; \ 86 __entry->db_level = 0; \ 87 __entry->db_blkid = 0; \ 88 __entry->db_offset = 0; \ 89 __entry->db_size = 0; \ 90 __entry->db_state = 0; \ 91 __entry->db_holds = 0; \ 92 snprintf(__get_str(msg), TRACE_DBUF_MSG_MAX, \ 93 "dbuf { NULL }"); \ 94 } 95 96 #define DBUF_TP_PRINTK_FMT \ 97 "dbuf { spa \"%s\" objset %llu object %llu level %llu " \ 98 "blkid %llu offset %llu size %llu state %llu holds %lld }" 99 100 #define DBUF_TP_PRINTK_ARGS \ 101 __get_str(os_spa), __entry->ds_object, \ 102 __entry->db_object, __entry->db_level, \ 103 __entry->db_blkid, __entry->db_offset, \ 104 __entry->db_size, __entry->db_state, __entry->db_holds 105 106 /* BEGIN CSTYLED */ 107 DECLARE_EVENT_CLASS(zfs_dbuf_class, 108 TP_PROTO(dmu_buf_impl_t *db, zio_t *zio), 109 TP_ARGS(db, zio), 110 TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY), 111 TP_fast_assign(DBUF_TP_FAST_ASSIGN), 112 TP_printk("%s", __get_str(msg)) 113 ); 114 115 DECLARE_EVENT_CLASS(zfs_dbuf_state_class, 116 TP_PROTO(dmu_buf_impl_t *db, const char *why), 117 TP_ARGS(db, why), 118 TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY), 119 TP_fast_assign(DBUF_TP_FAST_ASSIGN), 120 TP_printk("%s", __get_str(msg)) 121 ); 122 /* END CSTYLED */ 123 124 #define DEFINE_DBUF_EVENT(name) \ 125 DEFINE_EVENT(zfs_dbuf_class, name, \ 126 TP_PROTO(dmu_buf_impl_t *db, zio_t *zio), \ 127 TP_ARGS(db, zio)) 128 DEFINE_DBUF_EVENT(zfs_blocked__read); 129 130 #define DEFINE_DBUF_STATE_EVENT(name) \ 131 DEFINE_EVENT(zfs_dbuf_state_class, name, \ 132 TP_PROTO(dmu_buf_impl_t *db, const char *why), \ 133 TP_ARGS(db, why)) 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 #define DEFINE_DBUF_EVICT_ONE_EVENT(name) \ 147 DEFINE_EVENT(zfs_dbuf_evict_one_class, name, \ 148 TP_PROTO(dmu_buf_impl_t *db, multilist_sublist_t *mls), \ 149 TP_ARGS(db, mls)) 150 DEFINE_DBUF_EVICT_ONE_EVENT(zfs_dbuf__evict__one); 151 152 #endif /* _TRACE_DBUF_H */ 153 154 #undef TRACE_INCLUDE_PATH 155 #undef TRACE_INCLUDE_FILE 156 #define TRACE_INCLUDE_PATH sys 157 #define TRACE_INCLUDE_FILE trace_dbuf 158 #include <trace/define_trace.h> 159 160 #else 161 162 DEFINE_DTRACE_PROBE2(blocked__read); 163 DEFINE_DTRACE_PROBE2(dbuf__evict__one); 164 DEFINE_DTRACE_PROBE2(dbuf__state_change); 165 166 #endif /* HAVE_DECLARE_EVENT_CLASS */ 167 #endif /* _KERNEL */ 168