1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 #if defined(_KERNEL) 24 #if defined(HAVE_DECLARE_EVENT_CLASS) 25 26 #undef TRACE_SYSTEM 27 #define TRACE_SYSTEM zfs 28 29 #undef TRACE_SYSTEM_VAR 30 #define TRACE_SYSTEM_VAR zfs_zil 31 32 #if !defined(_TRACE_ZIL_H) || defined(TRACE_HEADER_MULTI_READ) 33 #define _TRACE_ZIL_H 34 35 #include <linux/tracepoint.h> 36 #include <sys/types.h> 37 38 #define ZILOG_TP_STRUCT_ENTRY \ 39 __field(uint64_t, zl_lr_seq) \ 40 __field(uint64_t, zl_commit_lr_seq) \ 41 __field(uint64_t, zl_destroy_txg) \ 42 __field(uint64_t, zl_replaying_seq) \ 43 __field(uint32_t, zl_suspend) \ 44 __field(uint8_t, zl_suspending) \ 45 __field(uint8_t, zl_keep_first) \ 46 __field(uint8_t, zl_replay) \ 47 __field(uint8_t, zl_stop_sync) \ 48 __field(uint8_t, zl_logbias) \ 49 __field(uint8_t, zl_sync) \ 50 __field(int, zl_parse_error) \ 51 __field(uint64_t, zl_parse_blk_seq) \ 52 __field(uint64_t, zl_parse_lr_seq) \ 53 __field(uint64_t, zl_parse_blk_count) \ 54 __field(uint64_t, zl_parse_lr_count) \ 55 __field(uint64_t, zl_cur_size) \ 56 __field(uint64_t, zl_cur_left) \ 57 __field(uint64_t, zl_cur_max) \ 58 __field(clock_t, zl_replay_time) \ 59 __field(uint64_t, zl_replay_blks) 60 61 #define ZILOG_TP_FAST_ASSIGN \ 62 __entry->zl_lr_seq = zilog->zl_lr_seq; \ 63 __entry->zl_commit_lr_seq = zilog->zl_commit_lr_seq; \ 64 __entry->zl_destroy_txg = zilog->zl_destroy_txg; \ 65 __entry->zl_replaying_seq = zilog->zl_replaying_seq; \ 66 __entry->zl_suspend = zilog->zl_suspend; \ 67 __entry->zl_suspending = zilog->zl_suspending; \ 68 __entry->zl_keep_first = zilog->zl_keep_first; \ 69 __entry->zl_replay = zilog->zl_replay; \ 70 __entry->zl_stop_sync = zilog->zl_stop_sync; \ 71 __entry->zl_logbias = zilog->zl_logbias; \ 72 __entry->zl_sync = zilog->zl_sync; \ 73 __entry->zl_parse_error = zilog->zl_parse_error; \ 74 __entry->zl_parse_blk_seq = zilog->zl_parse_blk_seq; \ 75 __entry->zl_parse_lr_seq = zilog->zl_parse_lr_seq; \ 76 __entry->zl_parse_blk_count = zilog->zl_parse_blk_count;\ 77 __entry->zl_parse_lr_count = zilog->zl_parse_lr_count; \ 78 __entry->zl_cur_size = zilog->zl_cur_size; \ 79 __entry->zl_cur_left = zilog->zl_cur_left; \ 80 __entry->zl_cur_max = zilog->zl_cur_max; \ 81 __entry->zl_replay_time = zilog->zl_replay_time; \ 82 __entry->zl_replay_blks = zilog->zl_replay_blks; 83 84 #define ZILOG_TP_PRINTK_FMT \ 85 "zl { lr_seq %llu commit_lr_seq %llu destroy_txg %llu " \ 86 "replaying_seq %llu suspend %u suspending %u keep_first %u " \ 87 "replay %u stop_sync %u logbias %u sync %u " \ 88 "parse_error %u parse_blk_seq %llu parse_lr_seq %llu " \ 89 "parse_blk_count %llu parse_lr_count %llu " \ 90 "cur_size %llu cur_left %llu cur_max %llu replay_time %lu " \ 91 "replay_blks %llu }" 92 93 #define ZILOG_TP_PRINTK_ARGS \ 94 __entry->zl_lr_seq, __entry->zl_commit_lr_seq, \ 95 __entry->zl_destroy_txg, __entry->zl_replaying_seq, \ 96 __entry->zl_suspend, __entry->zl_suspending, \ 97 __entry->zl_keep_first, __entry->zl_replay, \ 98 __entry->zl_stop_sync, __entry->zl_logbias, __entry->zl_sync, \ 99 __entry->zl_parse_error, __entry->zl_parse_blk_seq, \ 100 __entry->zl_parse_lr_seq, __entry->zl_parse_blk_count, \ 101 __entry->zl_parse_lr_count, __entry->zl_cur_size, \ 102 __entry->zl_cur_left, __entry->zl_cur_max, \ 103 __entry->zl_replay_time, __entry->zl_replay_blks 104 105 #define ITX_TP_STRUCT_ENTRY \ 106 __field(itx_wr_state_t, itx_wr_state) \ 107 __field(uint8_t, itx_sync) \ 108 __field(zil_callback_t, itx_callback) \ 109 __field(void *, itx_callback_data) \ 110 __field(uint64_t, itx_oid) \ 111 \ 112 __field(uint64_t, lrc_txtype) \ 113 __field(uint64_t, lrc_reclen) \ 114 __field(uint64_t, lrc_txg) \ 115 __field(uint64_t, lrc_seq) 116 117 #define ITX_TP_FAST_ASSIGN \ 118 __entry->itx_wr_state = itx->itx_wr_state; \ 119 __entry->itx_sync = itx->itx_sync; \ 120 __entry->itx_callback = itx->itx_callback; \ 121 __entry->itx_callback_data = itx->itx_callback_data; \ 122 __entry->itx_oid = itx->itx_oid; \ 123 \ 124 __entry->lrc_txtype = itx->itx_lr.lrc_txtype; \ 125 __entry->lrc_reclen = itx->itx_lr.lrc_reclen; \ 126 __entry->lrc_txg = itx->itx_lr.lrc_txg; \ 127 __entry->lrc_seq = itx->itx_lr.lrc_seq; 128 129 #define ITX_TP_PRINTK_FMT \ 130 "itx { wr_state %u sync %u callback %p callback_data %p oid %llu" \ 131 " { txtype %llu reclen %llu txg %llu seq %llu } }" 132 133 #define ITX_TP_PRINTK_ARGS \ 134 __entry->itx_wr_state, __entry->itx_sync, __entry->itx_callback,\ 135 __entry->itx_callback_data, __entry->itx_oid, \ 136 __entry->lrc_txtype, __entry->lrc_reclen, __entry->lrc_txg, \ 137 __entry->lrc_seq 138 139 #define ZCW_TP_STRUCT_ENTRY \ 140 __field(lwb_t *, zcw_lwb) \ 141 __field(boolean_t, zcw_done) \ 142 __field(int, zcw_zio_error) \ 143 144 #define ZCW_TP_FAST_ASSIGN \ 145 __entry->zcw_lwb = zcw->zcw_lwb; \ 146 __entry->zcw_done = zcw->zcw_done; \ 147 __entry->zcw_zio_error = zcw->zcw_zio_error; 148 149 #define ZCW_TP_PRINTK_FMT \ 150 "zcw { lwb %p done %u error %u }" 151 152 #define ZCW_TP_PRINTK_ARGS \ 153 __entry->zcw_lwb, __entry->zcw_done, __entry->zcw_zio_error 154 155 /* 156 * Generic support for two argument tracepoints of the form: 157 * 158 * DTRACE_PROBE2(..., 159 * zilog_t *, ..., 160 * itx_t *, ...); 161 */ 162 163 #if defined(__clang__) 164 #pragma clang diagnostic push 165 #pragma clang diagnostic ignored "-Wordered-compare-function-pointers" 166 #endif 167 /* BEGIN CSTYLED */ 168 DECLARE_EVENT_CLASS(zfs_zil_process_itx_class, 169 TP_PROTO(zilog_t *zilog, itx_t *itx), 170 TP_ARGS(zilog, itx), 171 TP_STRUCT__entry( 172 ZILOG_TP_STRUCT_ENTRY 173 ITX_TP_STRUCT_ENTRY 174 ), 175 TP_fast_assign( 176 ZILOG_TP_FAST_ASSIGN 177 ITX_TP_FAST_ASSIGN 178 ), 179 TP_printk( 180 ZILOG_TP_PRINTK_FMT " " ITX_TP_PRINTK_FMT, 181 ZILOG_TP_PRINTK_ARGS, ITX_TP_PRINTK_ARGS) 182 ); 183 /* END CSTYLED */ 184 #if defined(__clang__) 185 #pragma clang diagnostic pop 186 #endif 187 188 #define DEFINE_ZIL_PROCESS_ITX_EVENT(name) \ 189 DEFINE_EVENT(zfs_zil_process_itx_class, name, \ 190 TP_PROTO(zilog_t *zilog, itx_t *itx), \ 191 TP_ARGS(zilog, itx)) 192 DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__commit__itx); 193 DEFINE_ZIL_PROCESS_ITX_EVENT(zfs_zil__process__normal__itx); 194 195 /* 196 * Generic support for two argument tracepoints of the form: 197 * 198 * DTRACE_PROBE2(..., 199 * zilog_t *, ..., 200 * zil_commit_waiter_t *, ...); 201 */ 202 /* BEGIN CSTYLED */ 203 DECLARE_EVENT_CLASS(zfs_zil_commit_io_error_class, 204 TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw), 205 TP_ARGS(zilog, zcw), 206 TP_STRUCT__entry( 207 ZILOG_TP_STRUCT_ENTRY 208 ZCW_TP_STRUCT_ENTRY 209 ), 210 TP_fast_assign( 211 ZILOG_TP_FAST_ASSIGN 212 ZCW_TP_FAST_ASSIGN 213 ), 214 TP_printk( 215 ZILOG_TP_PRINTK_FMT " " ZCW_TP_PRINTK_FMT, 216 ZILOG_TP_PRINTK_ARGS, ZCW_TP_PRINTK_ARGS) 217 ); 218 219 #define DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(name) \ 220 DEFINE_EVENT(zfs_zil_commit_io_error_class, name, \ 221 TP_PROTO(zilog_t *zilog, zil_commit_waiter_t *zcw), \ 222 TP_ARGS(zilog, zcw)) 223 DEFINE_ZIL_COMMIT_IO_ERROR_EVENT(zfs_zil__commit__io__error); 224 225 /* 226 * Generic support for three argument tracepoints of the form: 227 * 228 * DTRACE_PROBE3(..., 229 * zilog_t *, ..., 230 * uint64_t, ..., 231 * uint64_t, ...); 232 */ 233 /* BEGIN CSTYLED */ 234 DECLARE_EVENT_CLASS(zfs_zil_block_size_class, 235 TP_PROTO(zilog_t *zilog, uint64_t res, uint64_t s1), 236 TP_ARGS(zilog, res, s1), 237 TP_STRUCT__entry( 238 ZILOG_TP_STRUCT_ENTRY 239 __field(uint64_t, res) 240 __field(uint64_t, s1) 241 ), 242 TP_fast_assign( 243 ZILOG_TP_FAST_ASSIGN 244 __entry->res = res; 245 __entry->s1 = s1; 246 ), 247 TP_printk( 248 ZILOG_TP_PRINTK_FMT " res %llu s1 %llu", 249 ZILOG_TP_PRINTK_ARGS, __entry->res, __entry->s1) 250 ); 251 252 #define DEFINE_ZIL_BLOCK_SIZE_EVENT(name) \ 253 DEFINE_EVENT(zfs_zil_block_size_class, name, \ 254 TP_PROTO(zilog_t *zilog, uint64_t res, uint64_t s1), \ 255 TP_ARGS(zilog, res, s1)) 256 DEFINE_ZIL_BLOCK_SIZE_EVENT(zfs_zil__block__size); 257 258 #endif /* _TRACE_ZIL_H */ 259 260 #undef TRACE_INCLUDE_PATH 261 #undef TRACE_INCLUDE_FILE 262 #define TRACE_INCLUDE_PATH sys 263 #define TRACE_INCLUDE_FILE trace_zil 264 #include <trace/define_trace.h> 265 266 #else 267 268 DEFINE_DTRACE_PROBE2(zil__process__commit__itx); 269 DEFINE_DTRACE_PROBE2(zil__process__normal__itx); 270 DEFINE_DTRACE_PROBE2(zil__commit__io__error); 271 DEFINE_DTRACE_PROBE3(zil__block__size); 272 273 #endif /* HAVE_DECLARE_EVENT_CLASS */ 274 #endif /* _KERNEL */ 275