xref: /linux/include/trace/events/netfs.h (revision 55d0969c451159cff86949b38c39171cab962069)
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_put,		"read-put")	\
176 	EM(netfs_folio_trace_read_unlock,	"read-unlock")	\
177 	EM(netfs_folio_trace_redirtied,		"redirtied")	\
178 	EM(netfs_folio_trace_store,		"store")	\
179 	EM(netfs_folio_trace_store_copy,	"store-copy")	\
180 	EM(netfs_folio_trace_store_plus,	"store+")	\
181 	EM(netfs_folio_trace_wthru,		"wthru")	\
182 	E_(netfs_folio_trace_wthru_plus,	"wthru+")
183 
184 #define netfs_collect_contig_traces				\
185 	EM(netfs_contig_trace_collect,		"Collect")	\
186 	EM(netfs_contig_trace_jump,		"-->JUMP-->")	\
187 	E_(netfs_contig_trace_unlock,		"Unlock")
188 
189 #define netfs_donate_traces					\
190 	EM(netfs_trace_donate_tail_to_prev,	"tail-to-prev")	\
191 	EM(netfs_trace_donate_to_prev,		"to-prev")	\
192 	EM(netfs_trace_donate_to_next,		"to-next")	\
193 	E_(netfs_trace_donate_to_deferred_next,	"defer-next")
194 
195 #ifndef __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY
196 #define __NETFS_DECLARE_TRACE_ENUMS_ONCE_ONLY
197 
198 #undef EM
199 #undef E_
200 #define EM(a, b) a,
201 #define E_(a, b) a
202 
203 enum netfs_read_trace { netfs_read_traces } __mode(byte);
204 enum netfs_write_trace { netfs_write_traces } __mode(byte);
205 enum netfs_rreq_trace { netfs_rreq_traces } __mode(byte);
206 enum netfs_sreq_trace { netfs_sreq_traces } __mode(byte);
207 enum netfs_failure { netfs_failures } __mode(byte);
208 enum netfs_rreq_ref_trace { netfs_rreq_ref_traces } __mode(byte);
209 enum netfs_sreq_ref_trace { netfs_sreq_ref_traces } __mode(byte);
210 enum netfs_folio_trace { netfs_folio_traces } __mode(byte);
211 enum netfs_collect_contig_trace { netfs_collect_contig_traces } __mode(byte);
212 enum netfs_donate_trace { netfs_donate_traces } __mode(byte);
213 
214 #endif
215 
216 /*
217  * Export enum symbols via userspace.
218  */
219 #undef EM
220 #undef E_
221 #define EM(a, b) TRACE_DEFINE_ENUM(a);
222 #define E_(a, b) TRACE_DEFINE_ENUM(a);
223 
224 netfs_read_traces;
225 netfs_write_traces;
226 netfs_rreq_origins;
227 netfs_rreq_traces;
228 netfs_sreq_sources;
229 netfs_sreq_traces;
230 netfs_failures;
231 netfs_rreq_ref_traces;
232 netfs_sreq_ref_traces;
233 netfs_folio_traces;
234 netfs_collect_contig_traces;
235 netfs_donate_traces;
236 
237 /*
238  * Now redefine the EM() and E_() macros to map the enums to the strings that
239  * will be printed in the output.
240  */
241 #undef EM
242 #undef E_
243 #define EM(a, b)	{ a, b },
244 #define E_(a, b)	{ a, b }
245 
246 TRACE_EVENT(netfs_read,
247 	    TP_PROTO(struct netfs_io_request *rreq,
248 		     loff_t start, size_t len,
249 		     enum netfs_read_trace what),
250 
251 	    TP_ARGS(rreq, start, len, what),
252 
253 	    TP_STRUCT__entry(
254 		    __field(unsigned int,		rreq		)
255 		    __field(unsigned int,		cookie		)
256 		    __field(loff_t,			i_size		)
257 		    __field(loff_t,			start		)
258 		    __field(size_t,			len		)
259 		    __field(enum netfs_read_trace,	what		)
260 		    __field(unsigned int,		netfs_inode	)
261 			     ),
262 
263 	    TP_fast_assign(
264 		    __entry->rreq	= rreq->debug_id;
265 		    __entry->cookie	= rreq->cache_resources.debug_id;
266 		    __entry->i_size	= rreq->i_size;
267 		    __entry->start	= start;
268 		    __entry->len	= len;
269 		    __entry->what	= what;
270 		    __entry->netfs_inode = rreq->inode->i_ino;
271 			   ),
272 
273 	    TP_printk("R=%08x %s c=%08x ni=%x s=%llx l=%zx sz=%llx",
274 		      __entry->rreq,
275 		      __print_symbolic(__entry->what, netfs_read_traces),
276 		      __entry->cookie,
277 		      __entry->netfs_inode,
278 		      __entry->start, __entry->len, __entry->i_size)
279 	    );
280 
281 TRACE_EVENT(netfs_rreq,
282 	    TP_PROTO(struct netfs_io_request *rreq,
283 		     enum netfs_rreq_trace what),
284 
285 	    TP_ARGS(rreq, what),
286 
287 	    TP_STRUCT__entry(
288 		    __field(unsigned int,		rreq		)
289 		    __field(unsigned int,		flags		)
290 		    __field(enum netfs_io_origin,	origin		)
291 		    __field(enum netfs_rreq_trace,	what		)
292 			     ),
293 
294 	    TP_fast_assign(
295 		    __entry->rreq	= rreq->debug_id;
296 		    __entry->flags	= rreq->flags;
297 		    __entry->origin	= rreq->origin;
298 		    __entry->what	= what;
299 			   ),
300 
301 	    TP_printk("R=%08x %s %s f=%02x",
302 		      __entry->rreq,
303 		      __print_symbolic(__entry->origin, netfs_rreq_origins),
304 		      __print_symbolic(__entry->what, netfs_rreq_traces),
305 		      __entry->flags)
306 	    );
307 
308 TRACE_EVENT(netfs_sreq,
309 	    TP_PROTO(struct netfs_io_subrequest *sreq,
310 		     enum netfs_sreq_trace what),
311 
312 	    TP_ARGS(sreq, what),
313 
314 	    TP_STRUCT__entry(
315 		    __field(unsigned int,		rreq		)
316 		    __field(unsigned short,		index		)
317 		    __field(short,			error		)
318 		    __field(unsigned short,		flags		)
319 		    __field(enum netfs_io_source,	source		)
320 		    __field(enum netfs_sreq_trace,	what		)
321 		    __field(size_t,			len		)
322 		    __field(size_t,			transferred	)
323 		    __field(loff_t,			start		)
324 			     ),
325 
326 	    TP_fast_assign(
327 		    __entry->rreq	= sreq->rreq->debug_id;
328 		    __entry->index	= sreq->debug_index;
329 		    __entry->error	= sreq->error;
330 		    __entry->flags	= sreq->flags;
331 		    __entry->source	= sreq->source;
332 		    __entry->what	= what;
333 		    __entry->len	= sreq->len;
334 		    __entry->transferred = sreq->transferred;
335 		    __entry->start	= sreq->start;
336 			   ),
337 
338 	    TP_printk("R=%08x[%x] %s %s f=%02x s=%llx %zx/%zx e=%d",
339 		      __entry->rreq, __entry->index,
340 		      __print_symbolic(__entry->source, netfs_sreq_sources),
341 		      __print_symbolic(__entry->what, netfs_sreq_traces),
342 		      __entry->flags,
343 		      __entry->start, __entry->transferred, __entry->len,
344 		      __entry->error)
345 	    );
346 
347 TRACE_EVENT(netfs_failure,
348 	    TP_PROTO(struct netfs_io_request *rreq,
349 		     struct netfs_io_subrequest *sreq,
350 		     int error, enum netfs_failure what),
351 
352 	    TP_ARGS(rreq, sreq, error, what),
353 
354 	    TP_STRUCT__entry(
355 		    __field(unsigned int,		rreq		)
356 		    __field(short,			index		)
357 		    __field(short,			error		)
358 		    __field(unsigned short,		flags		)
359 		    __field(enum netfs_io_source,	source		)
360 		    __field(enum netfs_failure,		what		)
361 		    __field(size_t,			len		)
362 		    __field(size_t,			transferred	)
363 		    __field(loff_t,			start		)
364 			     ),
365 
366 	    TP_fast_assign(
367 		    __entry->rreq	= rreq->debug_id;
368 		    __entry->index	= sreq ? sreq->debug_index : -1;
369 		    __entry->error	= error;
370 		    __entry->flags	= sreq ? sreq->flags : 0;
371 		    __entry->source	= sreq ? sreq->source : NETFS_INVALID_READ;
372 		    __entry->what	= what;
373 		    __entry->len	= sreq ? sreq->len : rreq->len;
374 		    __entry->transferred = sreq ? sreq->transferred : 0;
375 		    __entry->start	= sreq ? sreq->start : 0;
376 			   ),
377 
378 	    TP_printk("R=%08x[%x] %s f=%02x s=%llx %zx/%zx %s e=%d",
379 		      __entry->rreq, __entry->index,
380 		      __print_symbolic(__entry->source, netfs_sreq_sources),
381 		      __entry->flags,
382 		      __entry->start, __entry->transferred, __entry->len,
383 		      __print_symbolic(__entry->what, netfs_failures),
384 		      __entry->error)
385 	    );
386 
387 TRACE_EVENT(netfs_rreq_ref,
388 	    TP_PROTO(unsigned int rreq_debug_id, int ref,
389 		     enum netfs_rreq_ref_trace what),
390 
391 	    TP_ARGS(rreq_debug_id, ref, what),
392 
393 	    TP_STRUCT__entry(
394 		    __field(unsigned int,		rreq		)
395 		    __field(int,			ref		)
396 		    __field(enum netfs_rreq_ref_trace,	what		)
397 			     ),
398 
399 	    TP_fast_assign(
400 		    __entry->rreq	= rreq_debug_id;
401 		    __entry->ref	= ref;
402 		    __entry->what	= what;
403 			   ),
404 
405 	    TP_printk("R=%08x %s r=%u",
406 		      __entry->rreq,
407 		      __print_symbolic(__entry->what, netfs_rreq_ref_traces),
408 		      __entry->ref)
409 	    );
410 
411 TRACE_EVENT(netfs_sreq_ref,
412 	    TP_PROTO(unsigned int rreq_debug_id, unsigned int subreq_debug_index,
413 		     int ref, enum netfs_sreq_ref_trace what),
414 
415 	    TP_ARGS(rreq_debug_id, subreq_debug_index, ref, what),
416 
417 	    TP_STRUCT__entry(
418 		    __field(unsigned int,		rreq		)
419 		    __field(unsigned int,		subreq		)
420 		    __field(int,			ref		)
421 		    __field(enum netfs_sreq_ref_trace,	what		)
422 			     ),
423 
424 	    TP_fast_assign(
425 		    __entry->rreq	= rreq_debug_id;
426 		    __entry->subreq	= subreq_debug_index;
427 		    __entry->ref	= ref;
428 		    __entry->what	= what;
429 			   ),
430 
431 	    TP_printk("R=%08x[%x] %s r=%u",
432 		      __entry->rreq,
433 		      __entry->subreq,
434 		      __print_symbolic(__entry->what, netfs_sreq_ref_traces),
435 		      __entry->ref)
436 	    );
437 
438 TRACE_EVENT(netfs_folio,
439 	    TP_PROTO(struct folio *folio, enum netfs_folio_trace why),
440 
441 	    TP_ARGS(folio, why),
442 
443 	    TP_STRUCT__entry(
444 		    __field(ino_t,			ino)
445 		    __field(pgoff_t,			index)
446 		    __field(unsigned int,		nr)
447 		    __field(enum netfs_folio_trace,	why)
448 			     ),
449 
450 	    TP_fast_assign(
451 		    struct address_space *__m = READ_ONCE(folio->mapping);
452 		    __entry->ino = __m ? __m->host->i_ino : 0;
453 		    __entry->why = why;
454 		    __entry->index = folio_index(folio);
455 		    __entry->nr = folio_nr_pages(folio);
456 			   ),
457 
458 	    TP_printk("i=%05lx ix=%05lx-%05lx %s",
459 		      __entry->ino, __entry->index, __entry->index + __entry->nr - 1,
460 		      __print_symbolic(__entry->why, netfs_folio_traces))
461 	    );
462 
463 TRACE_EVENT(netfs_write_iter,
464 	    TP_PROTO(const struct kiocb *iocb, const struct iov_iter *from),
465 
466 	    TP_ARGS(iocb, from),
467 
468 	    TP_STRUCT__entry(
469 		    __field(unsigned long long,		start		)
470 		    __field(size_t,			len		)
471 		    __field(unsigned int,		flags		)
472 		    __field(unsigned int,		ino		)
473 			     ),
474 
475 	    TP_fast_assign(
476 		    __entry->start	= iocb->ki_pos;
477 		    __entry->len	= iov_iter_count(from);
478 		    __entry->ino	= iocb->ki_filp->f_inode->i_ino;
479 		    __entry->flags	= iocb->ki_flags;
480 			   ),
481 
482 	    TP_printk("WRITE-ITER i=%x s=%llx l=%zx f=%x",
483 		      __entry->ino, __entry->start, __entry->len, __entry->flags)
484 	    );
485 
486 TRACE_EVENT(netfs_write,
487 	    TP_PROTO(const struct netfs_io_request *wreq,
488 		     enum netfs_write_trace what),
489 
490 	    TP_ARGS(wreq, what),
491 
492 	    TP_STRUCT__entry(
493 		    __field(unsigned int,		wreq		)
494 		    __field(unsigned int,		cookie		)
495 		    __field(unsigned int,		ino		)
496 		    __field(enum netfs_write_trace,	what		)
497 		    __field(unsigned long long,		start		)
498 		    __field(unsigned long long,		len		)
499 			     ),
500 
501 	    TP_fast_assign(
502 		    struct netfs_inode *__ctx = netfs_inode(wreq->inode);
503 		    struct fscache_cookie *__cookie = netfs_i_cookie(__ctx);
504 		    __entry->wreq	= wreq->debug_id;
505 		    __entry->cookie	= __cookie ? __cookie->debug_id : 0;
506 		    __entry->ino	= wreq->inode->i_ino;
507 		    __entry->what	= what;
508 		    __entry->start	= wreq->start;
509 		    __entry->len	= wreq->len;
510 			   ),
511 
512 	    TP_printk("R=%08x %s c=%08x i=%x by=%llx-%llx",
513 		      __entry->wreq,
514 		      __print_symbolic(__entry->what, netfs_write_traces),
515 		      __entry->cookie,
516 		      __entry->ino,
517 		      __entry->start, __entry->start + __entry->len - 1)
518 	    );
519 
520 TRACE_EVENT(netfs_collect,
521 	    TP_PROTO(const struct netfs_io_request *wreq),
522 
523 	    TP_ARGS(wreq),
524 
525 	    TP_STRUCT__entry(
526 		    __field(unsigned int,		wreq		)
527 		    __field(unsigned int,		len		)
528 		    __field(unsigned long long,		transferred	)
529 		    __field(unsigned long long,		start		)
530 			     ),
531 
532 	    TP_fast_assign(
533 		    __entry->wreq	= wreq->debug_id;
534 		    __entry->start	= wreq->start;
535 		    __entry->len	= wreq->len;
536 		    __entry->transferred = wreq->transferred;
537 			   ),
538 
539 	    TP_printk("R=%08x s=%llx-%llx",
540 		      __entry->wreq,
541 		      __entry->start + __entry->transferred,
542 		      __entry->start + __entry->len)
543 	    );
544 
545 TRACE_EVENT(netfs_collect_sreq,
546 	    TP_PROTO(const struct netfs_io_request *wreq,
547 		     const struct netfs_io_subrequest *subreq),
548 
549 	    TP_ARGS(wreq, subreq),
550 
551 	    TP_STRUCT__entry(
552 		    __field(unsigned int,		wreq		)
553 		    __field(unsigned int,		subreq		)
554 		    __field(unsigned int,		stream		)
555 		    __field(unsigned int,		len		)
556 		    __field(unsigned int,		transferred	)
557 		    __field(unsigned long long,		start		)
558 			     ),
559 
560 	    TP_fast_assign(
561 		    __entry->wreq	= wreq->debug_id;
562 		    __entry->subreq	= subreq->debug_index;
563 		    __entry->stream	= subreq->stream_nr;
564 		    __entry->start	= subreq->start;
565 		    __entry->len	= subreq->len;
566 		    __entry->transferred = subreq->transferred;
567 			   ),
568 
569 	    TP_printk("R=%08x[%u:%02x] s=%llx t=%x/%x",
570 		      __entry->wreq, __entry->stream, __entry->subreq,
571 		      __entry->start, __entry->transferred, __entry->len)
572 	    );
573 
574 TRACE_EVENT(netfs_collect_folio,
575 	    TP_PROTO(const struct netfs_io_request *wreq,
576 		     const struct folio *folio,
577 		     unsigned long long fend,
578 		     unsigned long long collected_to),
579 
580 	    TP_ARGS(wreq, folio, fend, collected_to),
581 
582 	    TP_STRUCT__entry(
583 		    __field(unsigned int,	wreq		)
584 		    __field(unsigned long,	index		)
585 		    __field(unsigned long long,	fend		)
586 		    __field(unsigned long long,	cleaned_to	)
587 		    __field(unsigned long long,	collected_to	)
588 			     ),
589 
590 	    TP_fast_assign(
591 		    __entry->wreq	= wreq->debug_id;
592 		    __entry->index	= folio->index;
593 		    __entry->fend	= fend;
594 		    __entry->cleaned_to	= wreq->cleaned_to;
595 		    __entry->collected_to = collected_to;
596 			   ),
597 
598 	    TP_printk("R=%08x ix=%05lx r=%llx-%llx t=%llx/%llx",
599 		      __entry->wreq, __entry->index,
600 		      (unsigned long long)__entry->index * PAGE_SIZE, __entry->fend,
601 		      __entry->cleaned_to, __entry->collected_to)
602 	    );
603 
604 TRACE_EVENT(netfs_collect_state,
605 	    TP_PROTO(const struct netfs_io_request *wreq,
606 		     unsigned long long collected_to,
607 		     unsigned int notes),
608 
609 	    TP_ARGS(wreq, collected_to, notes),
610 
611 	    TP_STRUCT__entry(
612 		    __field(unsigned int,	wreq		)
613 		    __field(unsigned int,	notes		)
614 		    __field(unsigned long long,	collected_to	)
615 		    __field(unsigned long long,	cleaned_to	)
616 			     ),
617 
618 	    TP_fast_assign(
619 		    __entry->wreq	= wreq->debug_id;
620 		    __entry->notes	= notes;
621 		    __entry->collected_to = collected_to;
622 		    __entry->cleaned_to	= wreq->cleaned_to;
623 			   ),
624 
625 	    TP_printk("R=%08x col=%llx cln=%llx n=%x",
626 		      __entry->wreq, __entry->collected_to,
627 		      __entry->cleaned_to,
628 		      __entry->notes)
629 	    );
630 
631 TRACE_EVENT(netfs_collect_gap,
632 	    TP_PROTO(const struct netfs_io_request *wreq,
633 		     const struct netfs_io_stream *stream,
634 		     unsigned long long jump_to, char type),
635 
636 	    TP_ARGS(wreq, stream, jump_to, type),
637 
638 	    TP_STRUCT__entry(
639 		    __field(unsigned int,	wreq)
640 		    __field(unsigned char,	stream)
641 		    __field(unsigned char,	type)
642 		    __field(unsigned long long,	from)
643 		    __field(unsigned long long,	to)
644 			     ),
645 
646 	    TP_fast_assign(
647 		    __entry->wreq	= wreq->debug_id;
648 		    __entry->stream	= stream->stream_nr;
649 		    __entry->from	= stream->collected_to;
650 		    __entry->to		= jump_to;
651 		    __entry->type	= type;
652 			   ),
653 
654 	    TP_printk("R=%08x[%x:] %llx->%llx %c",
655 		      __entry->wreq, __entry->stream,
656 		      __entry->from, __entry->to, __entry->type)
657 	    );
658 
659 TRACE_EVENT(netfs_collect_stream,
660 	    TP_PROTO(const struct netfs_io_request *wreq,
661 		     const struct netfs_io_stream *stream),
662 
663 	    TP_ARGS(wreq, stream),
664 
665 	    TP_STRUCT__entry(
666 		    __field(unsigned int,	wreq)
667 		    __field(unsigned char,	stream)
668 		    __field(unsigned long long,	collected_to)
669 		    __field(unsigned long long,	front)
670 			     ),
671 
672 	    TP_fast_assign(
673 		    __entry->wreq	= wreq->debug_id;
674 		    __entry->stream	= stream->stream_nr;
675 		    __entry->collected_to = stream->collected_to;
676 		    __entry->front	= stream->front ? stream->front->start : UINT_MAX;
677 			   ),
678 
679 	    TP_printk("R=%08x[%x:] cto=%llx frn=%llx",
680 		      __entry->wreq, __entry->stream,
681 		      __entry->collected_to, __entry->front)
682 	    );
683 
684 TRACE_EVENT(netfs_progress,
685 	    TP_PROTO(const struct netfs_io_subrequest *subreq,
686 		     unsigned long long start, size_t avail, size_t part),
687 
688 	    TP_ARGS(subreq, start, avail, part),
689 
690 	    TP_STRUCT__entry(
691 		    __field(unsigned int,		rreq)
692 		    __field(unsigned int,		subreq)
693 		    __field(unsigned int,		consumed)
694 		    __field(unsigned int,		transferred)
695 		    __field(unsigned long long,		f_start)
696 		    __field(unsigned int,		f_avail)
697 		    __field(unsigned int,		f_part)
698 		    __field(unsigned char,		slot)
699 			     ),
700 
701 	    TP_fast_assign(
702 		    __entry->rreq	= subreq->rreq->debug_id;
703 		    __entry->subreq	= subreq->debug_index;
704 		    __entry->consumed	= subreq->consumed;
705 		    __entry->transferred = subreq->transferred;
706 		    __entry->f_start	= start;
707 		    __entry->f_avail	= avail;
708 		    __entry->f_part	= part;
709 		    __entry->slot	= subreq->curr_folioq_slot;
710 			   ),
711 
712 	    TP_printk("R=%08x[%02x] s=%llx ct=%x/%x pa=%x/%x sl=%x",
713 		      __entry->rreq, __entry->subreq, __entry->f_start,
714 		      __entry->consumed, __entry->transferred,
715 		      __entry->f_part, __entry->f_avail,  __entry->slot)
716 	    );
717 
718 TRACE_EVENT(netfs_donate,
719 	    TP_PROTO(const struct netfs_io_request *rreq,
720 		     const struct netfs_io_subrequest *from,
721 		     const struct netfs_io_subrequest *to,
722 		     size_t amount,
723 		     enum netfs_donate_trace trace),
724 
725 	    TP_ARGS(rreq, from, to, amount, trace),
726 
727 	    TP_STRUCT__entry(
728 		    __field(unsigned int,		rreq)
729 		    __field(unsigned int,		from)
730 		    __field(unsigned int,		to)
731 		    __field(unsigned int,		amount)
732 		    __field(enum netfs_donate_trace,	trace)
733 			     ),
734 
735 	    TP_fast_assign(
736 		    __entry->rreq	= rreq->debug_id;
737 		    __entry->from	= from->debug_index;
738 		    __entry->to		= to ? to->debug_index : -1;
739 		    __entry->amount	= amount;
740 		    __entry->trace	= trace;
741 			   ),
742 
743 	    TP_printk("R=%08x[%02x] -> [%02x] %s am=%x",
744 		      __entry->rreq, __entry->from, __entry->to,
745 		      __print_symbolic(__entry->trace, netfs_donate_traces),
746 		      __entry->amount)
747 	    );
748 
749 #undef EM
750 #undef E_
751 #endif /* _TRACE_NETFS_H */
752 
753 /* This part must be outside protection */
754 #include <trace/define_trace.h>
755