xref: /openbmc/linux/fs/xfs/scrub/trace.h (revision a3fad2e9)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2017-2023 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <djwong@kernel.org>
5  *
6  * NOTE: none of these tracepoints shall be considered a stable kernel ABI
7  * as they can change at any time.  See xfs_trace.h for documentation of
8  * specific units found in tracepoint output.
9  */
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM xfs_scrub
12 
13 #if !defined(_TRACE_XFS_SCRUB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
14 #define _TRACE_XFS_SCRUB_TRACE_H
15 
16 #include <linux/tracepoint.h>
17 #include "xfs_bit.h"
18 
19 struct xfile;
20 struct xfarray;
21 struct xfarray_sortinfo;
22 
23 /*
24  * ftrace's __print_symbolic requires that all enum values be wrapped in the
25  * TRACE_DEFINE_ENUM macro so that the enum value can be encoded in the ftrace
26  * ring buffer.  Somehow this was only worth mentioning in the ftrace sample
27  * code.
28  */
29 TRACE_DEFINE_ENUM(XFS_BTNUM_BNOi);
30 TRACE_DEFINE_ENUM(XFS_BTNUM_CNTi);
31 TRACE_DEFINE_ENUM(XFS_BTNUM_BMAPi);
32 TRACE_DEFINE_ENUM(XFS_BTNUM_INOi);
33 TRACE_DEFINE_ENUM(XFS_BTNUM_FINOi);
34 TRACE_DEFINE_ENUM(XFS_BTNUM_RMAPi);
35 TRACE_DEFINE_ENUM(XFS_BTNUM_REFCi);
36 
37 TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_SHARED);
38 TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_COW);
39 
40 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PROBE);
41 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SB);
42 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGF);
43 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGFL);
44 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGI);
45 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BNOBT);
46 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_CNTBT);
47 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INOBT);
48 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FINOBT);
49 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RMAPBT);
50 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_REFCNTBT);
51 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INODE);
52 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTD);
53 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTA);
54 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTC);
55 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_DIR);
56 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_XATTR);
57 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SYMLINK);
58 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PARENT);
59 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTBITMAP);
60 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTSUM);
61 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_UQUOTA);
62 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_GQUOTA);
63 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PQUOTA);
64 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FSCOUNTERS);
65 
66 #define XFS_SCRUB_TYPE_STRINGS \
67 	{ XFS_SCRUB_TYPE_PROBE,		"probe" }, \
68 	{ XFS_SCRUB_TYPE_SB,		"sb" }, \
69 	{ XFS_SCRUB_TYPE_AGF,		"agf" }, \
70 	{ XFS_SCRUB_TYPE_AGFL,		"agfl" }, \
71 	{ XFS_SCRUB_TYPE_AGI,		"agi" }, \
72 	{ XFS_SCRUB_TYPE_BNOBT,		"bnobt" }, \
73 	{ XFS_SCRUB_TYPE_CNTBT,		"cntbt" }, \
74 	{ XFS_SCRUB_TYPE_INOBT,		"inobt" }, \
75 	{ XFS_SCRUB_TYPE_FINOBT,	"finobt" }, \
76 	{ XFS_SCRUB_TYPE_RMAPBT,	"rmapbt" }, \
77 	{ XFS_SCRUB_TYPE_REFCNTBT,	"refcountbt" }, \
78 	{ XFS_SCRUB_TYPE_INODE,		"inode" }, \
79 	{ XFS_SCRUB_TYPE_BMBTD,		"bmapbtd" }, \
80 	{ XFS_SCRUB_TYPE_BMBTA,		"bmapbta" }, \
81 	{ XFS_SCRUB_TYPE_BMBTC,		"bmapbtc" }, \
82 	{ XFS_SCRUB_TYPE_DIR,		"directory" }, \
83 	{ XFS_SCRUB_TYPE_XATTR,		"xattr" }, \
84 	{ XFS_SCRUB_TYPE_SYMLINK,	"symlink" }, \
85 	{ XFS_SCRUB_TYPE_PARENT,	"parent" }, \
86 	{ XFS_SCRUB_TYPE_RTBITMAP,	"rtbitmap" }, \
87 	{ XFS_SCRUB_TYPE_RTSUM,		"rtsummary" }, \
88 	{ XFS_SCRUB_TYPE_UQUOTA,	"usrquota" }, \
89 	{ XFS_SCRUB_TYPE_GQUOTA,	"grpquota" }, \
90 	{ XFS_SCRUB_TYPE_PQUOTA,	"prjquota" }, \
91 	{ XFS_SCRUB_TYPE_FSCOUNTERS,	"fscounters" }
92 
93 #define XFS_SCRUB_FLAG_STRINGS \
94 	{ XFS_SCRUB_IFLAG_REPAIR,		"repair" }, \
95 	{ XFS_SCRUB_OFLAG_CORRUPT,		"corrupt" }, \
96 	{ XFS_SCRUB_OFLAG_PREEN,		"preen" }, \
97 	{ XFS_SCRUB_OFLAG_XFAIL,		"xfail" }, \
98 	{ XFS_SCRUB_OFLAG_XCORRUPT,		"xcorrupt" }, \
99 	{ XFS_SCRUB_OFLAG_INCOMPLETE,		"incomplete" }, \
100 	{ XFS_SCRUB_OFLAG_WARNING,		"warning" }, \
101 	{ XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED,	"norepair" }, \
102 	{ XFS_SCRUB_IFLAG_FORCE_REBUILD,	"rebuild" }
103 
104 #define XFS_SCRUB_STATE_STRINGS \
105 	{ XCHK_TRY_HARDER,			"try_harder" }, \
106 	{ XCHK_HAVE_FREEZE_PROT,		"nofreeze" }, \
107 	{ XCHK_FSGATES_DRAIN,			"fsgates_drain" }, \
108 	{ XCHK_NEED_DRAIN,			"need_drain" }, \
109 	{ XREP_ALREADY_FIXED,			"already_fixed" }
110 
111 DECLARE_EVENT_CLASS(xchk_class,
112 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm,
113 		 int error),
114 	TP_ARGS(ip, sm, error),
115 	TP_STRUCT__entry(
116 		__field(dev_t, dev)
117 		__field(xfs_ino_t, ino)
118 		__field(unsigned int, type)
119 		__field(xfs_agnumber_t, agno)
120 		__field(xfs_ino_t, inum)
121 		__field(unsigned int, gen)
122 		__field(unsigned int, flags)
123 		__field(int, error)
124 	),
125 	TP_fast_assign(
126 		__entry->dev = ip->i_mount->m_super->s_dev;
127 		__entry->ino = ip->i_ino;
128 		__entry->type = sm->sm_type;
129 		__entry->agno = sm->sm_agno;
130 		__entry->inum = sm->sm_ino;
131 		__entry->gen = sm->sm_gen;
132 		__entry->flags = sm->sm_flags;
133 		__entry->error = error;
134 	),
135 	TP_printk("dev %d:%d ino 0x%llx type %s agno 0x%x inum 0x%llx gen 0x%x flags (%s) error %d",
136 		  MAJOR(__entry->dev), MINOR(__entry->dev),
137 		  __entry->ino,
138 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
139 		  __entry->agno,
140 		  __entry->inum,
141 		  __entry->gen,
142 		  __print_flags(__entry->flags, "|", XFS_SCRUB_FLAG_STRINGS),
143 		  __entry->error)
144 )
145 #define DEFINE_SCRUB_EVENT(name) \
146 DEFINE_EVENT(xchk_class, name, \
147 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, \
148 		 int error), \
149 	TP_ARGS(ip, sm, error))
150 
151 DEFINE_SCRUB_EVENT(xchk_start);
152 DEFINE_SCRUB_EVENT(xchk_done);
153 DEFINE_SCRUB_EVENT(xchk_deadlock_retry);
154 DEFINE_SCRUB_EVENT(xrep_attempt);
155 DEFINE_SCRUB_EVENT(xrep_done);
156 
157 DECLARE_EVENT_CLASS(xchk_fsgate_class,
158 	TP_PROTO(struct xfs_scrub *sc, unsigned int fsgate_flags),
159 	TP_ARGS(sc, fsgate_flags),
160 	TP_STRUCT__entry(
161 		__field(dev_t, dev)
162 		__field(unsigned int, type)
163 		__field(unsigned int, fsgate_flags)
164 	),
165 	TP_fast_assign(
166 		__entry->dev = sc->mp->m_super->s_dev;
167 		__entry->type = sc->sm->sm_type;
168 		__entry->fsgate_flags = fsgate_flags;
169 	),
170 	TP_printk("dev %d:%d type %s fsgates '%s'",
171 		  MAJOR(__entry->dev), MINOR(__entry->dev),
172 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
173 		  __print_flags(__entry->fsgate_flags, "|", XFS_SCRUB_STATE_STRINGS))
174 )
175 
176 #define DEFINE_SCRUB_FSHOOK_EVENT(name) \
177 DEFINE_EVENT(xchk_fsgate_class, name, \
178 	TP_PROTO(struct xfs_scrub *sc, unsigned int fsgates_flags), \
179 	TP_ARGS(sc, fsgates_flags))
180 
181 DEFINE_SCRUB_FSHOOK_EVENT(xchk_fsgates_enable);
182 DEFINE_SCRUB_FSHOOK_EVENT(xchk_fsgates_disable);
183 
184 TRACE_EVENT(xchk_op_error,
185 	TP_PROTO(struct xfs_scrub *sc, xfs_agnumber_t agno,
186 		 xfs_agblock_t bno, int error, void *ret_ip),
187 	TP_ARGS(sc, agno, bno, error, ret_ip),
188 	TP_STRUCT__entry(
189 		__field(dev_t, dev)
190 		__field(unsigned int, type)
191 		__field(xfs_agnumber_t, agno)
192 		__field(xfs_agblock_t, bno)
193 		__field(int, error)
194 		__field(void *, ret_ip)
195 	),
196 	TP_fast_assign(
197 		__entry->dev = sc->mp->m_super->s_dev;
198 		__entry->type = sc->sm->sm_type;
199 		__entry->agno = agno;
200 		__entry->bno = bno;
201 		__entry->error = error;
202 		__entry->ret_ip = ret_ip;
203 	),
204 	TP_printk("dev %d:%d type %s agno 0x%x agbno 0x%x error %d ret_ip %pS",
205 		  MAJOR(__entry->dev), MINOR(__entry->dev),
206 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
207 		  __entry->agno,
208 		  __entry->bno,
209 		  __entry->error,
210 		  __entry->ret_ip)
211 );
212 
213 TRACE_EVENT(xchk_file_op_error,
214 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
215 		 xfs_fileoff_t offset, int error, void *ret_ip),
216 	TP_ARGS(sc, whichfork, offset, error, ret_ip),
217 	TP_STRUCT__entry(
218 		__field(dev_t, dev)
219 		__field(xfs_ino_t, ino)
220 		__field(int, whichfork)
221 		__field(unsigned int, type)
222 		__field(xfs_fileoff_t, offset)
223 		__field(int, error)
224 		__field(void *, ret_ip)
225 	),
226 	TP_fast_assign(
227 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
228 		__entry->ino = sc->ip->i_ino;
229 		__entry->whichfork = whichfork;
230 		__entry->type = sc->sm->sm_type;
231 		__entry->offset = offset;
232 		__entry->error = error;
233 		__entry->ret_ip = ret_ip;
234 	),
235 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s fileoff 0x%llx error %d ret_ip %pS",
236 		  MAJOR(__entry->dev), MINOR(__entry->dev),
237 		  __entry->ino,
238 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
239 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
240 		  __entry->offset,
241 		  __entry->error,
242 		  __entry->ret_ip)
243 );
244 
245 DECLARE_EVENT_CLASS(xchk_block_error_class,
246 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, void *ret_ip),
247 	TP_ARGS(sc, daddr, ret_ip),
248 	TP_STRUCT__entry(
249 		__field(dev_t, dev)
250 		__field(unsigned int, type)
251 		__field(xfs_agnumber_t, agno)
252 		__field(xfs_agblock_t, agbno)
253 		__field(void *, ret_ip)
254 	),
255 	TP_fast_assign(
256 		__entry->dev = sc->mp->m_super->s_dev;
257 		__entry->type = sc->sm->sm_type;
258 		__entry->agno = xfs_daddr_to_agno(sc->mp, daddr);
259 		__entry->agbno = xfs_daddr_to_agbno(sc->mp, daddr);
260 		__entry->ret_ip = ret_ip;
261 	),
262 	TP_printk("dev %d:%d type %s agno 0x%x agbno 0x%x ret_ip %pS",
263 		  MAJOR(__entry->dev), MINOR(__entry->dev),
264 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
265 		  __entry->agno,
266 		  __entry->agbno,
267 		  __entry->ret_ip)
268 )
269 
270 #define DEFINE_SCRUB_BLOCK_ERROR_EVENT(name) \
271 DEFINE_EVENT(xchk_block_error_class, name, \
272 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, \
273 		 void *ret_ip), \
274 	TP_ARGS(sc, daddr, ret_ip))
275 
276 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_fs_error);
277 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_error);
278 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_preen);
279 
280 DECLARE_EVENT_CLASS(xchk_ino_error_class,
281 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, void *ret_ip),
282 	TP_ARGS(sc, ino, ret_ip),
283 	TP_STRUCT__entry(
284 		__field(dev_t, dev)
285 		__field(xfs_ino_t, ino)
286 		__field(unsigned int, type)
287 		__field(void *, ret_ip)
288 	),
289 	TP_fast_assign(
290 		__entry->dev = sc->mp->m_super->s_dev;
291 		__entry->ino = ino;
292 		__entry->type = sc->sm->sm_type;
293 		__entry->ret_ip = ret_ip;
294 	),
295 	TP_printk("dev %d:%d ino 0x%llx type %s ret_ip %pS",
296 		  MAJOR(__entry->dev), MINOR(__entry->dev),
297 		  __entry->ino,
298 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
299 		  __entry->ret_ip)
300 )
301 
302 #define DEFINE_SCRUB_INO_ERROR_EVENT(name) \
303 DEFINE_EVENT(xchk_ino_error_class, name, \
304 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, \
305 		 void *ret_ip), \
306 	TP_ARGS(sc, ino, ret_ip))
307 
308 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_error);
309 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_preen);
310 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_warning);
311 
312 DECLARE_EVENT_CLASS(xchk_fblock_error_class,
313 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
314 		 xfs_fileoff_t offset, void *ret_ip),
315 	TP_ARGS(sc, whichfork, offset, ret_ip),
316 	TP_STRUCT__entry(
317 		__field(dev_t, dev)
318 		__field(xfs_ino_t, ino)
319 		__field(int, whichfork)
320 		__field(unsigned int, type)
321 		__field(xfs_fileoff_t, offset)
322 		__field(void *, ret_ip)
323 	),
324 	TP_fast_assign(
325 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
326 		__entry->ino = sc->ip->i_ino;
327 		__entry->whichfork = whichfork;
328 		__entry->type = sc->sm->sm_type;
329 		__entry->offset = offset;
330 		__entry->ret_ip = ret_ip;
331 	),
332 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s fileoff 0x%llx ret_ip %pS",
333 		  MAJOR(__entry->dev), MINOR(__entry->dev),
334 		  __entry->ino,
335 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
336 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
337 		  __entry->offset,
338 		  __entry->ret_ip)
339 );
340 
341 #define DEFINE_SCRUB_FBLOCK_ERROR_EVENT(name) \
342 DEFINE_EVENT(xchk_fblock_error_class, name, \
343 	TP_PROTO(struct xfs_scrub *sc, int whichfork, \
344 		 xfs_fileoff_t offset, void *ret_ip), \
345 	TP_ARGS(sc, whichfork, offset, ret_ip))
346 
347 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_error);
348 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_warning);
349 
350 TRACE_EVENT(xchk_incomplete,
351 	TP_PROTO(struct xfs_scrub *sc, void *ret_ip),
352 	TP_ARGS(sc, ret_ip),
353 	TP_STRUCT__entry(
354 		__field(dev_t, dev)
355 		__field(unsigned int, type)
356 		__field(void *, ret_ip)
357 	),
358 	TP_fast_assign(
359 		__entry->dev = sc->mp->m_super->s_dev;
360 		__entry->type = sc->sm->sm_type;
361 		__entry->ret_ip = ret_ip;
362 	),
363 	TP_printk("dev %d:%d type %s ret_ip %pS",
364 		  MAJOR(__entry->dev), MINOR(__entry->dev),
365 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
366 		  __entry->ret_ip)
367 );
368 
369 TRACE_EVENT(xchk_btree_op_error,
370 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
371 		 int level, int error, void *ret_ip),
372 	TP_ARGS(sc, cur, level, error, ret_ip),
373 	TP_STRUCT__entry(
374 		__field(dev_t, dev)
375 		__field(unsigned int, type)
376 		__field(xfs_btnum_t, btnum)
377 		__field(int, level)
378 		__field(xfs_agnumber_t, agno)
379 		__field(xfs_agblock_t, bno)
380 		__field(int, ptr)
381 		__field(int, error)
382 		__field(void *, ret_ip)
383 	),
384 	TP_fast_assign(
385 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
386 
387 		__entry->dev = sc->mp->m_super->s_dev;
388 		__entry->type = sc->sm->sm_type;
389 		__entry->btnum = cur->bc_btnum;
390 		__entry->level = level;
391 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
392 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
393 		__entry->ptr = cur->bc_levels[level].ptr;
394 		__entry->error = error;
395 		__entry->ret_ip = ret_ip;
396 	),
397 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno 0x%x agbno 0x%x error %d ret_ip %pS",
398 		  MAJOR(__entry->dev), MINOR(__entry->dev),
399 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
400 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
401 		  __entry->level,
402 		  __entry->ptr,
403 		  __entry->agno,
404 		  __entry->bno,
405 		  __entry->error,
406 		  __entry->ret_ip)
407 );
408 
409 TRACE_EVENT(xchk_ifork_btree_op_error,
410 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
411 		 int level, int error, void *ret_ip),
412 	TP_ARGS(sc, cur, level, error, ret_ip),
413 	TP_STRUCT__entry(
414 		__field(dev_t, dev)
415 		__field(xfs_ino_t, ino)
416 		__field(int, whichfork)
417 		__field(unsigned int, type)
418 		__field(xfs_btnum_t, btnum)
419 		__field(int, level)
420 		__field(int, ptr)
421 		__field(xfs_agnumber_t, agno)
422 		__field(xfs_agblock_t, bno)
423 		__field(int, error)
424 		__field(void *, ret_ip)
425 	),
426 	TP_fast_assign(
427 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
428 		__entry->dev = sc->mp->m_super->s_dev;
429 		__entry->ino = sc->ip->i_ino;
430 		__entry->whichfork = cur->bc_ino.whichfork;
431 		__entry->type = sc->sm->sm_type;
432 		__entry->btnum = cur->bc_btnum;
433 		__entry->level = level;
434 		__entry->ptr = cur->bc_levels[level].ptr;
435 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
436 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
437 		__entry->error = error;
438 		__entry->ret_ip = ret_ip;
439 	),
440 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s btree %s level %d ptr %d agno 0x%x agbno 0x%x error %d ret_ip %pS",
441 		  MAJOR(__entry->dev), MINOR(__entry->dev),
442 		  __entry->ino,
443 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
444 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
445 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
446 		  __entry->level,
447 		  __entry->ptr,
448 		  __entry->agno,
449 		  __entry->bno,
450 		  __entry->error,
451 		  __entry->ret_ip)
452 );
453 
454 TRACE_EVENT(xchk_btree_error,
455 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
456 		 int level, void *ret_ip),
457 	TP_ARGS(sc, cur, level, ret_ip),
458 	TP_STRUCT__entry(
459 		__field(dev_t, dev)
460 		__field(unsigned int, type)
461 		__field(xfs_btnum_t, btnum)
462 		__field(int, level)
463 		__field(xfs_agnumber_t, agno)
464 		__field(xfs_agblock_t, bno)
465 		__field(int, ptr)
466 		__field(void *, ret_ip)
467 	),
468 	TP_fast_assign(
469 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
470 		__entry->dev = sc->mp->m_super->s_dev;
471 		__entry->type = sc->sm->sm_type;
472 		__entry->btnum = cur->bc_btnum;
473 		__entry->level = level;
474 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
475 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
476 		__entry->ptr = cur->bc_levels[level].ptr;
477 		__entry->ret_ip = ret_ip;
478 	),
479 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno 0x%x agbno 0x%x ret_ip %pS",
480 		  MAJOR(__entry->dev), MINOR(__entry->dev),
481 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
482 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
483 		  __entry->level,
484 		  __entry->ptr,
485 		  __entry->agno,
486 		  __entry->bno,
487 		  __entry->ret_ip)
488 );
489 
490 TRACE_EVENT(xchk_ifork_btree_error,
491 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
492 		 int level, void *ret_ip),
493 	TP_ARGS(sc, cur, level, ret_ip),
494 	TP_STRUCT__entry(
495 		__field(dev_t, dev)
496 		__field(xfs_ino_t, ino)
497 		__field(int, whichfork)
498 		__field(unsigned int, type)
499 		__field(xfs_btnum_t, btnum)
500 		__field(int, level)
501 		__field(xfs_agnumber_t, agno)
502 		__field(xfs_agblock_t, bno)
503 		__field(int, ptr)
504 		__field(void *, ret_ip)
505 	),
506 	TP_fast_assign(
507 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
508 		__entry->dev = sc->mp->m_super->s_dev;
509 		__entry->ino = sc->ip->i_ino;
510 		__entry->whichfork = cur->bc_ino.whichfork;
511 		__entry->type = sc->sm->sm_type;
512 		__entry->btnum = cur->bc_btnum;
513 		__entry->level = level;
514 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
515 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
516 		__entry->ptr = cur->bc_levels[level].ptr;
517 		__entry->ret_ip = ret_ip;
518 	),
519 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s btree %s level %d ptr %d agno 0x%x agbno 0x%x ret_ip %pS",
520 		  MAJOR(__entry->dev), MINOR(__entry->dev),
521 		  __entry->ino,
522 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
523 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
524 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
525 		  __entry->level,
526 		  __entry->ptr,
527 		  __entry->agno,
528 		  __entry->bno,
529 		  __entry->ret_ip)
530 );
531 
532 DECLARE_EVENT_CLASS(xchk_sbtree_class,
533 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
534 		 int level),
535 	TP_ARGS(sc, cur, level),
536 	TP_STRUCT__entry(
537 		__field(dev_t, dev)
538 		__field(int, type)
539 		__field(xfs_btnum_t, btnum)
540 		__field(xfs_agnumber_t, agno)
541 		__field(xfs_agblock_t, bno)
542 		__field(int, level)
543 		__field(int, nlevels)
544 		__field(int, ptr)
545 	),
546 	TP_fast_assign(
547 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
548 
549 		__entry->dev = sc->mp->m_super->s_dev;
550 		__entry->type = sc->sm->sm_type;
551 		__entry->btnum = cur->bc_btnum;
552 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
553 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
554 		__entry->level = level;
555 		__entry->nlevels = cur->bc_nlevels;
556 		__entry->ptr = cur->bc_levels[level].ptr;
557 	),
558 	TP_printk("dev %d:%d type %s btree %s agno 0x%x agbno 0x%x level %d nlevels %d ptr %d",
559 		  MAJOR(__entry->dev), MINOR(__entry->dev),
560 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
561 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
562 		  __entry->agno,
563 		  __entry->bno,
564 		  __entry->level,
565 		  __entry->nlevels,
566 		  __entry->ptr)
567 )
568 #define DEFINE_SCRUB_SBTREE_EVENT(name) \
569 DEFINE_EVENT(xchk_sbtree_class, name, \
570 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur, \
571 		 int level), \
572 	TP_ARGS(sc, cur, level))
573 
574 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_rec);
575 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_key);
576 
577 TRACE_EVENT(xchk_xref_error,
578 	TP_PROTO(struct xfs_scrub *sc, int error, void *ret_ip),
579 	TP_ARGS(sc, error, ret_ip),
580 	TP_STRUCT__entry(
581 		__field(dev_t, dev)
582 		__field(int, type)
583 		__field(int, error)
584 		__field(void *, ret_ip)
585 	),
586 	TP_fast_assign(
587 		__entry->dev = sc->mp->m_super->s_dev;
588 		__entry->type = sc->sm->sm_type;
589 		__entry->error = error;
590 		__entry->ret_ip = ret_ip;
591 	),
592 	TP_printk("dev %d:%d type %s xref error %d ret_ip %pS",
593 		  MAJOR(__entry->dev), MINOR(__entry->dev),
594 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
595 		  __entry->error,
596 		  __entry->ret_ip)
597 );
598 
599 TRACE_EVENT(xchk_iallocbt_check_cluster,
600 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
601 		 xfs_agino_t startino, xfs_daddr_t map_daddr,
602 		 unsigned short map_len, unsigned int chunk_ino,
603 		 unsigned int nr_inodes, uint16_t cluster_mask,
604 		 uint16_t holemask, unsigned int cluster_ino),
605 	TP_ARGS(mp, agno, startino, map_daddr, map_len, chunk_ino, nr_inodes,
606 		cluster_mask, holemask, cluster_ino),
607 	TP_STRUCT__entry(
608 		__field(dev_t, dev)
609 		__field(xfs_agnumber_t, agno)
610 		__field(xfs_agino_t, startino)
611 		__field(xfs_daddr_t, map_daddr)
612 		__field(unsigned short, map_len)
613 		__field(unsigned int, chunk_ino)
614 		__field(unsigned int, nr_inodes)
615 		__field(unsigned int, cluster_ino)
616 		__field(uint16_t, cluster_mask)
617 		__field(uint16_t, holemask)
618 	),
619 	TP_fast_assign(
620 		__entry->dev = mp->m_super->s_dev;
621 		__entry->agno = agno;
622 		__entry->startino = startino;
623 		__entry->map_daddr = map_daddr;
624 		__entry->map_len = map_len;
625 		__entry->chunk_ino = chunk_ino;
626 		__entry->nr_inodes = nr_inodes;
627 		__entry->cluster_mask = cluster_mask;
628 		__entry->holemask = holemask;
629 		__entry->cluster_ino = cluster_ino;
630 	),
631 	TP_printk("dev %d:%d agno 0x%x startino 0x%x daddr 0x%llx bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x",
632 		  MAJOR(__entry->dev), MINOR(__entry->dev),
633 		  __entry->agno,
634 		  __entry->startino,
635 		  __entry->map_daddr,
636 		  __entry->map_len,
637 		  __entry->chunk_ino,
638 		  __entry->nr_inodes,
639 		  __entry->cluster_mask,
640 		  __entry->holemask,
641 		  __entry->cluster_ino)
642 )
643 
644 TRACE_EVENT(xchk_inode_is_allocated,
645 	TP_PROTO(struct xfs_inode *ip),
646 	TP_ARGS(ip),
647 	TP_STRUCT__entry(
648 		__field(dev_t, dev)
649 		__field(xfs_ino_t, ino)
650 		__field(unsigned long, iflags)
651 		__field(umode_t, mode)
652 	),
653 	TP_fast_assign(
654 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
655 		__entry->ino = ip->i_ino;
656 		__entry->iflags = ip->i_flags;
657 		__entry->mode = VFS_I(ip)->i_mode;
658 	),
659 	TP_printk("dev %d:%d ino 0x%llx iflags 0x%lx mode 0x%x",
660 		  MAJOR(__entry->dev), MINOR(__entry->dev),
661 		  __entry->ino,
662 		  __entry->iflags,
663 		  __entry->mode)
664 );
665 
666 TRACE_EVENT(xchk_fscounters_calc,
667 	TP_PROTO(struct xfs_mount *mp, uint64_t icount, uint64_t ifree,
668 		 uint64_t fdblocks, uint64_t delalloc),
669 	TP_ARGS(mp, icount, ifree, fdblocks, delalloc),
670 	TP_STRUCT__entry(
671 		__field(dev_t, dev)
672 		__field(int64_t, icount_sb)
673 		__field(uint64_t, icount_calculated)
674 		__field(int64_t, ifree_sb)
675 		__field(uint64_t, ifree_calculated)
676 		__field(int64_t, fdblocks_sb)
677 		__field(uint64_t, fdblocks_calculated)
678 		__field(uint64_t, delalloc)
679 	),
680 	TP_fast_assign(
681 		__entry->dev = mp->m_super->s_dev;
682 		__entry->icount_sb = mp->m_sb.sb_icount;
683 		__entry->icount_calculated = icount;
684 		__entry->ifree_sb = mp->m_sb.sb_ifree;
685 		__entry->ifree_calculated = ifree;
686 		__entry->fdblocks_sb = mp->m_sb.sb_fdblocks;
687 		__entry->fdblocks_calculated = fdblocks;
688 		__entry->delalloc = delalloc;
689 	),
690 	TP_printk("dev %d:%d icount %lld:%llu ifree %lld::%llu fdblocks %lld::%llu delalloc %llu",
691 		  MAJOR(__entry->dev), MINOR(__entry->dev),
692 		  __entry->icount_sb,
693 		  __entry->icount_calculated,
694 		  __entry->ifree_sb,
695 		  __entry->ifree_calculated,
696 		  __entry->fdblocks_sb,
697 		  __entry->fdblocks_calculated,
698 		  __entry->delalloc)
699 )
700 
701 TRACE_EVENT(xchk_fscounters_within_range,
702 	TP_PROTO(struct xfs_mount *mp, uint64_t expected, int64_t curr_value,
703 		 int64_t old_value),
704 	TP_ARGS(mp, expected, curr_value, old_value),
705 	TP_STRUCT__entry(
706 		__field(dev_t, dev)
707 		__field(uint64_t, expected)
708 		__field(int64_t, curr_value)
709 		__field(int64_t, old_value)
710 	),
711 	TP_fast_assign(
712 		__entry->dev = mp->m_super->s_dev;
713 		__entry->expected = expected;
714 		__entry->curr_value = curr_value;
715 		__entry->old_value = old_value;
716 	),
717 	TP_printk("dev %d:%d expected %llu curr_value %lld old_value %lld",
718 		  MAJOR(__entry->dev), MINOR(__entry->dev),
719 		  __entry->expected,
720 		  __entry->curr_value,
721 		  __entry->old_value)
722 )
723 
724 DECLARE_EVENT_CLASS(xchk_fsfreeze_class,
725 	TP_PROTO(struct xfs_scrub *sc, int error),
726 	TP_ARGS(sc, error),
727 	TP_STRUCT__entry(
728 		__field(dev_t, dev)
729 		__field(unsigned int, type)
730 		__field(int, error)
731 	),
732 	TP_fast_assign(
733 		__entry->dev = sc->mp->m_super->s_dev;
734 		__entry->type = sc->sm->sm_type;
735 		__entry->error = error;
736 	),
737 	TP_printk("dev %d:%d type %s error %d",
738 		  MAJOR(__entry->dev), MINOR(__entry->dev),
739 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
740 		  __entry->error)
741 );
742 #define DEFINE_XCHK_FSFREEZE_EVENT(name) \
743 DEFINE_EVENT(xchk_fsfreeze_class, name, \
744 	TP_PROTO(struct xfs_scrub *sc, int error), \
745 	TP_ARGS(sc, error))
746 DEFINE_XCHK_FSFREEZE_EVENT(xchk_fsfreeze);
747 DEFINE_XCHK_FSFREEZE_EVENT(xchk_fsthaw);
748 
749 TRACE_EVENT(xchk_refcount_incorrect,
750 	TP_PROTO(struct xfs_perag *pag, const struct xfs_refcount_irec *irec,
751 		 xfs_nlink_t seen),
752 	TP_ARGS(pag, irec, seen),
753 	TP_STRUCT__entry(
754 		__field(dev_t, dev)
755 		__field(xfs_agnumber_t, agno)
756 		__field(enum xfs_refc_domain, domain)
757 		__field(xfs_agblock_t, startblock)
758 		__field(xfs_extlen_t, blockcount)
759 		__field(xfs_nlink_t, refcount)
760 		__field(xfs_nlink_t, seen)
761 	),
762 	TP_fast_assign(
763 		__entry->dev = pag->pag_mount->m_super->s_dev;
764 		__entry->agno = pag->pag_agno;
765 		__entry->domain = irec->rc_domain;
766 		__entry->startblock = irec->rc_startblock;
767 		__entry->blockcount = irec->rc_blockcount;
768 		__entry->refcount = irec->rc_refcount;
769 		__entry->seen = seen;
770 	),
771 	TP_printk("dev %d:%d agno 0x%x dom %s agbno 0x%x fsbcount 0x%x refcount %u seen %u",
772 		  MAJOR(__entry->dev), MINOR(__entry->dev),
773 		  __entry->agno,
774 		  __print_symbolic(__entry->domain, XFS_REFC_DOMAIN_STRINGS),
775 		  __entry->startblock,
776 		  __entry->blockcount,
777 		  __entry->refcount,
778 		  __entry->seen)
779 )
780 
781 TRACE_EVENT(xfile_create,
782 	TP_PROTO(struct xfile *xf),
783 	TP_ARGS(xf),
784 	TP_STRUCT__entry(
785 		__field(dev_t, dev)
786 		__field(unsigned long, ino)
787 		__array(char, pathname, 256)
788 	),
789 	TP_fast_assign(
790 		char		pathname[257];
791 		char		*path;
792 
793 		__entry->ino = file_inode(xf->file)->i_ino;
794 		memset(pathname, 0, sizeof(pathname));
795 		path = file_path(xf->file, pathname, sizeof(pathname) - 1);
796 		if (IS_ERR(path))
797 			path = "(unknown)";
798 		strncpy(__entry->pathname, path, sizeof(__entry->pathname));
799 	),
800 	TP_printk("xfino 0x%lx path '%s'",
801 		  __entry->ino,
802 		  __entry->pathname)
803 );
804 
805 TRACE_EVENT(xfile_destroy,
806 	TP_PROTO(struct xfile *xf),
807 	TP_ARGS(xf),
808 	TP_STRUCT__entry(
809 		__field(unsigned long, ino)
810 		__field(unsigned long long, bytes)
811 		__field(loff_t, size)
812 	),
813 	TP_fast_assign(
814 		struct xfile_stat	statbuf;
815 		int			ret;
816 
817 		ret = xfile_stat(xf, &statbuf);
818 		if (!ret) {
819 			__entry->bytes = statbuf.bytes;
820 			__entry->size = statbuf.size;
821 		} else {
822 			__entry->bytes = -1;
823 			__entry->size = -1;
824 		}
825 		__entry->ino = file_inode(xf->file)->i_ino;
826 	),
827 	TP_printk("xfino 0x%lx mem_bytes 0x%llx isize 0x%llx",
828 		  __entry->ino,
829 		  __entry->bytes,
830 		  __entry->size)
831 );
832 
833 DECLARE_EVENT_CLASS(xfile_class,
834 	TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount),
835 	TP_ARGS(xf, pos, bytecount),
836 	TP_STRUCT__entry(
837 		__field(unsigned long, ino)
838 		__field(unsigned long long, bytes_used)
839 		__field(loff_t, pos)
840 		__field(loff_t, size)
841 		__field(unsigned long long, bytecount)
842 	),
843 	TP_fast_assign(
844 		struct xfile_stat	statbuf;
845 		int			ret;
846 
847 		ret = xfile_stat(xf, &statbuf);
848 		if (!ret) {
849 			__entry->bytes_used = statbuf.bytes;
850 			__entry->size = statbuf.size;
851 		} else {
852 			__entry->bytes_used = -1;
853 			__entry->size = -1;
854 		}
855 		__entry->ino = file_inode(xf->file)->i_ino;
856 		__entry->pos = pos;
857 		__entry->bytecount = bytecount;
858 	),
859 	TP_printk("xfino 0x%lx mem_bytes 0x%llx pos 0x%llx bytecount 0x%llx isize 0x%llx",
860 		  __entry->ino,
861 		  __entry->bytes_used,
862 		  __entry->pos,
863 		  __entry->bytecount,
864 		  __entry->size)
865 );
866 #define DEFINE_XFILE_EVENT(name) \
867 DEFINE_EVENT(xfile_class, name, \
868 	TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount), \
869 	TP_ARGS(xf, pos, bytecount))
870 DEFINE_XFILE_EVENT(xfile_pread);
871 DEFINE_XFILE_EVENT(xfile_pwrite);
872 DEFINE_XFILE_EVENT(xfile_seek_data);
873 DEFINE_XFILE_EVENT(xfile_get_page);
874 DEFINE_XFILE_EVENT(xfile_put_page);
875 
876 TRACE_EVENT(xfarray_create,
877 	TP_PROTO(struct xfarray *xfa, unsigned long long required_capacity),
878 	TP_ARGS(xfa, required_capacity),
879 	TP_STRUCT__entry(
880 		__field(unsigned long, ino)
881 		__field(uint64_t, max_nr)
882 		__field(size_t, obj_size)
883 		__field(int, obj_size_log)
884 		__field(unsigned long long, required_capacity)
885 	),
886 	TP_fast_assign(
887 		__entry->max_nr = xfa->max_nr;
888 		__entry->obj_size = xfa->obj_size;
889 		__entry->obj_size_log = xfa->obj_size_log;
890 		__entry->ino = file_inode(xfa->xfile->file)->i_ino;
891 		__entry->required_capacity = required_capacity;
892 	),
893 	TP_printk("xfino 0x%lx max_nr %llu reqd_nr %llu objsz %zu objszlog %d",
894 		  __entry->ino,
895 		  __entry->max_nr,
896 		  __entry->required_capacity,
897 		  __entry->obj_size,
898 		  __entry->obj_size_log)
899 );
900 
901 TRACE_EVENT(xfarray_isort,
902 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
903 	TP_ARGS(si, lo, hi),
904 	TP_STRUCT__entry(
905 		__field(unsigned long, ino)
906 		__field(unsigned long long, lo)
907 		__field(unsigned long long, hi)
908 	),
909 	TP_fast_assign(
910 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
911 		__entry->lo = lo;
912 		__entry->hi = hi;
913 	),
914 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu",
915 		  __entry->ino,
916 		  __entry->lo,
917 		  __entry->hi,
918 		  __entry->hi - __entry->lo)
919 );
920 
921 TRACE_EVENT(xfarray_pagesort,
922 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
923 	TP_ARGS(si, lo, hi),
924 	TP_STRUCT__entry(
925 		__field(unsigned long, ino)
926 		__field(unsigned long long, lo)
927 		__field(unsigned long long, hi)
928 	),
929 	TP_fast_assign(
930 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
931 		__entry->lo = lo;
932 		__entry->hi = hi;
933 	),
934 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu",
935 		  __entry->ino,
936 		  __entry->lo,
937 		  __entry->hi,
938 		  __entry->hi - __entry->lo)
939 );
940 
941 TRACE_EVENT(xfarray_qsort,
942 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
943 	TP_ARGS(si, lo, hi),
944 	TP_STRUCT__entry(
945 		__field(unsigned long, ino)
946 		__field(unsigned long long, lo)
947 		__field(unsigned long long, hi)
948 		__field(int, stack_depth)
949 		__field(int, max_stack_depth)
950 	),
951 	TP_fast_assign(
952 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
953 		__entry->lo = lo;
954 		__entry->hi = hi;
955 		__entry->stack_depth = si->stack_depth;
956 		__entry->max_stack_depth = si->max_stack_depth;
957 	),
958 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu stack %d/%d",
959 		  __entry->ino,
960 		  __entry->lo,
961 		  __entry->hi,
962 		  __entry->hi - __entry->lo,
963 		  __entry->stack_depth,
964 		  __entry->max_stack_depth)
965 );
966 
967 TRACE_EVENT(xfarray_sort,
968 	TP_PROTO(struct xfarray_sortinfo *si, size_t bytes),
969 	TP_ARGS(si, bytes),
970 	TP_STRUCT__entry(
971 		__field(unsigned long, ino)
972 		__field(unsigned long long, nr)
973 		__field(size_t, obj_size)
974 		__field(size_t, bytes)
975 		__field(unsigned int, max_stack_depth)
976 	),
977 	TP_fast_assign(
978 		__entry->nr = si->array->nr;
979 		__entry->obj_size = si->array->obj_size;
980 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
981 		__entry->bytes = bytes;
982 		__entry->max_stack_depth = si->max_stack_depth;
983 	),
984 	TP_printk("xfino 0x%lx nr %llu objsz %zu stack %u bytes %zu",
985 		  __entry->ino,
986 		  __entry->nr,
987 		  __entry->obj_size,
988 		  __entry->max_stack_depth,
989 		  __entry->bytes)
990 );
991 
992 TRACE_EVENT(xfarray_sort_stats,
993 	TP_PROTO(struct xfarray_sortinfo *si, int error),
994 	TP_ARGS(si, error),
995 	TP_STRUCT__entry(
996 		__field(unsigned long, ino)
997 #ifdef DEBUG
998 		__field(unsigned long long, loads)
999 		__field(unsigned long long, stores)
1000 		__field(unsigned long long, compares)
1001 		__field(unsigned long long, heapsorts)
1002 #endif
1003 		__field(unsigned int, max_stack_depth)
1004 		__field(unsigned int, max_stack_used)
1005 		__field(int, error)
1006 	),
1007 	TP_fast_assign(
1008 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1009 #ifdef DEBUG
1010 		__entry->loads = si->loads;
1011 		__entry->stores = si->stores;
1012 		__entry->compares = si->compares;
1013 		__entry->heapsorts = si->heapsorts;
1014 #endif
1015 		__entry->max_stack_depth = si->max_stack_depth;
1016 		__entry->max_stack_used = si->max_stack_used;
1017 		__entry->error = error;
1018 	),
1019 	TP_printk(
1020 #ifdef DEBUG
1021 		  "xfino 0x%lx loads %llu stores %llu compares %llu heapsorts %llu stack_depth %u/%u error %d",
1022 #else
1023 		  "xfino 0x%lx stack_depth %u/%u error %d",
1024 #endif
1025 		  __entry->ino,
1026 #ifdef DEBUG
1027 		  __entry->loads,
1028 		  __entry->stores,
1029 		  __entry->compares,
1030 		  __entry->heapsorts,
1031 #endif
1032 		  __entry->max_stack_used,
1033 		  __entry->max_stack_depth,
1034 		  __entry->error)
1035 );
1036 
1037 #ifdef CONFIG_XFS_RT
1038 TRACE_EVENT(xchk_rtsum_record_free,
1039 	TP_PROTO(struct xfs_mount *mp, xfs_rtblock_t start,
1040 		 uint64_t len, unsigned int log, loff_t pos, xfs_suminfo_t v),
1041 	TP_ARGS(mp, start, len, log, pos, v),
1042 	TP_STRUCT__entry(
1043 		__field(dev_t, dev)
1044 		__field(dev_t, rtdev)
1045 		__field(xfs_rtblock_t, start)
1046 		__field(unsigned long long, len)
1047 		__field(unsigned int, log)
1048 		__field(loff_t, pos)
1049 		__field(xfs_suminfo_t, v)
1050 	),
1051 	TP_fast_assign(
1052 		__entry->dev = mp->m_super->s_dev;
1053 		__entry->rtdev = mp->m_rtdev_targp->bt_dev;
1054 		__entry->start = start;
1055 		__entry->len = len;
1056 		__entry->log = log;
1057 		__entry->pos = pos;
1058 		__entry->v = v;
1059 	),
1060 	TP_printk("dev %d:%d rtdev %d:%d rtx 0x%llx rtxcount 0x%llx log %u rsumpos 0x%llx sumcount %u",
1061 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1062 		  MAJOR(__entry->rtdev), MINOR(__entry->rtdev),
1063 		  __entry->start,
1064 		  __entry->len,
1065 		  __entry->log,
1066 		  __entry->pos,
1067 		  __entry->v)
1068 );
1069 #endif /* CONFIG_XFS_RT */
1070 
1071 /* repair tracepoints */
1072 #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
1073 
1074 DECLARE_EVENT_CLASS(xrep_extent_class,
1075 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len),
1076 	TP_ARGS(pag, agbno, len),
1077 	TP_STRUCT__entry(
1078 		__field(dev_t, dev)
1079 		__field(xfs_agnumber_t, agno)
1080 		__field(xfs_agblock_t, agbno)
1081 		__field(xfs_extlen_t, len)
1082 	),
1083 	TP_fast_assign(
1084 		__entry->dev = pag->pag_mount->m_super->s_dev;
1085 		__entry->agno = pag->pag_agno;
1086 		__entry->agbno = agbno;
1087 		__entry->len = len;
1088 	),
1089 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
1090 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1091 		  __entry->agno,
1092 		  __entry->agbno,
1093 		  __entry->len)
1094 );
1095 #define DEFINE_REPAIR_EXTENT_EVENT(name) \
1096 DEFINE_EVENT(xrep_extent_class, name, \
1097 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len), \
1098 	TP_ARGS(pag, agbno, len))
1099 DEFINE_REPAIR_EXTENT_EVENT(xreap_dispose_unmap_extent);
1100 DEFINE_REPAIR_EXTENT_EVENT(xreap_dispose_free_extent);
1101 DEFINE_REPAIR_EXTENT_EVENT(xreap_agextent_binval);
1102 DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
1103 
1104 DECLARE_EVENT_CLASS(xrep_reap_find_class,
1105 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len,
1106 		bool crosslinked),
1107 	TP_ARGS(pag, agbno, len, crosslinked),
1108 	TP_STRUCT__entry(
1109 		__field(dev_t, dev)
1110 		__field(xfs_agnumber_t, agno)
1111 		__field(xfs_agblock_t, agbno)
1112 		__field(xfs_extlen_t, len)
1113 		__field(bool, crosslinked)
1114 	),
1115 	TP_fast_assign(
1116 		__entry->dev = pag->pag_mount->m_super->s_dev;
1117 		__entry->agno = pag->pag_agno;
1118 		__entry->agbno = agbno;
1119 		__entry->len = len;
1120 		__entry->crosslinked = crosslinked;
1121 	),
1122 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x crosslinked %d",
1123 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1124 		  __entry->agno,
1125 		  __entry->agbno,
1126 		  __entry->len,
1127 		  __entry->crosslinked ? 1 : 0)
1128 );
1129 #define DEFINE_REPAIR_REAP_FIND_EVENT(name) \
1130 DEFINE_EVENT(xrep_reap_find_class, name, \
1131 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len, \
1132 		 bool crosslinked), \
1133 	TP_ARGS(pag, agbno, len, crosslinked))
1134 DEFINE_REPAIR_REAP_FIND_EVENT(xreap_agextent_select);
1135 
1136 DECLARE_EVENT_CLASS(xrep_rmap_class,
1137 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1138 		 xfs_agblock_t agbno, xfs_extlen_t len,
1139 		 uint64_t owner, uint64_t offset, unsigned int flags),
1140 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
1141 	TP_STRUCT__entry(
1142 		__field(dev_t, dev)
1143 		__field(xfs_agnumber_t, agno)
1144 		__field(xfs_agblock_t, agbno)
1145 		__field(xfs_extlen_t, len)
1146 		__field(uint64_t, owner)
1147 		__field(uint64_t, offset)
1148 		__field(unsigned int, flags)
1149 	),
1150 	TP_fast_assign(
1151 		__entry->dev = mp->m_super->s_dev;
1152 		__entry->agno = agno;
1153 		__entry->agbno = agbno;
1154 		__entry->len = len;
1155 		__entry->owner = owner;
1156 		__entry->offset = offset;
1157 		__entry->flags = flags;
1158 	),
1159 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%x",
1160 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1161 		  __entry->agno,
1162 		  __entry->agbno,
1163 		  __entry->len,
1164 		  __entry->owner,
1165 		  __entry->offset,
1166 		  __entry->flags)
1167 );
1168 #define DEFINE_REPAIR_RMAP_EVENT(name) \
1169 DEFINE_EVENT(xrep_rmap_class, name, \
1170 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1171 		 xfs_agblock_t agbno, xfs_extlen_t len, \
1172 		 uint64_t owner, uint64_t offset, unsigned int flags), \
1173 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
1174 DEFINE_REPAIR_RMAP_EVENT(xrep_alloc_extent_fn);
1175 DEFINE_REPAIR_RMAP_EVENT(xrep_ialloc_extent_fn);
1176 DEFINE_REPAIR_RMAP_EVENT(xrep_rmap_extent_fn);
1177 DEFINE_REPAIR_RMAP_EVENT(xrep_bmap_extent_fn);
1178 
1179 TRACE_EVENT(xrep_refcount_extent_fn,
1180 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1181 		 struct xfs_refcount_irec *irec),
1182 	TP_ARGS(mp, agno, irec),
1183 	TP_STRUCT__entry(
1184 		__field(dev_t, dev)
1185 		__field(xfs_agnumber_t, agno)
1186 		__field(xfs_agblock_t, startblock)
1187 		__field(xfs_extlen_t, blockcount)
1188 		__field(xfs_nlink_t, refcount)
1189 	),
1190 	TP_fast_assign(
1191 		__entry->dev = mp->m_super->s_dev;
1192 		__entry->agno = agno;
1193 		__entry->startblock = irec->rc_startblock;
1194 		__entry->blockcount = irec->rc_blockcount;
1195 		__entry->refcount = irec->rc_refcount;
1196 	),
1197 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x refcount %u",
1198 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1199 		  __entry->agno,
1200 		  __entry->startblock,
1201 		  __entry->blockcount,
1202 		  __entry->refcount)
1203 )
1204 
1205 TRACE_EVENT(xrep_findroot_block,
1206 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
1207 		 uint32_t magic, uint16_t level),
1208 	TP_ARGS(mp, agno, agbno, magic, level),
1209 	TP_STRUCT__entry(
1210 		__field(dev_t, dev)
1211 		__field(xfs_agnumber_t, agno)
1212 		__field(xfs_agblock_t, agbno)
1213 		__field(uint32_t, magic)
1214 		__field(uint16_t, level)
1215 	),
1216 	TP_fast_assign(
1217 		__entry->dev = mp->m_super->s_dev;
1218 		__entry->agno = agno;
1219 		__entry->agbno = agbno;
1220 		__entry->magic = magic;
1221 		__entry->level = level;
1222 	),
1223 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x magic 0x%x level %u",
1224 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1225 		  __entry->agno,
1226 		  __entry->agbno,
1227 		  __entry->magic,
1228 		  __entry->level)
1229 )
1230 TRACE_EVENT(xrep_calc_ag_resblks,
1231 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1232 		 xfs_agino_t icount, xfs_agblock_t aglen, xfs_agblock_t freelen,
1233 		 xfs_agblock_t usedlen),
1234 	TP_ARGS(mp, agno, icount, aglen, freelen, usedlen),
1235 	TP_STRUCT__entry(
1236 		__field(dev_t, dev)
1237 		__field(xfs_agnumber_t, agno)
1238 		__field(xfs_agino_t, icount)
1239 		__field(xfs_agblock_t, aglen)
1240 		__field(xfs_agblock_t, freelen)
1241 		__field(xfs_agblock_t, usedlen)
1242 	),
1243 	TP_fast_assign(
1244 		__entry->dev = mp->m_super->s_dev;
1245 		__entry->agno = agno;
1246 		__entry->icount = icount;
1247 		__entry->aglen = aglen;
1248 		__entry->freelen = freelen;
1249 		__entry->usedlen = usedlen;
1250 	),
1251 	TP_printk("dev %d:%d agno 0x%x icount %u aglen %u freelen %u usedlen %u",
1252 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1253 		  __entry->agno,
1254 		  __entry->icount,
1255 		  __entry->aglen,
1256 		  __entry->freelen,
1257 		  __entry->usedlen)
1258 )
1259 TRACE_EVENT(xrep_calc_ag_resblks_btsize,
1260 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1261 		 xfs_agblock_t bnobt_sz, xfs_agblock_t inobt_sz,
1262 		 xfs_agblock_t rmapbt_sz, xfs_agblock_t refcbt_sz),
1263 	TP_ARGS(mp, agno, bnobt_sz, inobt_sz, rmapbt_sz, refcbt_sz),
1264 	TP_STRUCT__entry(
1265 		__field(dev_t, dev)
1266 		__field(xfs_agnumber_t, agno)
1267 		__field(xfs_agblock_t, bnobt_sz)
1268 		__field(xfs_agblock_t, inobt_sz)
1269 		__field(xfs_agblock_t, rmapbt_sz)
1270 		__field(xfs_agblock_t, refcbt_sz)
1271 	),
1272 	TP_fast_assign(
1273 		__entry->dev = mp->m_super->s_dev;
1274 		__entry->agno = agno;
1275 		__entry->bnobt_sz = bnobt_sz;
1276 		__entry->inobt_sz = inobt_sz;
1277 		__entry->rmapbt_sz = rmapbt_sz;
1278 		__entry->refcbt_sz = refcbt_sz;
1279 	),
1280 	TP_printk("dev %d:%d agno 0x%x bnobt %u inobt %u rmapbt %u refcountbt %u",
1281 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1282 		  __entry->agno,
1283 		  __entry->bnobt_sz,
1284 		  __entry->inobt_sz,
1285 		  __entry->rmapbt_sz,
1286 		  __entry->refcbt_sz)
1287 )
1288 TRACE_EVENT(xrep_reset_counters,
1289 	TP_PROTO(struct xfs_mount *mp),
1290 	TP_ARGS(mp),
1291 	TP_STRUCT__entry(
1292 		__field(dev_t, dev)
1293 	),
1294 	TP_fast_assign(
1295 		__entry->dev = mp->m_super->s_dev;
1296 	),
1297 	TP_printk("dev %d:%d",
1298 		  MAJOR(__entry->dev), MINOR(__entry->dev))
1299 )
1300 
1301 TRACE_EVENT(xrep_ialloc_insert,
1302 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1303 		 xfs_agino_t startino, uint16_t holemask, uint8_t count,
1304 		 uint8_t freecount, uint64_t freemask),
1305 	TP_ARGS(mp, agno, startino, holemask, count, freecount, freemask),
1306 	TP_STRUCT__entry(
1307 		__field(dev_t, dev)
1308 		__field(xfs_agnumber_t, agno)
1309 		__field(xfs_agino_t, startino)
1310 		__field(uint16_t, holemask)
1311 		__field(uint8_t, count)
1312 		__field(uint8_t, freecount)
1313 		__field(uint64_t, freemask)
1314 	),
1315 	TP_fast_assign(
1316 		__entry->dev = mp->m_super->s_dev;
1317 		__entry->agno = agno;
1318 		__entry->startino = startino;
1319 		__entry->holemask = holemask;
1320 		__entry->count = count;
1321 		__entry->freecount = freecount;
1322 		__entry->freemask = freemask;
1323 	),
1324 	TP_printk("dev %d:%d agno 0x%x startino 0x%x holemask 0x%x count %u freecount %u freemask 0x%llx",
1325 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1326 		  __entry->agno,
1327 		  __entry->startino,
1328 		  __entry->holemask,
1329 		  __entry->count,
1330 		  __entry->freecount,
1331 		  __entry->freemask)
1332 )
1333 
1334 #endif /* IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) */
1335 
1336 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
1337 
1338 #undef TRACE_INCLUDE_PATH
1339 #define TRACE_INCLUDE_PATH .
1340 #define TRACE_INCLUDE_FILE scrub/trace
1341 #include <trace/define_trace.h>
1342