xref: /linux/include/trace/events/netfs.h (revision e301aea030d60da760f85f854a82ce788d5cf6e7)
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 #define netfs_read_traces					\
19 	EM(netfs_read_trace_dio_read,		"DIO-READ ")	\
20 	EM(netfs_read_trace_expanded,		"EXPANDED ")	\
21 	EM(netfs_read_trace_readahead,		"READAHEAD")	\
22 	EM(netfs_read_trace_readpage,		"READPAGE ")	\
23 	EM(netfs_read_trace_read_gaps,		"READ-GAPS")	\
24 	EM(netfs_read_trace_prefetch_for_write,	"PREFETCHW")	\
25 	E_(netfs_read_trace_write_begin,	"WRITEBEGN")
26 
27 #define netfs_write_traces					\
28 	EM(netfs_write_trace_copy_to_cache,	"COPY2CACH")	\
29 	EM(netfs_write_trace_dio_write,		"DIO-WRITE")	\
30 	EM(netfs_write_trace_unbuffered_write,	"UNB-WRITE")	\
31 	EM(netfs_write_trace_writeback,		"WRITEBACK")	\
32 	E_(netfs_write_trace_writethrough,	"WRITETHRU")
33 
34 #define netfs_rreq_origins					\
35 	EM(NETFS_READAHEAD,			"RA")		\
36 	EM(NETFS_READPAGE,			"RP")		\
37 	EM(NETFS_READ_GAPS,			"RG")		\
38 	EM(NETFS_READ_FOR_WRITE,		"RW")		\
39 	EM(NETFS_DIO_READ,			"DR")		\
40 	EM(NETFS_WRITEBACK,			"WB")		\
41 	EM(NETFS_WRITETHROUGH,			"WT")		\
42 	EM(NETFS_UNBUFFERED_WRITE,		"UW")		\
43 	EM(NETFS_DIO_WRITE,			"DW")		\
44 	E_(NETFS_PGPRIV2_COPY_TO_CACHE,		"2C")
45 
46 #define netfs_rreq_traces					\
47 	EM(netfs_rreq_trace_assess,		"ASSESS ")	\
48 	EM(netfs_rreq_trace_copy,		"COPY   ")	\
49 	EM(netfs_rreq_trace_collect,		"COLLECT")	\
50 	EM(netfs_rreq_trace_done,		"DONE   ")	\
51 	EM(netfs_rreq_trace_free,		"FREE   ")	\
52 	EM(netfs_rreq_trace_redirty,		"REDIRTY")	\
53 	EM(netfs_rreq_trace_resubmit,		"RESUBMT")	\
54 	EM(netfs_rreq_trace_set_pause,		"PAUSE  ")	\
55 	EM(netfs_rreq_trace_unlock,		"UNLOCK ")	\
56 	EM(netfs_rreq_trace_unlock_pgpriv2,	"UNLCK-2")	\
57 	EM(netfs_rreq_trace_unmark,		"UNMARK ")	\
58 	EM(netfs_rreq_trace_wait_ip,		"WAIT-IP")	\
59 	EM(netfs_rreq_trace_wait_pause,		"WT-PAUS")	\
60 	EM(netfs_rreq_trace_wake_ip,		"WAKE-IP")	\
61 	EM(netfs_rreq_trace_unpause,		"UNPAUSE")	\
62 	E_(netfs_rreq_trace_write_done,		"WR-DONE")
63 
64 #define netfs_sreq_sources					\
65 	EM(NETFS_SOURCE_UNKNOWN,		"----")		\
66 	EM(NETFS_FILL_WITH_ZEROES,		"ZERO")		\
67 	EM(NETFS_DOWNLOAD_FROM_SERVER,		"DOWN")		\
68 	EM(NETFS_READ_FROM_CACHE,		"READ")		\
69 	EM(NETFS_INVALID_READ,			"INVL")		\
70 	EM(NETFS_UPLOAD_TO_SERVER,		"UPLD")		\
71 	EM(NETFS_WRITE_TO_CACHE,		"WRIT")		\
72 	E_(NETFS_INVALID_WRITE,			"INVL")
73 
74 #define netfs_sreq_traces					\
75 	EM(netfs_sreq_trace_add_donations,	"+DON ")	\
76 	EM(netfs_sreq_trace_added,		"ADD  ")	\
77 	EM(netfs_sreq_trace_clear,		"CLEAR")	\
78 	EM(netfs_sreq_trace_discard,		"DSCRD")	\
79 	EM(netfs_sreq_trace_donate_to_prev,	"DON-P")	\
80 	EM(netfs_sreq_trace_donate_to_next,	"DON-N")	\
81 	EM(netfs_sreq_trace_download_instead,	"RDOWN")	\
82 	EM(netfs_sreq_trace_fail,		"FAIL ")	\
83 	EM(netfs_sreq_trace_free,		"FREE ")	\
84 	EM(netfs_sreq_trace_hit_eof,		"EOF  ")	\
85 	EM(netfs_sreq_trace_io_progress,	"IO   ")	\
86 	EM(netfs_sreq_trace_limited,		"LIMIT")	\
87 	EM(netfs_sreq_trace_prepare,		"PREP ")	\
88 	EM(netfs_sreq_trace_prep_failed,	"PRPFL")	\
89 	EM(netfs_sreq_trace_progress,		"PRGRS")	\
90 	EM(netfs_sreq_trace_reprep_failed,	"REPFL")	\
91 	EM(netfs_sreq_trace_retry,		"RETRY")	\
92 	EM(netfs_sreq_trace_short,		"SHORT")	\
93 	EM(netfs_sreq_trace_split,		"SPLIT")	\
94 	EM(netfs_sreq_trace_submit,		"SUBMT")	\
95 	EM(netfs_sreq_trace_terminated,		"TERM ")	\
96 	EM(netfs_sreq_trace_write,		"WRITE")	\
97 	EM(netfs_sreq_trace_write_skip,		"SKIP ")	\
98 	E_(netfs_sreq_trace_write_term,		"WTERM")
99 
100 #define netfs_failures							\
101 	EM(netfs_fail_check_write_begin,	"check-write-begin")	\
102 	EM(netfs_fail_copy_to_cache,		"copy-to-cache")	\
103 	EM(netfs_fail_dio_read_short,		"dio-read-short")	\
104 	EM(netfs_fail_dio_read_zero,		"dio-read-zero")	\
105 	EM(netfs_fail_read,			"read")			\
106 	EM(netfs_fail_short_read,		"short-read")		\
107 	EM(netfs_fail_prepare_write,		"prep-write")		\
108 	E_(netfs_fail_write,			"write")
109 
110 #define netfs_rreq_ref_traces					\
111 	EM(netfs_rreq_trace_get_for_outstanding,"GET OUTSTND")	\
112 	EM(netfs_rreq_trace_get_subreq,		"GET SUBREQ ")	\
113 	EM(netfs_rreq_trace_get_work,		"GET WORK   ")	\
114 	EM(netfs_rreq_trace_put_complete,	"PUT COMPLT ")	\
115 	EM(netfs_rreq_trace_put_discard,	"PUT DISCARD")	\
116 	EM(netfs_rreq_trace_put_failed,		"PUT FAILED ")	\
117 	EM(netfs_rreq_trace_put_no_submit,	"PUT NO-SUBM")	\
118 	EM(netfs_rreq_trace_put_return,		"PUT RETURN ")	\
119 	EM(netfs_rreq_trace_put_subreq,		"PUT SUBREQ ")	\
120 	EM(netfs_rreq_trace_put_work,		"PUT WORK   ")	\
121 	EM(netfs_rreq_trace_put_work_complete,	"PUT WORK CP")	\
122 	EM(netfs_rreq_trace_put_work_nq,	"PUT WORK NQ")	\
123 	EM(netfs_rreq_trace_see_work,		"SEE WORK   ")	\
124 	E_(netfs_rreq_trace_new,		"NEW        ")
125 
126 #define netfs_sreq_ref_traces					\
127 	EM(netfs_sreq_trace_get_copy_to_cache,	"GET COPY2C ")	\
128 	EM(netfs_sreq_trace_get_resubmit,	"GET RESUBMIT")	\
129 	EM(netfs_sreq_trace_get_submit,		"GET SUBMIT")	\
130 	EM(netfs_sreq_trace_get_short_read,	"GET SHORTRD")	\
131 	EM(netfs_sreq_trace_new,		"NEW        ")	\
132 	EM(netfs_sreq_trace_put_cancel,		"PUT CANCEL ")	\
133 	EM(netfs_sreq_trace_put_clear,		"PUT CLEAR  ")	\
134 	EM(netfs_sreq_trace_put_consumed,	"PUT CONSUME")	\
135 	EM(netfs_sreq_trace_put_done,		"PUT DONE   ")	\
136 	EM(netfs_sreq_trace_put_failed,		"PUT FAILED ")	\
137 	EM(netfs_sreq_trace_put_merged,		"PUT MERGED ")	\
138 	EM(netfs_sreq_trace_put_no_copy,	"PUT NO COPY")	\
139 	EM(netfs_sreq_trace_put_oom,		"PUT OOM    ")	\
140 	EM(netfs_sreq_trace_put_wip,		"PUT WIP    ")	\
141 	EM(netfs_sreq_trace_put_work,		"PUT WORK   ")	\
142 	E_(netfs_sreq_trace_put_terminated,	"PUT TERM   ")
143 
144 #define netfs_folio_traces					\
145 	EM(netfs_folio_is_uptodate,		"mod-uptodate")	\
146 	EM(netfs_just_prefetch,			"mod-prefetch")	\
147 	EM(netfs_whole_folio_modify,		"mod-whole-f")	\
148 	EM(netfs_modify_and_clear,		"mod-n-clear")	\
149 	EM(netfs_streaming_write,		"mod-streamw")	\
150 	EM(netfs_streaming_write_cont,		"mod-streamw+")	\
151 	EM(netfs_flush_content,			"flush")	\
152 	EM(netfs_streaming_filled_page,		"mod-streamw-f") \
153 	EM(netfs_streaming_cont_filled_page,	"mod-streamw-f+") \
154 	EM(netfs_folio_trace_abandon,		"abandon")	\
155 	EM(netfs_folio_trace_cancel_copy,	"cancel-copy")	\
156 	EM(netfs_folio_trace_cancel_store,	"cancel-store")	\
157 	EM(netfs_folio_trace_clear,		"clear")	\
158 	EM(netfs_folio_trace_clear_cc,		"clear-cc")	\
159 	EM(netfs_folio_trace_clear_g,		"clear-g")	\
160 	EM(netfs_folio_trace_clear_s,		"clear-s")	\
161 	EM(netfs_folio_trace_copy_to_cache,	"mark-copy")	\
162 	EM(netfs_folio_trace_end_copy,		"end-copy")	\
163 	EM(netfs_folio_trace_filled_gaps,	"filled-gaps")	\
164 	EM(netfs_folio_trace_kill,		"kill")		\
165 	EM(netfs_folio_trace_kill_cc,		"kill-cc")	\
166 	EM(netfs_folio_trace_kill_g,		"kill-g")	\
167 	EM(netfs_folio_trace_kill_s,		"kill-s")	\
168 	EM(netfs_folio_trace_mkwrite,		"mkwrite")	\
169 	EM(netfs_folio_trace_mkwrite_plus,	"mkwrite+")	\
170 	EM(netfs_folio_trace_not_under_wback,	"!wback")	\
171 	EM(netfs_folio_trace_put,		"put")		\
172 	EM(netfs_folio_trace_read,		"read")		\
173 	EM(netfs_folio_trace_read_done,		"read-done")	\
174 	EM(netfs_folio_trace_read_gaps,		"read-gaps")	\
175 	EM(netfs_folio_trace_read_unlock,	"read-unlock")	\
176 	EM(netfs_folio_trace_redirtied,		"redirtied")	\
177 	EM(netfs_folio_trace_store,		"store")	\
178 	EM(netfs_folio_trace_store_copy,	"store-copy")	\
179 	EM(netfs_folio_trace_store_plus,	"store+")	\
180 	EM(netfs_folio_trace_wthru,		"wthru")	\
181 	E_(netfs_folio_trace_wthru_plus,	"wthru+")
182 
183 #define netfs_collect_contig_traces				\
184 	EM(netfs_contig_trace_collect,		"Collect")	\
185 	EM(netfs_contig_trace_jump,		"-->JUMP-->")	\
186 	E_(netfs_contig_trace_unlock,		"Unlock")
187 
188 #define netfs_donate_traces					\
189 	EM(netfs_trace_donate_tail_to_prev,	"tail-to-prev")	\
190 	EM(netfs_trace_donate_to_prev,		"to-prev")	\
191 	EM(netfs_trace_donate_to_next,		"to-next")	\
192 	E_(netfs_trace_donate_to_deferred_next,	"defer-next")
193 
194 #ifndef __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY
195 #define __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY
196 
197 #undef EM
198 #undef E_
199 #define EM(a, b) a,
200 #define E_(a, b) a
201 
202 enum netfs_read_trace { netfs_read_traces } __mode(byte);
203 enum netfs_write_trace { netfs_write_traces } __mode(byte);
204 enum netfs_rreq_trace { netfs_rreq_traces } __mode(byte);
205 enum netfs_sreq_trace { netfs_sreq_traces } __mode(byte);
206 enum netfs_failure { netfs_failures } __mode(byte);
207 enum netfs_rreq_ref_trace { netfs_rreq_ref_traces } __mode(byte);
208 enum netfs_sreq_ref_trace { netfs_sreq_ref_traces } __mode(byte);
209 enum netfs_folio_trace { netfs_folio_traces } __mode(byte);
210 enum netfs_collect_contig_trace { netfs_collect_contig_traces } __mode(byte);
211 enum netfs_donate_trace { netfs_donate_traces } __mode(byte);
212 
213 #endif
214 
215 /*
216  * Export enum symbols via userspace.
217  */
218 #undef EM
219 #undef E_
220 #define EM(a, b) TRACE_DEFINE_ENUM(a);
221 #define E_(a, b) TRACE_DEFINE_ENUM(a);
222 
223 netfs_read_traces;
224 netfs_write_traces;
225 netfs_rreq_origins;
226 netfs_rreq_traces;
227 netfs_sreq_sources;
228 netfs_sreq_traces;
229 netfs_failures;
230 netfs_rreq_ref_traces;
231 netfs_sreq_ref_traces;
232 netfs_folio_traces;
233 netfs_collect_contig_traces;
234 netfs_donate_traces;
235 
236 /*
237  * Now redefine the EM() and E_() macros to map the enums to the strings that
238  * will be printed in the output.
239  */
240 #undef EM
241 #undef E_
242 #define EM(a, b)	{ a, b },
243 #define E_(a, b)	{ a, b }
244 
245 TRACE_EVENT(netfs_read,
246 	    TP_PROTO(struct netfs_io_request *rreq,
247 		     loff_t start, size_t len,
248 		     enum netfs_read_trace what),
249 
250 	    TP_ARGS(rreq, start, len, what),
251 
252 	    TP_STRUCT__entry(
253 		    __field(unsigned int,		rreq		)
254 		    __field(unsigned int,		cookie		)
255 		    __field(loff_t,			i_size		)
256 		    __field(loff_t,			start		)
257 		    __field(size_t,			len		)
258 		    __field(enum netfs_read_trace,	what		)
259 		    __field(unsigned int,		netfs_inode	)
260 			     ),
261 
262 	    TP_fast_assign(
263 		    __entry->rreq	= rreq->debug_id;
264 		    __entry->cookie	= rreq->cache_resources.debug_id;
265 		    __entry->i_size	= rreq->i_size;
266 		    __entry->start	= start;
267 		    __entry->len	= len;
268 		    __entry->what	= what;
269 		    __entry->netfs_inode = rreq->inode->i_ino;
270 			   ),
271 
272 	    TP_printk("R=%08x %s c=%08x ni=%x s=%llx l=%zx sz=%llx",
273 		      __entry->rreq,
274 		      __print_symbolic(__entry->what, netfs_read_traces),
275 		      __entry->cookie,
276 		      __entry->netfs_inode,
277 		      __entry->start, __entry->len, __entry->i_size)
278 	    );
279 
280 TRACE_EVENT(netfs_rreq,
281 	    TP_PROTO(struct netfs_io_request *rreq,
282 		     enum netfs_rreq_trace what),
283 
284 	    TP_ARGS(rreq, what),
285 
286 	    TP_STRUCT__entry(
287 		    __field(unsigned int,		rreq		)
288 		    __field(unsigned int,		flags		)
289 		    __field(enum netfs_io_origin,	origin		)
290 		    __field(enum netfs_rreq_trace,	what		)
291 			     ),
292 
293 	    TP_fast_assign(
294 		    __entry->rreq	= rreq->debug_id;
295 		    __entry->flags	= rreq->flags;
296 		    __entry->origin	= rreq->origin;
297 		    __entry->what	= what;
298 			   ),
299 
300 	    TP_printk("R=%08x %s %s f=%02x",
301 		      __entry->rreq,
302 		      __print_symbolic(__entry->origin, netfs_rreq_origins),
303 		      __print_symbolic(__entry->what, netfs_rreq_traces),
304 		      __entry->flags)
305 	    );
306 
307 TRACE_EVENT(netfs_sreq,
308 	    TP_PROTO(struct netfs_io_subrequest *sreq,
309 		     enum netfs_sreq_trace what),
310 
311 	    TP_ARGS(sreq, what),
312 
313 	    TP_STRUCT__entry(
314 		    __field(unsigned int,		rreq		)
315 		    __field(unsigned short,		index		)
316 		    __field(short,			error		)
317 		    __field(unsigned short,		flags		)
318 		    __field(enum netfs_io_source,	source		)
319 		    __field(enum netfs_sreq_trace,	what		)
320 		    __field(size_t,			len		)
321 		    __field(size_t,			transferred	)
322 		    __field(loff_t,			start		)
323 			     ),
324 
325 	    TP_fast_assign(
326 		    __entry->rreq	= sreq->rreq->debug_id;
327 		    __entry->index	= sreq->debug_index;
328 		    __entry->error	= sreq->error;
329 		    __entry->flags	= sreq->flags;
330 		    __entry->source	= sreq->source;
331 		    __entry->what	= what;
332 		    __entry->len	= sreq->len;
333 		    __entry->transferred = sreq->transferred;
334 		    __entry->start	= sreq->start;
335 			   ),
336 
337 	    TP_printk("R=%08x[%x] %s %s f=%02x s=%llx %zx/%zx e=%d",
338 		      __entry->rreq, __entry->index,
339 		      __print_symbolic(__entry->source, netfs_sreq_sources),
340 		      __print_symbolic(__entry->what, netfs_sreq_traces),
341 		      __entry->flags,
342 		      __entry->start, __entry->transferred, __entry->len,
343 		      __entry->error)
344 	    );
345 
346 TRACE_EVENT(netfs_failure,
347 	    TP_PROTO(struct netfs_io_request *rreq,
348 		     struct netfs_io_subrequest *sreq,
349 		     int error, enum netfs_failure what),
350 
351 	    TP_ARGS(rreq, sreq, error, what),
352 
353 	    TP_STRUCT__entry(
354 		    __field(unsigned int,		rreq		)
355 		    __field(short,			index		)
356 		    __field(short,			error		)
357 		    __field(unsigned short,		flags		)
358 		    __field(enum netfs_io_source,	source		)
359 		    __field(enum netfs_failure,		what		)
360 		    __field(size_t,			len		)
361 		    __field(size_t,			transferred	)
362 		    __field(loff_t,			start		)
363 			     ),
364 
365 	    TP_fast_assign(
366 		    __entry->rreq	= rreq->debug_id;
367 		    __entry->index	= sreq ? sreq->debug_index : -1;
368 		    __entry->error	= error;
369 		    __entry->flags	= sreq ? sreq->flags : 0;
370 		    __entry->source	= sreq ? sreq->source : NETFS_INVALID_READ;
371 		    __entry->what	= what;
372 		    __entry->len	= sreq ? sreq->len : rreq->len;
373 		    __entry->transferred = sreq ? sreq->transferred : 0;
374 		    __entry->start	= sreq ? sreq->start : 0;
375 			   ),
376 
377 	    TP_printk("R=%08x[%x] %s f=%02x s=%llx %zx/%zx %s e=%d",
378 		      __entry->rreq, __entry->index,
379 		      __print_symbolic(__entry->source, netfs_sreq_sources),
380 		      __entry->flags,
381 		      __entry->start, __entry->transferred, __entry->len,
382 		      __print_symbolic(__entry->what, netfs_failures),
383 		      __entry->error)
384 	    );
385 
386 TRACE_EVENT(netfs_rreq_ref,
387 	    TP_PROTO(unsigned int rreq_debug_id, int ref,
388 		     enum netfs_rreq_ref_trace what),
389 
390 	    TP_ARGS(rreq_debug_id, ref, what),
391 
392 	    TP_STRUCT__entry(
393 		    __field(unsigned int,		rreq		)
394 		    __field(int,			ref		)
395 		    __field(enum netfs_rreq_ref_trace,	what		)
396 			     ),
397 
398 	    TP_fast_assign(
399 		    __entry->rreq	= rreq_debug_id;
400 		    __entry->ref	= ref;
401 		    __entry->what	= what;
402 			   ),
403 
404 	    TP_printk("R=%08x %s r=%u",
405 		      __entry->rreq,
406 		      __print_symbolic(__entry->what, netfs_rreq_ref_traces),
407 		      __entry->ref)
408 	    );
409 
410 TRACE_EVENT(netfs_sreq_ref,
411 	    TP_PROTO(unsigned int rreq_debug_id, unsigned int subreq_debug_index,
412 		     int ref, enum netfs_sreq_ref_trace what),
413 
414 	    TP_ARGS(rreq_debug_id, subreq_debug_index, ref, what),
415 
416 	    TP_STRUCT__entry(
417 		    __field(unsigned int,		rreq		)
418 		    __field(unsigned int,		subreq		)
419 		    __field(int,			ref		)
420 		    __field(enum netfs_sreq_ref_trace,	what		)
421 			     ),
422 
423 	    TP_fast_assign(
424 		    __entry->rreq	= rreq_debug_id;
425 		    __entry->subreq	= subreq_debug_index;
426 		    __entry->ref	= ref;
427 		    __entry->what	= what;
428 			   ),
429 
430 	    TP_printk("R=%08x[%x] %s r=%u",
431 		      __entry->rreq,
432 		      __entry->subreq,
433 		      __print_symbolic(__entry->what, netfs_sreq_ref_traces),
434 		      __entry->ref)
435 	    );
436 
437 TRACE_EVENT(netfs_folio,
438 	    TP_PROTO(struct folio *folio, enum netfs_folio_trace why),
439 
440 	    TP_ARGS(folio, why),
441 
442 	    TP_STRUCT__entry(
443 		    __field(ino_t,			ino)
444 		    __field(pgoff_t,			index)
445 		    __field(unsigned int,		nr)
446 		    __field(enum netfs_folio_trace,	why)
447 			     ),
448 
449 	    TP_fast_assign(
450 		    struct address_space *__m = READ_ONCE(folio->mapping);
451 		    __entry->ino = __m ? __m->host->i_ino : 0;
452 		    __entry->why = why;
453 		    __entry->index = folio_index(folio);
454 		    __entry->nr = folio_nr_pages(folio);
455 			   ),
456 
457 	    TP_printk("i=%05lx ix=%05lx-%05lx %s",
458 		      __entry->ino, __entry->index, __entry->index + __entry->nr - 1,
459 		      __print_symbolic(__entry->why, netfs_folio_traces))
460 	    );
461 
462 TRACE_EVENT(netfs_write_iter,
463 	    TP_PROTO(const struct kiocb *iocb, const struct iov_iter *from),
464 
465 	    TP_ARGS(iocb, from),
466 
467 	    TP_STRUCT__entry(
468 		    __field(unsigned long long,		start		)
469 		    __field(size_t,			len		)
470 		    __field(unsigned int,		flags		)
471 		    __field(unsigned int,		ino		)
472 			     ),
473 
474 	    TP_fast_assign(
475 		    __entry->start	= iocb->ki_pos;
476 		    __entry->len	= iov_iter_count(from);
477 		    __entry->ino	= iocb->ki_filp->f_inode->i_ino;
478 		    __entry->flags	= iocb->ki_flags;
479 			   ),
480 
481 	    TP_printk("WRITE-ITER i=%x s=%llx l=%zx f=%x",
482 		      __entry->ino, __entry->start, __entry->len, __entry->flags)
483 	    );
484 
485 TRACE_EVENT(netfs_write,
486 	    TP_PROTO(const struct netfs_io_request *wreq,
487 		     enum netfs_write_trace what),
488 
489 	    TP_ARGS(wreq, what),
490 
491 	    TP_STRUCT__entry(
492 		    __field(unsigned int,		wreq		)
493 		    __field(unsigned int,		cookie		)
494 		    __field(unsigned int,		ino		)
495 		    __field(enum netfs_write_trace,	what		)
496 		    __field(unsigned long long,		start		)
497 		    __field(unsigned long long,		len		)
498 			     ),
499 
500 	    TP_fast_assign(
501 		    struct netfs_inode *__ctx = netfs_inode(wreq->inode);
502 		    struct fscache_cookie *__cookie = netfs_i_cookie(__ctx);
503 		    __entry->wreq	= wreq->debug_id;
504 		    __entry->cookie	= __cookie ? __cookie->debug_id : 0;
505 		    __entry->ino	= wreq->inode->i_ino;
506 		    __entry->what	= what;
507 		    __entry->start	= wreq->start;
508 		    __entry->len	= wreq->len;
509 			   ),
510 
511 	    TP_printk("R=%08x %s c=%08x i=%x by=%llx-%llx",
512 		      __entry->wreq,
513 		      __print_symbolic(__entry->what, netfs_write_traces),
514 		      __entry->cookie,
515 		      __entry->ino,
516 		      __entry->start, __entry->start + __entry->len - 1)
517 	    );
518 
519 TRACE_EVENT(netfs_collect,
520 	    TP_PROTO(const struct netfs_io_request *wreq),
521 
522 	    TP_ARGS(wreq),
523 
524 	    TP_STRUCT__entry(
525 		    __field(unsigned int,		wreq		)
526 		    __field(unsigned int,		len		)
527 		    __field(unsigned long long,		transferred	)
528 		    __field(unsigned long long,		start		)
529 			     ),
530 
531 	    TP_fast_assign(
532 		    __entry->wreq	= wreq->debug_id;
533 		    __entry->start	= wreq->start;
534 		    __entry->len	= wreq->len;
535 		    __entry->transferred = wreq->transferred;
536 			   ),
537 
538 	    TP_printk("R=%08x s=%llx-%llx",
539 		      __entry->wreq,
540 		      __entry->start + __entry->transferred,
541 		      __entry->start + __entry->len)
542 	    );
543 
544 TRACE_EVENT(netfs_collect_sreq,
545 	    TP_PROTO(const struct netfs_io_request *wreq,
546 		     const struct netfs_io_subrequest *subreq),
547 
548 	    TP_ARGS(wreq, subreq),
549 
550 	    TP_STRUCT__entry(
551 		    __field(unsigned int,		wreq		)
552 		    __field(unsigned int,		subreq		)
553 		    __field(unsigned int,		stream		)
554 		    __field(unsigned int,		len		)
555 		    __field(unsigned int,		transferred	)
556 		    __field(unsigned long long,		start		)
557 			     ),
558 
559 	    TP_fast_assign(
560 		    __entry->wreq	= wreq->debug_id;
561 		    __entry->subreq	= subreq->debug_index;
562 		    __entry->stream	= subreq->stream_nr;
563 		    __entry->start	= subreq->start;
564 		    __entry->len	= subreq->len;
565 		    __entry->transferred = subreq->transferred;
566 			   ),
567 
568 	    TP_printk("R=%08x[%u:%02x] s=%llx t=%x/%x",
569 		      __entry->wreq, __entry->stream, __entry->subreq,
570 		      __entry->start, __entry->transferred, __entry->len)
571 	    );
572 
573 TRACE_EVENT(netfs_collect_folio,
574 	    TP_PROTO(const struct netfs_io_request *wreq,
575 		     const struct folio *folio,
576 		     unsigned long long fend,
577 		     unsigned long long collected_to),
578 
579 	    TP_ARGS(wreq, folio, fend, collected_to),
580 
581 	    TP_STRUCT__entry(
582 		    __field(unsigned int,	wreq		)
583 		    __field(unsigned long,	index		)
584 		    __field(unsigned long long,	fend		)
585 		    __field(unsigned long long,	cleaned_to	)
586 		    __field(unsigned long long,	collected_to	)
587 			     ),
588 
589 	    TP_fast_assign(
590 		    __entry->wreq	= wreq->debug_id;
591 		    __entry->index	= folio->index;
592 		    __entry->fend	= fend;
593 		    __entry->cleaned_to	= wreq->cleaned_to;
594 		    __entry->collected_to = collected_to;
595 			   ),
596 
597 	    TP_printk("R=%08x ix=%05lx r=%llx-%llx t=%llx/%llx",
598 		      __entry->wreq, __entry->index,
599 		      (unsigned long long)__entry->index * PAGE_SIZE, __entry->fend,
600 		      __entry->cleaned_to, __entry->collected_to)
601 	    );
602 
603 TRACE_EVENT(netfs_collect_state,
604 	    TP_PROTO(const struct netfs_io_request *wreq,
605 		     unsigned long long collected_to,
606 		     unsigned int notes),
607 
608 	    TP_ARGS(wreq, collected_to, notes),
609 
610 	    TP_STRUCT__entry(
611 		    __field(unsigned int,	wreq		)
612 		    __field(unsigned int,	notes		)
613 		    __field(unsigned long long,	collected_to	)
614 		    __field(unsigned long long,	cleaned_to	)
615 			     ),
616 
617 	    TP_fast_assign(
618 		    __entry->wreq	= wreq->debug_id;
619 		    __entry->notes	= notes;
620 		    __entry->collected_to = collected_to;
621 		    __entry->cleaned_to	= wreq->cleaned_to;
622 			   ),
623 
624 	    TP_printk("R=%08x col=%llx cln=%llx n=%x",
625 		      __entry->wreq, __entry->collected_to,
626 		      __entry->cleaned_to,
627 		      __entry->notes)
628 	    );
629 
630 TRACE_EVENT(netfs_collect_gap,
631 	    TP_PROTO(const struct netfs_io_request *wreq,
632 		     const struct netfs_io_stream *stream,
633 		     unsigned long long jump_to, char type),
634 
635 	    TP_ARGS(wreq, stream, jump_to, type),
636 
637 	    TP_STRUCT__entry(
638 		    __field(unsigned int,	wreq)
639 		    __field(unsigned char,	stream)
640 		    __field(unsigned char,	type)
641 		    __field(unsigned long long,	from)
642 		    __field(unsigned long long,	to)
643 			     ),
644 
645 	    TP_fast_assign(
646 		    __entry->wreq	= wreq->debug_id;
647 		    __entry->stream	= stream->stream_nr;
648 		    __entry->from	= stream->collected_to;
649 		    __entry->to		= jump_to;
650 		    __entry->type	= type;
651 			   ),
652 
653 	    TP_printk("R=%08x[%x:] %llx->%llx %c",
654 		      __entry->wreq, __entry->stream,
655 		      __entry->from, __entry->to, __entry->type)
656 	    );
657 
658 TRACE_EVENT(netfs_collect_stream,
659 	    TP_PROTO(const struct netfs_io_request *wreq,
660 		     const struct netfs_io_stream *stream),
661 
662 	    TP_ARGS(wreq, stream),
663 
664 	    TP_STRUCT__entry(
665 		    __field(unsigned int,	wreq)
666 		    __field(unsigned char,	stream)
667 		    __field(unsigned long long,	collected_to)
668 		    __field(unsigned long long,	front)
669 			     ),
670 
671 	    TP_fast_assign(
672 		    __entry->wreq	= wreq->debug_id;
673 		    __entry->stream	= stream->stream_nr;
674 		    __entry->collected_to = stream->collected_to;
675 		    __entry->front	= stream->front ? stream->front->start : UINT_MAX;
676 			   ),
677 
678 	    TP_printk("R=%08x[%x:] cto=%llx frn=%llx",
679 		      __entry->wreq, __entry->stream,
680 		      __entry->collected_to, __entry->front)
681 	    );
682 
683 TRACE_EVENT(netfs_progress,
684 	    TP_PROTO(const struct netfs_io_subrequest *subreq,
685 		     unsigned long long start, size_t avail, size_t part),
686 
687 	    TP_ARGS(subreq, start, avail, part),
688 
689 	    TP_STRUCT__entry(
690 		    __field(unsigned int,		rreq)
691 		    __field(unsigned int,		subreq)
692 		    __field(unsigned int,		consumed)
693 		    __field(unsigned int,		transferred)
694 		    __field(unsigned long long,		f_start)
695 		    __field(unsigned int,		f_avail)
696 		    __field(unsigned int,		f_part)
697 		    __field(unsigned char,		slot)
698 			     ),
699 
700 	    TP_fast_assign(
701 		    __entry->rreq	= subreq->rreq->debug_id;
702 		    __entry->subreq	= subreq->debug_index;
703 		    __entry->consumed	= subreq->consumed;
704 		    __entry->transferred = subreq->transferred;
705 		    __entry->f_start	= start;
706 		    __entry->f_avail	= avail;
707 		    __entry->f_part	= part;
708 		    __entry->slot	= subreq->curr_folioq_slot;
709 			   ),
710 
711 	    TP_printk("R=%08x[%02x] s=%llx ct=%x/%x pa=%x/%x sl=%x",
712 		      __entry->rreq, __entry->subreq, __entry->f_start,
713 		      __entry->consumed, __entry->transferred,
714 		      __entry->f_part, __entry->f_avail,  __entry->slot)
715 	    );
716 
717 TRACE_EVENT(netfs_donate,
718 	    TP_PROTO(const struct netfs_io_request *rreq,
719 		     const struct netfs_io_subrequest *from,
720 		     const struct netfs_io_subrequest *to,
721 		     size_t amount,
722 		     enum netfs_donate_trace trace),
723 
724 	    TP_ARGS(rreq, from, to, amount, trace),
725 
726 	    TP_STRUCT__entry(
727 		    __field(unsigned int,		rreq)
728 		    __field(unsigned int,		from)
729 		    __field(unsigned int,		to)
730 		    __field(unsigned int,		amount)
731 		    __field(enum netfs_donate_trace,	trace)
732 			     ),
733 
734 	    TP_fast_assign(
735 		    __entry->rreq	= rreq->debug_id;
736 		    __entry->from	= from->debug_index;
737 		    __entry->to		= to ? to->debug_index : -1;
738 		    __entry->amount	= amount;
739 		    __entry->trace	= trace;
740 			   ),
741 
742 	    TP_printk("R=%08x[%02x] -> [%02x] %s am=%x",
743 		      __entry->rreq, __entry->from, __entry->to,
744 		      __print_symbolic(__entry->trace, netfs_donate_traces),
745 		      __entry->amount)
746 	    );
747 
748 #undef EM
749 #undef E_
750 #endif /* _TRACE_NETFS_H */
751 
752 /* This part must be outside protection */
753 #include <trace/define_trace.h>
754