1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* Network filesystem support module tracepoints 3 * 4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.com) 6 */ 7 #undef TRACE_SYSTEM 8 #define TRACE_SYSTEM netfs 9 10 #if !defined(_TRACE_NETFS_H) || defined(TRACE_HEADER_MULTI_READ) 11 #define _TRACE_NETFS_H 12 13 #include <linux/tracepoint.h> 14 15 /* 16 * Define enums for tracing information. 17 */ 18 #ifndef __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY 19 #define __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY 20 21 enum netfs_read_trace { 22 netfs_read_trace_expanded, 23 netfs_read_trace_readahead, 24 netfs_read_trace_readpage, 25 netfs_read_trace_write_begin, 26 }; 27 28 enum netfs_rreq_trace { 29 netfs_rreq_trace_assess, 30 netfs_rreq_trace_done, 31 netfs_rreq_trace_free, 32 netfs_rreq_trace_resubmit, 33 netfs_rreq_trace_unlock, 34 netfs_rreq_trace_unmark, 35 netfs_rreq_trace_write, 36 }; 37 38 enum netfs_sreq_trace { 39 netfs_sreq_trace_download_instead, 40 netfs_sreq_trace_free, 41 netfs_sreq_trace_prepare, 42 netfs_sreq_trace_resubmit_short, 43 netfs_sreq_trace_submit, 44 netfs_sreq_trace_terminated, 45 netfs_sreq_trace_write, 46 netfs_sreq_trace_write_skip, 47 netfs_sreq_trace_write_term, 48 }; 49 50 enum netfs_failure { 51 netfs_fail_check_write_begin, 52 netfs_fail_copy_to_cache, 53 netfs_fail_read, 54 netfs_fail_short_readpage, 55 netfs_fail_short_write_begin, 56 netfs_fail_prepare_write, 57 }; 58 59 #endif 60 61 #define netfs_read_traces \ 62 EM(netfs_read_trace_expanded, "EXPANDED ") \ 63 EM(netfs_read_trace_readahead, "READAHEAD") \ 64 EM(netfs_read_trace_readpage, "READPAGE ") \ 65 E_(netfs_read_trace_write_begin, "WRITEBEGN") 66 67 #define netfs_rreq_traces \ 68 EM(netfs_rreq_trace_assess, "ASSESS") \ 69 EM(netfs_rreq_trace_done, "DONE ") \ 70 EM(netfs_rreq_trace_free, "FREE ") \ 71 EM(netfs_rreq_trace_resubmit, "RESUBM") \ 72 EM(netfs_rreq_trace_unlock, "UNLOCK") \ 73 EM(netfs_rreq_trace_unmark, "UNMARK") \ 74 E_(netfs_rreq_trace_write, "WRITE ") 75 76 #define netfs_sreq_sources \ 77 EM(NETFS_FILL_WITH_ZEROES, "ZERO") \ 78 EM(NETFS_DOWNLOAD_FROM_SERVER, "DOWN") \ 79 EM(NETFS_READ_FROM_CACHE, "READ") \ 80 E_(NETFS_INVALID_READ, "INVL") \ 81 82 #define netfs_sreq_traces \ 83 EM(netfs_sreq_trace_download_instead, "RDOWN") \ 84 EM(netfs_sreq_trace_free, "FREE ") \ 85 EM(netfs_sreq_trace_prepare, "PREP ") \ 86 EM(netfs_sreq_trace_resubmit_short, "SHORT") \ 87 EM(netfs_sreq_trace_submit, "SUBMT") \ 88 EM(netfs_sreq_trace_terminated, "TERM ") \ 89 EM(netfs_sreq_trace_write, "WRITE") \ 90 EM(netfs_sreq_trace_write_skip, "SKIP ") \ 91 E_(netfs_sreq_trace_write_term, "WTERM") 92 93 #define netfs_failures \ 94 EM(netfs_fail_check_write_begin, "check-write-begin") \ 95 EM(netfs_fail_copy_to_cache, "copy-to-cache") \ 96 EM(netfs_fail_read, "read") \ 97 EM(netfs_fail_short_readpage, "short-readpage") \ 98 EM(netfs_fail_short_write_begin, "short-write-begin") \ 99 E_(netfs_fail_prepare_write, "prep-write") 100 101 102 /* 103 * Export enum symbols via userspace. 104 */ 105 #undef EM 106 #undef E_ 107 #define EM(a, b) TRACE_DEFINE_ENUM(a); 108 #define E_(a, b) TRACE_DEFINE_ENUM(a); 109 110 netfs_read_traces; 111 netfs_rreq_traces; 112 netfs_sreq_sources; 113 netfs_sreq_traces; 114 netfs_failures; 115 116 /* 117 * Now redefine the EM() and E_() macros to map the enums to the strings that 118 * will be printed in the output. 119 */ 120 #undef EM 121 #undef E_ 122 #define EM(a, b) { a, b }, 123 #define E_(a, b) { a, b } 124 125 TRACE_EVENT(netfs_read, 126 TP_PROTO(struct netfs_read_request *rreq, 127 loff_t start, size_t len, 128 enum netfs_read_trace what), 129 130 TP_ARGS(rreq, start, len, what), 131 132 TP_STRUCT__entry( 133 __field(unsigned int, rreq ) 134 __field(unsigned int, cookie ) 135 __field(loff_t, start ) 136 __field(size_t, len ) 137 __field(enum netfs_read_trace, what ) 138 __field(unsigned int, netfs_inode ) 139 ), 140 141 TP_fast_assign( 142 __entry->rreq = rreq->debug_id; 143 __entry->cookie = rreq->cache_resources.debug_id; 144 __entry->start = start; 145 __entry->len = len; 146 __entry->what = what; 147 __entry->netfs_inode = rreq->inode->i_ino; 148 ), 149 150 TP_printk("R=%08x %s c=%08x ni=%x s=%llx %zx", 151 __entry->rreq, 152 __print_symbolic(__entry->what, netfs_read_traces), 153 __entry->cookie, 154 __entry->netfs_inode, 155 __entry->start, __entry->len) 156 ); 157 158 TRACE_EVENT(netfs_rreq, 159 TP_PROTO(struct netfs_read_request *rreq, 160 enum netfs_rreq_trace what), 161 162 TP_ARGS(rreq, what), 163 164 TP_STRUCT__entry( 165 __field(unsigned int, rreq ) 166 __field(unsigned short, flags ) 167 __field(enum netfs_rreq_trace, what ) 168 ), 169 170 TP_fast_assign( 171 __entry->rreq = rreq->debug_id; 172 __entry->flags = rreq->flags; 173 __entry->what = what; 174 ), 175 176 TP_printk("R=%08x %s f=%02x", 177 __entry->rreq, 178 __print_symbolic(__entry->what, netfs_rreq_traces), 179 __entry->flags) 180 ); 181 182 TRACE_EVENT(netfs_sreq, 183 TP_PROTO(struct netfs_read_subrequest *sreq, 184 enum netfs_sreq_trace what), 185 186 TP_ARGS(sreq, what), 187 188 TP_STRUCT__entry( 189 __field(unsigned int, rreq ) 190 __field(unsigned short, index ) 191 __field(short, error ) 192 __field(unsigned short, flags ) 193 __field(enum netfs_read_source, source ) 194 __field(enum netfs_sreq_trace, what ) 195 __field(size_t, len ) 196 __field(size_t, transferred ) 197 __field(loff_t, start ) 198 ), 199 200 TP_fast_assign( 201 __entry->rreq = sreq->rreq->debug_id; 202 __entry->index = sreq->debug_index; 203 __entry->error = sreq->error; 204 __entry->flags = sreq->flags; 205 __entry->source = sreq->source; 206 __entry->what = what; 207 __entry->len = sreq->len; 208 __entry->transferred = sreq->transferred; 209 __entry->start = sreq->start; 210 ), 211 212 TP_printk("R=%08x[%u] %s %s f=%02x s=%llx %zx/%zx e=%d", 213 __entry->rreq, __entry->index, 214 __print_symbolic(__entry->what, netfs_sreq_traces), 215 __print_symbolic(__entry->source, netfs_sreq_sources), 216 __entry->flags, 217 __entry->start, __entry->transferred, __entry->len, 218 __entry->error) 219 ); 220 221 TRACE_EVENT(netfs_failure, 222 TP_PROTO(struct netfs_read_request *rreq, 223 struct netfs_read_subrequest *sreq, 224 int error, enum netfs_failure what), 225 226 TP_ARGS(rreq, sreq, error, what), 227 228 TP_STRUCT__entry( 229 __field(unsigned int, rreq ) 230 __field(unsigned short, index ) 231 __field(short, error ) 232 __field(unsigned short, flags ) 233 __field(enum netfs_read_source, source ) 234 __field(enum netfs_failure, what ) 235 __field(size_t, len ) 236 __field(size_t, transferred ) 237 __field(loff_t, start ) 238 ), 239 240 TP_fast_assign( 241 __entry->rreq = rreq->debug_id; 242 __entry->index = sreq ? sreq->debug_index : 0; 243 __entry->error = error; 244 __entry->flags = sreq ? sreq->flags : 0; 245 __entry->source = sreq ? sreq->source : NETFS_INVALID_READ; 246 __entry->what = what; 247 __entry->len = sreq ? sreq->len : 0; 248 __entry->transferred = sreq ? sreq->transferred : 0; 249 __entry->start = sreq ? sreq->start : 0; 250 ), 251 252 TP_printk("R=%08x[%u] %s f=%02x s=%llx %zx/%zx %s e=%d", 253 __entry->rreq, __entry->index, 254 __print_symbolic(__entry->source, netfs_sreq_sources), 255 __entry->flags, 256 __entry->start, __entry->transferred, __entry->len, 257 __print_symbolic(__entry->what, netfs_failures), 258 __entry->error) 259 ); 260 261 #endif /* _TRACE_NETFS_H */ 262 263 /* This part must be outside protection */ 264 #include <trace/define_trace.h> 265