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_zil 30 31 #if !defined(_TRACE_ZIL_H) || defined(TRACE_HEADER_MULTI_READ) 32 #define _TRACE_ZIL_H 33 34 #include <linux/tracepoint.h> 35 #include <sys/types.h> 36 37 #define ZILOG_TP_STRUCT_ENTRY \ 38 __field(uint64_t, zl_lr_seq) \ 39 __field(uint64_t, zl_commit_lr_seq) \ 40 __field(uint64_t, zl_destroy_txg) \ 41 __field(uint64_t, zl_replaying_seq) \ 42 __field(uint32_t, zl_suspend) \ 43 __field(uint8_t, zl_suspending) \ 44 __field(uint8_t, zl_keep_first) \ 45 __field(uint8_t, zl_replay) \ 46 __field(uint8_t, zl_stop_sync) \ 47 __field(uint8_t, zl_logbias) \ 48 __field(uint8_t, zl_sync) \ 49 __field(int, zl_parse_error) \ 50 __field(uint64_t, zl_parse_blk_seq) \ 51 __field(uint64_t, zl_parse_lr_seq) \ 52 __field(uint64_t, zl_parse_blk_count) \ 53 __field(uint64_t, zl_parse_lr_count) \ 54 __field(uint64_t, zl_cur_size) \ 55 __field(uint64_t, zl_cur_left) \ 56 __field(uint64_t, zl_cur_max) \ 57 __field(clock_t, zl_replay_time) \ 58 __field(uint64_t, zl_replay_blks) 59 60 #define ZILOG_TP_FAST_ASSIGN \ 61 __entry->zl_lr_seq = zilog->zl_lr_seq; \ 62 __entry->zl_commit_lr_seq = zilog->zl_commit_lr_seq; \ 63 __entry->zl_destroy_txg = zilog->zl_destroy_txg; \ 64 __entry->zl_replaying_seq = zilog->zl_replaying_seq; \ 65 __entry->zl_suspend = zilog->zl_suspend; \ 66 __entry->zl_suspending = zilog->zl_suspending; \ 67 __entry->zl_keep_first = zilog->zl_keep_first; \ 68 __entry->zl_replay = zilog->zl_replay; \ 69 __entry->zl_stop_sync = zilog->zl_stop_sync; \ 70 __entry->zl_logbias = zilog->zl_logbias; \ 71 __entry->zl_sync = zilog->zl_sync; \ 72 __entry->zl_parse_error = zilog->zl_parse_error; \ 73 __entry->zl_parse_blk_seq = zilog->zl_parse_blk_seq; \ 74 __entry->zl_parse_lr_seq = zilog->zl_parse_lr_seq; \ 75 __entry->zl_parse_blk_count = zilog->zl_parse_blk_count;\ 76 __entry->zl_parse_lr_count = zilog->zl_parse_lr_count; \ 77 __entry->zl_cur_size = zilog->zl_cur_size; \ 78 __entry->zl_cur_left = zilog->zl_cur_left; \ 79 __entry->zl_cur_max = zilog->zl_cur_max; \ 80 __entry->zl_replay_time = zilog->zl_replay_time; \ 81 __entry->zl_replay_blks = zilog->zl_replay_blks; 82 83 #define ZILOG_TP_PRINTK_FMT \ 84 "zl { lr_seq %llu commit_lr_seq %llu destroy_txg %llu " \ 85 "replaying_seq %llu suspend %u suspending %u keep_first %u " \ 86 "replay %u stop_sync %u logbias %u sync %u " \ 87 "parse_error %u parse_blk_seq %llu parse_lr_seq %llu " \ 88 "parse_blk_count %llu parse_lr_count %llu " \ 89 "cur_size %llu cur_left %llu cur_max %llu replay_time %lu " \ 90 "replay_blks %llu }" 91 92 #define ZILOG_TP_PRINTK_ARGS \ 93 __entry->zl_lr_seq, __entry->zl_commit_lr_seq, \ 94 __entry->zl_destroy_txg, __entry->zl_replaying_seq, \ 95 __entry->zl_suspend, __entry->zl_suspending, \ 96 __entry->zl_keep_first, __entry->zl_replay, \ 97 __entry->zl_stop_sync, __entry->zl_logbias, __entry->zl_sync, \ 98 __entry->zl_parse_error, __entry->zl_parse_blk_seq, \ 99 __entry->zl_parse_lr_seq, __entry->zl_parse_blk_count, \ 100 __entry->zl_parse_lr_count, __entry->zl_cur_size, \ 101 __entry->zl_cur_left, __entry->zl_cur_max, \ 102 __entry->zl_replay_time, __entry->zl_replay_blks 103 104 #define ITX_TP_STRUCT_ENTRY \ 105 __field(itx_wr_state_t, itx_wr_state) \ 106 __field(uint8_t, itx_sync) \ 107 __field(zil_callback_t, itx_callback) \ 108 __field(void *, itx_callback_data) \ 109 __field(uint64_t, itx_oid) \ 110 \ 111 __field(uint64_t, lrc_txtype) \ 112 __field(uint64_t, lrc_reclen) \ 113 __field(uint64_t, lrc_txg) \ 114 __field(uint64_t, lrc_seq) 115 116 #define ITX_TP_FAST_ASSIGN \ 117 __entry->itx_wr_state = itx->itx_wr_state; \ 118 __entry->itx_sync = itx->itx_sync; \ 119 __entry->itx_callback = itx->itx_callback; \ 120 __entry->itx_callback_data = itx->itx_callback_data; \ 121 __entry->itx_oid = itx->itx_oid; \ 122 \ 123 __entry->lrc_txtype = itx->itx_lr.lrc_txtype; \ 124 __entry->lrc_reclen = itx->itx_lr.lrc_reclen; \ 125 __entry->lrc_txg = itx->itx_lr.lrc_txg; \ 126 __entry->lrc_seq = itx->itx_lr.lrc_seq; 127 128 #define ITX_TP_PRINTK_FMT \ 129 "itx { wr_state %u sync %u callback %p callback_data %p oid %llu" \ 130 " { txtype %llu reclen %llu txg %llu seq %llu } }" 131 132 #define ITX_TP_PRINTK_ARGS \ 133 __entry->itx_wr_state, __entry->itx_sync, __entry->itx_callback,\ 134 __entry->itx_callback_data, __entry->itx_oid, \ 135 __entry->lrc_txtype, __entry->lrc_reclen, __entry->lrc_txg, \ 136 __entry->lrc_seq 137 138 #define ZCW_TP_STRUCT_ENTRY \ 139 __field(lwb_t *, zcw_lwb) \ 140 __field(boolean_t, zcw_done) \ 141 __field(int, zcw_zio_error) \ 142 143 #define ZCW_TP_FAST_ASSIGN \ 144 __entry->zcw_lwb = zcw->zcw_lwb; \ 145 __entry->zcw_done = zcw->zcw_done; \ 146 __entry->zcw_zio_error = zcw->zcw_zio_error; 147 148 #define ZCW_TP_PRINTK_FMT \ 149 "zcw { lwb %p done %u error %u }" 150 151 #define ZCW_TP_PRINTK_ARGS \ 152 __entry->zcw_lwb, __entry->zcw_done, __entry->zcw_zio_error 153 154 /* 155 * Generic support for two argument tracepoints of the form: 156 * 157 * DTRACE_PROBE2(..., 158 * zilog_t *, ..., 159 * itx_t *, ...); 160 */ 161 162 #if defined(__clang__) 163 #pragma clang diagnostic push 164 #pragma clang diagnostic ignored "-Wordered-compare-function-pointers" 165 #endif 166 /* BEGIN CSTYLED */ 167 DECLARE_EVENT_CLASS(zfs_zil_process_itx_class, 168 TP_PROTO(zilog_t *zilog, itx_t *itx), 169 TP_ARGS(zilog, itx), 170 TP_STRUCT__entry( 171 ZILOG_TP_STRUCT_ENTRY 172 ITX_TP_STRUCT_ENTRY 173 ), 174 TP_fast_assign( 175 ZILOG_TP_FAST_ASSIGN 176 ITX_TP_FAST_ASSIGN 177 ), 178 TP_printk( 179 ZILOG_TP_PRINTK_FMT " " ITX_TP_PRINTK_FMT, 180 ZILOG_TP_PRINTK_ARGS, ITX_TP_PRINTK_ARGS) 181 ); 182 /* END CSTYLED */ 183 #if defined(__clang__) 184 #pragma clang diagnostic pop 185 #endif 186 187 #define DEFINE_ZIL_PROCESS_ITX_EVENT(name) \ 188 DEFINE_EVENT(zfs_zil_process_itx_class, name, \ 189 TP_PROTO(zilog_t *zilog, itx_t *itx), \ 190 TP_ARGS(zilog, itx)) 191 DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__commit__itx); 192 DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__normal__itx); 193 194 /* 195 * Generic support for two argument tracepoints of the form: 196 * 197 * DTRACE_PROBE2(..., 198 * zilog_t *, ..., 199 * zil_commit_waiter_t *, ...); 200 */ 201 /* BEGIN CSTYLED */ 202 DECLARE_EVENT_CLASS(zfs_zil_commit_io_error_class, 203 TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw), 204 TP_ARGS(zilog, zcw), 205 TP_STRUCT__entry( 206 ZILOG_TP_STRUCT_ENTRY 207 ZCW_TP_STRUCT_ENTRY 208 ), 209 TP_fast_assign( 210 ZILOG_TP_FAST_ASSIGN 211 ZCW_TP_FAST_ASSIGN 212 ), 213 TP_printk( 214 ZILOG_TP_PRINTK_FMT " " ZCW_TP_PRINTK_FMT, 215 ZILOG_TP_PRINTK_ARGS, ZCW_TP_PRINTK_ARGS) 216 ); 217 218 #define DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(name) \ 219 DEFINE_EVENT(zfs_zil_commit_io_error_class, name, \ 220 TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw), \ 221 TP_ARGS(zilog, zcw)) 222 DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(zfs_zil__commit__io__error); 223 224 /* 225 * Generic support for three argument tracepoints of the form: 226 * 227 * DTRACE_PROBE3(..., 228 * zilog_t *, ..., 229 * uint64_t, ..., 230 * uint64_t, ...); 231 */ 232 /* BEGIN CSTYLED */ 233 DECLARE_EVENT_CLASS(zfs_zil_block_size_class, 234 TP_PROTO(zilog_t *zilog, uint64_t res, uint64_t s1), 235 TP_ARGS(zilog, res, s1), 236 TP_STRUCT__entry( 237 ZILOG_TP_STRUCT_ENTRY 238 __field(uint64_t, res) 239 __field(uint64_t, s1) 240 ), 241 TP_fast_assign( 242 ZILOG_TP_FAST_ASSIGN 243 __entry->res = res; 244 __entry->s1 = s1; 245 ), 246 TP_printk( 247 ZILOG_TP_PRINTK_FMT " res %llu s1 %llu", 248 ZILOG_TP_PRINTK_ARGS, __entry->res, __entry->s1) 249 ); 250 251 #define DEFINE_ZIL_BLOCK_SIZE_EVENT(name) \ 252 DEFINE_EVENT(zfs_zil_block_size_class, name, \ 253 TP_PROTO(zilog_t *zilog, uint64_t res, uint64_t s1), \ 254 TP_ARGS(zilog, res, s1)) 255 DEFINE_ZIL_BLOCK_SIZE_EVENT(zfs_zil__block__size); 256 257 #endif /* _TRACE_ZIL_H */ 258 259 #undef TRACE_INCLUDE_PATH 260 #undef TRACE_INCLUDE_FILE 261 #define TRACE_INCLUDE_PATH sys 262 #define TRACE_INCLUDE_FILE trace_zil 263 #include <trace/define_trace.h> 264 265 #else 266 267 DEFINE_DTRACE_PROBE2(zil__process__commit__itx); 268 DEFINE_DTRACE_PROBE2(zil__process__normal__itx); 269 DEFINE_DTRACE_PROBE2(zil__commit__io__error); 270 DEFINE_DTRACE_PROBE3(zil__block__size); 271 272 #endif /* HAVE_DECLARE_EVENT_CLASS */ 273 #endif /* _KERNEL */ 274