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 __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 #define DEFINE_DBUF_EVENT(name) \ 121 DEFINE_EVENT(zfs_dbuf_class, name, \ 122 TP_PROTO(dmu_buf_impl_t *db, zio_t *zio), \ 123 TP_ARGS(db, zio)) 124 DEFINE_DBUF_EVENT(zfs_blocked__read); 125 126 #define DEFINE_DBUF_STATE_EVENT(name) \ 127 DEFINE_EVENT(zfs_dbuf_state_class, name, \ 128 TP_PROTO(dmu_buf_impl_t *db, const char *why), \ 129 TP_ARGS(db, why)) 130 DEFINE_DBUF_STATE_EVENT(zfs_dbuf__state_change); 131 132 /* BEGIN CSTYLED */ 133 DECLARE_EVENT_CLASS(zfs_dbuf_evict_one_class, 134 TP_PROTO(dmu_buf_impl_t *db, multilist_sublist_t *mls), 135 TP_ARGS(db, mls), 136 TP_STRUCT__entry(DBUF_TP_STRUCT_ENTRY), 137 TP_fast_assign(DBUF_TP_FAST_ASSIGN), 138 TP_printk("%s", __get_str(msg)) 139 ); 140 /* END CSTYLED */ 141 142 #define DEFINE_DBUF_EVICT_ONE_EVENT(name) \ 143 DEFINE_EVENT(zfs_dbuf_evict_one_class, name, \ 144 TP_PROTO(dmu_buf_impl_t *db, multilist_sublist_t *mls), \ 145 TP_ARGS(db, mls)) 146 DEFINE_DBUF_EVICT_ONE_EVENT(zfs_dbuf__evict__one); 147 148 #endif /* _TRACE_DBUF_H */ 149 150 #undef TRACE_INCLUDE_PATH 151 #undef TRACE_INCLUDE_FILE 152 #define TRACE_INCLUDE_PATH sys 153 #define TRACE_INCLUDE_FILE trace_dbuf 154 #include <trace/define_trace.h> 155 156 #else 157 158 DEFINE_DTRACE_PROBE2(blocked__read); 159 DEFINE_DTRACE_PROBE2(dbuf__evict__one); 160 DEFINE_DTRACE_PROBE2(dbuf__state_change); 161 162 #endif /* HAVE_DECLARE_EVENT_CLASS */ 163 #endif /* _KERNEL */ 164