xref: /linux/fs/xfs/scrub/trace.h (revision e6a901a00822659181c93c86d8bbc2a17779fddc)
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 #include "xfs_quota_defs.h"
19 
20 struct xfs_scrub;
21 struct xfile;
22 struct xfarray;
23 struct xfarray_sortinfo;
24 struct xchk_dqiter;
25 struct xchk_iscan;
26 struct xchk_nlink;
27 struct xchk_fscounters;
28 struct xfs_rmap_update_params;
29 
30 /*
31  * ftrace's __print_symbolic requires that all enum values be wrapped in the
32  * TRACE_DEFINE_ENUM macro so that the enum value can be encoded in the ftrace
33  * ring buffer.  Somehow this was only worth mentioning in the ftrace sample
34  * code.
35  */
36 TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_SHARED);
37 TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_COW);
38 
39 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PROBE);
40 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SB);
41 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGF);
42 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGFL);
43 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGI);
44 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BNOBT);
45 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_CNTBT);
46 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INOBT);
47 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FINOBT);
48 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RMAPBT);
49 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_REFCNTBT);
50 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INODE);
51 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTD);
52 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTA);
53 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTC);
54 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_DIR);
55 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_XATTR);
56 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SYMLINK);
57 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PARENT);
58 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTBITMAP);
59 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTSUM);
60 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_UQUOTA);
61 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_GQUOTA);
62 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PQUOTA);
63 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FSCOUNTERS);
64 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_QUOTACHECK);
65 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_NLINKS);
66 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_HEALTHY);
67 
68 #define XFS_SCRUB_TYPE_STRINGS \
69 	{ XFS_SCRUB_TYPE_PROBE,		"probe" }, \
70 	{ XFS_SCRUB_TYPE_SB,		"sb" }, \
71 	{ XFS_SCRUB_TYPE_AGF,		"agf" }, \
72 	{ XFS_SCRUB_TYPE_AGFL,		"agfl" }, \
73 	{ XFS_SCRUB_TYPE_AGI,		"agi" }, \
74 	{ XFS_SCRUB_TYPE_BNOBT,		"bnobt" }, \
75 	{ XFS_SCRUB_TYPE_CNTBT,		"cntbt" }, \
76 	{ XFS_SCRUB_TYPE_INOBT,		"inobt" }, \
77 	{ XFS_SCRUB_TYPE_FINOBT,	"finobt" }, \
78 	{ XFS_SCRUB_TYPE_RMAPBT,	"rmapbt" }, \
79 	{ XFS_SCRUB_TYPE_REFCNTBT,	"refcountbt" }, \
80 	{ XFS_SCRUB_TYPE_INODE,		"inode" }, \
81 	{ XFS_SCRUB_TYPE_BMBTD,		"bmapbtd" }, \
82 	{ XFS_SCRUB_TYPE_BMBTA,		"bmapbta" }, \
83 	{ XFS_SCRUB_TYPE_BMBTC,		"bmapbtc" }, \
84 	{ XFS_SCRUB_TYPE_DIR,		"directory" }, \
85 	{ XFS_SCRUB_TYPE_XATTR,		"xattr" }, \
86 	{ XFS_SCRUB_TYPE_SYMLINK,	"symlink" }, \
87 	{ XFS_SCRUB_TYPE_PARENT,	"parent" }, \
88 	{ XFS_SCRUB_TYPE_RTBITMAP,	"rtbitmap" }, \
89 	{ XFS_SCRUB_TYPE_RTSUM,		"rtsummary" }, \
90 	{ XFS_SCRUB_TYPE_UQUOTA,	"usrquota" }, \
91 	{ XFS_SCRUB_TYPE_GQUOTA,	"grpquota" }, \
92 	{ XFS_SCRUB_TYPE_PQUOTA,	"prjquota" }, \
93 	{ XFS_SCRUB_TYPE_FSCOUNTERS,	"fscounters" }, \
94 	{ XFS_SCRUB_TYPE_QUOTACHECK,	"quotacheck" }, \
95 	{ XFS_SCRUB_TYPE_NLINKS,	"nlinks" }, \
96 	{ XFS_SCRUB_TYPE_HEALTHY,	"healthy" }
97 
98 #define XFS_SCRUB_FLAG_STRINGS \
99 	{ XFS_SCRUB_IFLAG_REPAIR,		"repair" }, \
100 	{ XFS_SCRUB_OFLAG_CORRUPT,		"corrupt" }, \
101 	{ XFS_SCRUB_OFLAG_PREEN,		"preen" }, \
102 	{ XFS_SCRUB_OFLAG_XFAIL,		"xfail" }, \
103 	{ XFS_SCRUB_OFLAG_XCORRUPT,		"xcorrupt" }, \
104 	{ XFS_SCRUB_OFLAG_INCOMPLETE,		"incomplete" }, \
105 	{ XFS_SCRUB_OFLAG_WARNING,		"warning" }, \
106 	{ XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED,	"norepair" }, \
107 	{ XFS_SCRUB_IFLAG_FORCE_REBUILD,	"rebuild" }
108 
109 #define XFS_SCRUB_STATE_STRINGS \
110 	{ XCHK_TRY_HARDER,			"try_harder" }, \
111 	{ XCHK_HAVE_FREEZE_PROT,		"nofreeze" }, \
112 	{ XCHK_FSGATES_DRAIN,			"fsgates_drain" }, \
113 	{ XCHK_NEED_DRAIN,			"need_drain" }, \
114 	{ XCHK_FSGATES_QUOTA,			"fsgates_quota" }, \
115 	{ XCHK_FSGATES_DIRENTS,			"fsgates_dirents" }, \
116 	{ XCHK_FSGATES_RMAP,			"fsgates_rmap" }, \
117 	{ XREP_RESET_PERAG_RESV,		"reset_perag_resv" }, \
118 	{ XREP_ALREADY_FIXED,			"already_fixed" }
119 
120 TRACE_DEFINE_ENUM(XFS_RMAP_MAP);
121 TRACE_DEFINE_ENUM(XFS_RMAP_MAP_SHARED);
122 TRACE_DEFINE_ENUM(XFS_RMAP_UNMAP);
123 TRACE_DEFINE_ENUM(XFS_RMAP_UNMAP_SHARED);
124 TRACE_DEFINE_ENUM(XFS_RMAP_CONVERT);
125 TRACE_DEFINE_ENUM(XFS_RMAP_CONVERT_SHARED);
126 TRACE_DEFINE_ENUM(XFS_RMAP_ALLOC);
127 TRACE_DEFINE_ENUM(XFS_RMAP_FREE);
128 
129 DECLARE_EVENT_CLASS(xchk_class,
130 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm,
131 		 int error),
132 	TP_ARGS(ip, sm, error),
133 	TP_STRUCT__entry(
134 		__field(dev_t, dev)
135 		__field(xfs_ino_t, ino)
136 		__field(unsigned int, type)
137 		__field(xfs_agnumber_t, agno)
138 		__field(xfs_ino_t, inum)
139 		__field(unsigned int, gen)
140 		__field(unsigned int, flags)
141 		__field(int, error)
142 	),
143 	TP_fast_assign(
144 		__entry->dev = ip->i_mount->m_super->s_dev;
145 		__entry->ino = ip->i_ino;
146 		__entry->type = sm->sm_type;
147 		__entry->agno = sm->sm_agno;
148 		__entry->inum = sm->sm_ino;
149 		__entry->gen = sm->sm_gen;
150 		__entry->flags = sm->sm_flags;
151 		__entry->error = error;
152 	),
153 	TP_printk("dev %d:%d ino 0x%llx type %s agno 0x%x inum 0x%llx gen 0x%x flags (%s) error %d",
154 		  MAJOR(__entry->dev), MINOR(__entry->dev),
155 		  __entry->ino,
156 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
157 		  __entry->agno,
158 		  __entry->inum,
159 		  __entry->gen,
160 		  __print_flags(__entry->flags, "|", XFS_SCRUB_FLAG_STRINGS),
161 		  __entry->error)
162 )
163 #define DEFINE_SCRUB_EVENT(name) \
164 DEFINE_EVENT(xchk_class, name, \
165 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, \
166 		 int error), \
167 	TP_ARGS(ip, sm, error))
168 
169 DEFINE_SCRUB_EVENT(xchk_start);
170 DEFINE_SCRUB_EVENT(xchk_done);
171 DEFINE_SCRUB_EVENT(xchk_deadlock_retry);
172 DEFINE_SCRUB_EVENT(xrep_attempt);
173 DEFINE_SCRUB_EVENT(xrep_done);
174 
175 DECLARE_EVENT_CLASS(xchk_fsgate_class,
176 	TP_PROTO(struct xfs_scrub *sc, unsigned int fsgate_flags),
177 	TP_ARGS(sc, fsgate_flags),
178 	TP_STRUCT__entry(
179 		__field(dev_t, dev)
180 		__field(unsigned int, type)
181 		__field(unsigned int, fsgate_flags)
182 	),
183 	TP_fast_assign(
184 		__entry->dev = sc->mp->m_super->s_dev;
185 		__entry->type = sc->sm->sm_type;
186 		__entry->fsgate_flags = fsgate_flags;
187 	),
188 	TP_printk("dev %d:%d type %s fsgates '%s'",
189 		  MAJOR(__entry->dev), MINOR(__entry->dev),
190 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
191 		  __print_flags(__entry->fsgate_flags, "|", XFS_SCRUB_STATE_STRINGS))
192 )
193 
194 #define DEFINE_SCRUB_FSHOOK_EVENT(name) \
195 DEFINE_EVENT(xchk_fsgate_class, name, \
196 	TP_PROTO(struct xfs_scrub *sc, unsigned int fsgates_flags), \
197 	TP_ARGS(sc, fsgates_flags))
198 
199 DEFINE_SCRUB_FSHOOK_EVENT(xchk_fsgates_enable);
200 DEFINE_SCRUB_FSHOOK_EVENT(xchk_fsgates_disable);
201 
202 TRACE_EVENT(xchk_op_error,
203 	TP_PROTO(struct xfs_scrub *sc, xfs_agnumber_t agno,
204 		 xfs_agblock_t bno, int error, void *ret_ip),
205 	TP_ARGS(sc, agno, bno, error, ret_ip),
206 	TP_STRUCT__entry(
207 		__field(dev_t, dev)
208 		__field(unsigned int, type)
209 		__field(xfs_agnumber_t, agno)
210 		__field(xfs_agblock_t, bno)
211 		__field(int, error)
212 		__field(void *, ret_ip)
213 	),
214 	TP_fast_assign(
215 		__entry->dev = sc->mp->m_super->s_dev;
216 		__entry->type = sc->sm->sm_type;
217 		__entry->agno = agno;
218 		__entry->bno = bno;
219 		__entry->error = error;
220 		__entry->ret_ip = ret_ip;
221 	),
222 	TP_printk("dev %d:%d type %s agno 0x%x agbno 0x%x error %d ret_ip %pS",
223 		  MAJOR(__entry->dev), MINOR(__entry->dev),
224 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
225 		  __entry->agno,
226 		  __entry->bno,
227 		  __entry->error,
228 		  __entry->ret_ip)
229 );
230 
231 TRACE_EVENT(xchk_file_op_error,
232 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
233 		 xfs_fileoff_t offset, int error, void *ret_ip),
234 	TP_ARGS(sc, whichfork, offset, error, ret_ip),
235 	TP_STRUCT__entry(
236 		__field(dev_t, dev)
237 		__field(xfs_ino_t, ino)
238 		__field(int, whichfork)
239 		__field(unsigned int, type)
240 		__field(xfs_fileoff_t, offset)
241 		__field(int, error)
242 		__field(void *, ret_ip)
243 	),
244 	TP_fast_assign(
245 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
246 		__entry->ino = sc->ip->i_ino;
247 		__entry->whichfork = whichfork;
248 		__entry->type = sc->sm->sm_type;
249 		__entry->offset = offset;
250 		__entry->error = error;
251 		__entry->ret_ip = ret_ip;
252 	),
253 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s fileoff 0x%llx error %d ret_ip %pS",
254 		  MAJOR(__entry->dev), MINOR(__entry->dev),
255 		  __entry->ino,
256 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
257 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
258 		  __entry->offset,
259 		  __entry->error,
260 		  __entry->ret_ip)
261 );
262 
263 DECLARE_EVENT_CLASS(xchk_block_error_class,
264 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, void *ret_ip),
265 	TP_ARGS(sc, daddr, ret_ip),
266 	TP_STRUCT__entry(
267 		__field(dev_t, dev)
268 		__field(unsigned int, type)
269 		__field(xfs_agnumber_t, agno)
270 		__field(xfs_agblock_t, agbno)
271 		__field(void *, ret_ip)
272 	),
273 	TP_fast_assign(
274 		__entry->dev = sc->mp->m_super->s_dev;
275 		__entry->type = sc->sm->sm_type;
276 		__entry->agno = xfs_daddr_to_agno(sc->mp, daddr);
277 		__entry->agbno = xfs_daddr_to_agbno(sc->mp, daddr);
278 		__entry->ret_ip = ret_ip;
279 	),
280 	TP_printk("dev %d:%d type %s agno 0x%x agbno 0x%x ret_ip %pS",
281 		  MAJOR(__entry->dev), MINOR(__entry->dev),
282 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
283 		  __entry->agno,
284 		  __entry->agbno,
285 		  __entry->ret_ip)
286 )
287 
288 #define DEFINE_SCRUB_BLOCK_ERROR_EVENT(name) \
289 DEFINE_EVENT(xchk_block_error_class, name, \
290 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, \
291 		 void *ret_ip), \
292 	TP_ARGS(sc, daddr, ret_ip))
293 
294 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_fs_error);
295 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_error);
296 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_preen);
297 
298 DECLARE_EVENT_CLASS(xchk_ino_error_class,
299 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, void *ret_ip),
300 	TP_ARGS(sc, ino, ret_ip),
301 	TP_STRUCT__entry(
302 		__field(dev_t, dev)
303 		__field(xfs_ino_t, ino)
304 		__field(unsigned int, type)
305 		__field(void *, ret_ip)
306 	),
307 	TP_fast_assign(
308 		__entry->dev = sc->mp->m_super->s_dev;
309 		__entry->ino = ino;
310 		__entry->type = sc->sm->sm_type;
311 		__entry->ret_ip = ret_ip;
312 	),
313 	TP_printk("dev %d:%d ino 0x%llx type %s ret_ip %pS",
314 		  MAJOR(__entry->dev), MINOR(__entry->dev),
315 		  __entry->ino,
316 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
317 		  __entry->ret_ip)
318 )
319 
320 #define DEFINE_SCRUB_INO_ERROR_EVENT(name) \
321 DEFINE_EVENT(xchk_ino_error_class, name, \
322 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, \
323 		 void *ret_ip), \
324 	TP_ARGS(sc, ino, ret_ip))
325 
326 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_error);
327 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_preen);
328 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_warning);
329 
330 DECLARE_EVENT_CLASS(xchk_fblock_error_class,
331 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
332 		 xfs_fileoff_t offset, void *ret_ip),
333 	TP_ARGS(sc, whichfork, offset, ret_ip),
334 	TP_STRUCT__entry(
335 		__field(dev_t, dev)
336 		__field(xfs_ino_t, ino)
337 		__field(int, whichfork)
338 		__field(unsigned int, type)
339 		__field(xfs_fileoff_t, offset)
340 		__field(void *, ret_ip)
341 	),
342 	TP_fast_assign(
343 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
344 		__entry->ino = sc->ip->i_ino;
345 		__entry->whichfork = whichfork;
346 		__entry->type = sc->sm->sm_type;
347 		__entry->offset = offset;
348 		__entry->ret_ip = ret_ip;
349 	),
350 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s fileoff 0x%llx ret_ip %pS",
351 		  MAJOR(__entry->dev), MINOR(__entry->dev),
352 		  __entry->ino,
353 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
354 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
355 		  __entry->offset,
356 		  __entry->ret_ip)
357 );
358 
359 #define DEFINE_SCRUB_FBLOCK_ERROR_EVENT(name) \
360 DEFINE_EVENT(xchk_fblock_error_class, name, \
361 	TP_PROTO(struct xfs_scrub *sc, int whichfork, \
362 		 xfs_fileoff_t offset, void *ret_ip), \
363 	TP_ARGS(sc, whichfork, offset, ret_ip))
364 
365 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_error);
366 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_warning);
367 
368 #ifdef CONFIG_XFS_QUOTA
369 DECLARE_EVENT_CLASS(xchk_dqiter_class,
370 	TP_PROTO(struct xchk_dqiter *cursor, uint64_t id),
371 	TP_ARGS(cursor, id),
372 	TP_STRUCT__entry(
373 		__field(dev_t, dev)
374 		__field(xfs_dqtype_t, dqtype)
375 		__field(xfs_ino_t, ino)
376 		__field(unsigned long long, cur_id)
377 		__field(unsigned long long, id)
378 		__field(xfs_fileoff_t, startoff)
379 		__field(xfs_fsblock_t, startblock)
380 		__field(xfs_filblks_t, blockcount)
381 		__field(xfs_exntst_t, state)
382 	),
383 	TP_fast_assign(
384 		__entry->dev = cursor->sc->ip->i_mount->m_super->s_dev;
385 		__entry->dqtype = cursor->dqtype;
386 		__entry->ino = cursor->quota_ip->i_ino;
387 		__entry->cur_id = cursor->id;
388 		__entry->startoff = cursor->bmap.br_startoff;
389 		__entry->startblock = cursor->bmap.br_startblock;
390 		__entry->blockcount = cursor->bmap.br_blockcount;
391 		__entry->state = cursor->bmap.br_state;
392 		__entry->id = id;
393 	),
394 	TP_printk("dev %d:%d dquot type %s ino 0x%llx cursor_id 0x%llx startoff 0x%llx startblock 0x%llx blockcount 0x%llx state %u id 0x%llx",
395 		  MAJOR(__entry->dev), MINOR(__entry->dev),
396 		  __print_symbolic(__entry->dqtype, XFS_DQTYPE_STRINGS),
397 		  __entry->ino,
398 		  __entry->cur_id,
399 		  __entry->startoff,
400 		  __entry->startblock,
401 		  __entry->blockcount,
402 		  __entry->state,
403 		  __entry->id)
404 );
405 
406 #define DEFINE_SCRUB_DQITER_EVENT(name) \
407 DEFINE_EVENT(xchk_dqiter_class, name, \
408 	TP_PROTO(struct xchk_dqiter *cursor, uint64_t id), \
409 	TP_ARGS(cursor, id))
410 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter_revalidate_bmap);
411 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter_advance_bmap);
412 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter_advance_incore);
413 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter);
414 
415 TRACE_EVENT(xchk_qcheck_error,
416 	TP_PROTO(struct xfs_scrub *sc, xfs_dqtype_t dqtype, xfs_dqid_t id,
417 		 void *ret_ip),
418 	TP_ARGS(sc, dqtype, id, ret_ip),
419 	TP_STRUCT__entry(
420 		__field(dev_t, dev)
421 		__field(xfs_dqtype_t, dqtype)
422 		__field(xfs_dqid_t, id)
423 		__field(void *, ret_ip)
424 	),
425 	TP_fast_assign(
426 		__entry->dev = sc->mp->m_super->s_dev;
427 		__entry->dqtype = dqtype;
428 		__entry->id = id;
429 		__entry->ret_ip = ret_ip;
430 	),
431 	TP_printk("dev %d:%d dquot type %s id 0x%x ret_ip %pS",
432 		  MAJOR(__entry->dev), MINOR(__entry->dev),
433 		  __print_symbolic(__entry->dqtype, XFS_DQTYPE_STRINGS),
434 		  __entry->id,
435 		  __entry->ret_ip)
436 );
437 #endif /* CONFIG_XFS_QUOTA */
438 
439 TRACE_EVENT(xchk_incomplete,
440 	TP_PROTO(struct xfs_scrub *sc, void *ret_ip),
441 	TP_ARGS(sc, ret_ip),
442 	TP_STRUCT__entry(
443 		__field(dev_t, dev)
444 		__field(unsigned int, type)
445 		__field(void *, ret_ip)
446 	),
447 	TP_fast_assign(
448 		__entry->dev = sc->mp->m_super->s_dev;
449 		__entry->type = sc->sm->sm_type;
450 		__entry->ret_ip = ret_ip;
451 	),
452 	TP_printk("dev %d:%d type %s ret_ip %pS",
453 		  MAJOR(__entry->dev), MINOR(__entry->dev),
454 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
455 		  __entry->ret_ip)
456 );
457 
458 TRACE_EVENT(xchk_btree_op_error,
459 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
460 		 int level, int error, void *ret_ip),
461 	TP_ARGS(sc, cur, level, error, ret_ip),
462 	TP_STRUCT__entry(
463 		__field(dev_t, dev)
464 		__field(unsigned int, type)
465 		__string(name, cur->bc_ops->name)
466 		__field(int, level)
467 		__field(xfs_agnumber_t, agno)
468 		__field(xfs_agblock_t, bno)
469 		__field(int, ptr)
470 		__field(int, error)
471 		__field(void *, ret_ip)
472 	),
473 	TP_fast_assign(
474 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
475 
476 		__entry->dev = sc->mp->m_super->s_dev;
477 		__entry->type = sc->sm->sm_type;
478 		__assign_str(name, cur->bc_ops->name);
479 		__entry->level = level;
480 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
481 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
482 		__entry->ptr = cur->bc_levels[level].ptr;
483 		__entry->error = error;
484 		__entry->ret_ip = ret_ip;
485 	),
486 	TP_printk("dev %d:%d type %s %sbt level %d ptr %d agno 0x%x agbno 0x%x error %d ret_ip %pS",
487 		  MAJOR(__entry->dev), MINOR(__entry->dev),
488 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
489 		  __get_str(name),
490 		  __entry->level,
491 		  __entry->ptr,
492 		  __entry->agno,
493 		  __entry->bno,
494 		  __entry->error,
495 		  __entry->ret_ip)
496 );
497 
498 TRACE_EVENT(xchk_ifork_btree_op_error,
499 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
500 		 int level, int error, void *ret_ip),
501 	TP_ARGS(sc, cur, level, error, ret_ip),
502 	TP_STRUCT__entry(
503 		__field(dev_t, dev)
504 		__field(xfs_ino_t, ino)
505 		__field(int, whichfork)
506 		__field(unsigned int, type)
507 		__string(name, cur->bc_ops->name)
508 		__field(int, level)
509 		__field(int, ptr)
510 		__field(xfs_agnumber_t, agno)
511 		__field(xfs_agblock_t, bno)
512 		__field(int, error)
513 		__field(void *, ret_ip)
514 	),
515 	TP_fast_assign(
516 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
517 		__entry->dev = sc->mp->m_super->s_dev;
518 		__entry->ino = sc->ip->i_ino;
519 		__entry->whichfork = cur->bc_ino.whichfork;
520 		__entry->type = sc->sm->sm_type;
521 		__assign_str(name, cur->bc_ops->name);
522 		__entry->level = level;
523 		__entry->ptr = cur->bc_levels[level].ptr;
524 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
525 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
526 		__entry->error = error;
527 		__entry->ret_ip = ret_ip;
528 	),
529 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s %sbt level %d ptr %d agno 0x%x agbno 0x%x error %d ret_ip %pS",
530 		  MAJOR(__entry->dev), MINOR(__entry->dev),
531 		  __entry->ino,
532 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
533 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
534 		  __get_str(name),
535 		  __entry->level,
536 		  __entry->ptr,
537 		  __entry->agno,
538 		  __entry->bno,
539 		  __entry->error,
540 		  __entry->ret_ip)
541 );
542 
543 TRACE_EVENT(xchk_btree_error,
544 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
545 		 int level, void *ret_ip),
546 	TP_ARGS(sc, cur, level, ret_ip),
547 	TP_STRUCT__entry(
548 		__field(dev_t, dev)
549 		__field(unsigned int, type)
550 		__string(name, cur->bc_ops->name)
551 		__field(int, level)
552 		__field(xfs_agnumber_t, agno)
553 		__field(xfs_agblock_t, bno)
554 		__field(int, ptr)
555 		__field(void *, ret_ip)
556 	),
557 	TP_fast_assign(
558 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
559 		__entry->dev = sc->mp->m_super->s_dev;
560 		__entry->type = sc->sm->sm_type;
561 		__assign_str(name, cur->bc_ops->name);
562 		__entry->level = level;
563 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
564 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
565 		__entry->ptr = cur->bc_levels[level].ptr;
566 		__entry->ret_ip = ret_ip;
567 	),
568 	TP_printk("dev %d:%d type %s %sbt level %d ptr %d agno 0x%x agbno 0x%x ret_ip %pS",
569 		  MAJOR(__entry->dev), MINOR(__entry->dev),
570 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
571 		  __get_str(name),
572 		  __entry->level,
573 		  __entry->ptr,
574 		  __entry->agno,
575 		  __entry->bno,
576 		  __entry->ret_ip)
577 );
578 
579 TRACE_EVENT(xchk_ifork_btree_error,
580 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
581 		 int level, void *ret_ip),
582 	TP_ARGS(sc, cur, level, ret_ip),
583 	TP_STRUCT__entry(
584 		__field(dev_t, dev)
585 		__field(xfs_ino_t, ino)
586 		__field(int, whichfork)
587 		__field(unsigned int, type)
588 		__string(name, cur->bc_ops->name)
589 		__field(int, level)
590 		__field(xfs_agnumber_t, agno)
591 		__field(xfs_agblock_t, bno)
592 		__field(int, ptr)
593 		__field(void *, ret_ip)
594 	),
595 	TP_fast_assign(
596 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
597 		__entry->dev = sc->mp->m_super->s_dev;
598 		__entry->ino = sc->ip->i_ino;
599 		__entry->whichfork = cur->bc_ino.whichfork;
600 		__entry->type = sc->sm->sm_type;
601 		__assign_str(name, cur->bc_ops->name);
602 		__entry->level = level;
603 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
604 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
605 		__entry->ptr = cur->bc_levels[level].ptr;
606 		__entry->ret_ip = ret_ip;
607 	),
608 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s %sbt level %d ptr %d agno 0x%x agbno 0x%x ret_ip %pS",
609 		  MAJOR(__entry->dev), MINOR(__entry->dev),
610 		  __entry->ino,
611 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
612 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
613 		  __get_str(name),
614 		  __entry->level,
615 		  __entry->ptr,
616 		  __entry->agno,
617 		  __entry->bno,
618 		  __entry->ret_ip)
619 );
620 
621 DECLARE_EVENT_CLASS(xchk_sbtree_class,
622 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
623 		 int level),
624 	TP_ARGS(sc, cur, level),
625 	TP_STRUCT__entry(
626 		__field(dev_t, dev)
627 		__field(int, type)
628 		__string(name, cur->bc_ops->name)
629 		__field(xfs_agnumber_t, agno)
630 		__field(xfs_agblock_t, bno)
631 		__field(int, level)
632 		__field(int, nlevels)
633 		__field(int, ptr)
634 	),
635 	TP_fast_assign(
636 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
637 
638 		__entry->dev = sc->mp->m_super->s_dev;
639 		__entry->type = sc->sm->sm_type;
640 		__assign_str(name, cur->bc_ops->name);
641 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
642 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
643 		__entry->level = level;
644 		__entry->nlevels = cur->bc_nlevels;
645 		__entry->ptr = cur->bc_levels[level].ptr;
646 	),
647 	TP_printk("dev %d:%d type %s %sbt agno 0x%x agbno 0x%x level %d nlevels %d ptr %d",
648 		  MAJOR(__entry->dev), MINOR(__entry->dev),
649 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
650 		  __get_str(name),
651 		  __entry->agno,
652 		  __entry->bno,
653 		  __entry->level,
654 		  __entry->nlevels,
655 		  __entry->ptr)
656 )
657 #define DEFINE_SCRUB_SBTREE_EVENT(name) \
658 DEFINE_EVENT(xchk_sbtree_class, name, \
659 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur, \
660 		 int level), \
661 	TP_ARGS(sc, cur, level))
662 
663 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_rec);
664 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_key);
665 
666 TRACE_EVENT(xchk_xref_error,
667 	TP_PROTO(struct xfs_scrub *sc, int error, void *ret_ip),
668 	TP_ARGS(sc, error, ret_ip),
669 	TP_STRUCT__entry(
670 		__field(dev_t, dev)
671 		__field(int, type)
672 		__field(int, error)
673 		__field(void *, ret_ip)
674 	),
675 	TP_fast_assign(
676 		__entry->dev = sc->mp->m_super->s_dev;
677 		__entry->type = sc->sm->sm_type;
678 		__entry->error = error;
679 		__entry->ret_ip = ret_ip;
680 	),
681 	TP_printk("dev %d:%d type %s xref error %d ret_ip %pS",
682 		  MAJOR(__entry->dev), MINOR(__entry->dev),
683 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
684 		  __entry->error,
685 		  __entry->ret_ip)
686 );
687 
688 TRACE_EVENT(xchk_iallocbt_check_cluster,
689 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
690 		 xfs_agino_t startino, xfs_daddr_t map_daddr,
691 		 unsigned short map_len, unsigned int chunk_ino,
692 		 unsigned int nr_inodes, uint16_t cluster_mask,
693 		 uint16_t holemask, unsigned int cluster_ino),
694 	TP_ARGS(mp, agno, startino, map_daddr, map_len, chunk_ino, nr_inodes,
695 		cluster_mask, holemask, cluster_ino),
696 	TP_STRUCT__entry(
697 		__field(dev_t, dev)
698 		__field(xfs_agnumber_t, agno)
699 		__field(xfs_agino_t, startino)
700 		__field(xfs_daddr_t, map_daddr)
701 		__field(unsigned short, map_len)
702 		__field(unsigned int, chunk_ino)
703 		__field(unsigned int, nr_inodes)
704 		__field(unsigned int, cluster_ino)
705 		__field(uint16_t, cluster_mask)
706 		__field(uint16_t, holemask)
707 	),
708 	TP_fast_assign(
709 		__entry->dev = mp->m_super->s_dev;
710 		__entry->agno = agno;
711 		__entry->startino = startino;
712 		__entry->map_daddr = map_daddr;
713 		__entry->map_len = map_len;
714 		__entry->chunk_ino = chunk_ino;
715 		__entry->nr_inodes = nr_inodes;
716 		__entry->cluster_mask = cluster_mask;
717 		__entry->holemask = holemask;
718 		__entry->cluster_ino = cluster_ino;
719 	),
720 	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",
721 		  MAJOR(__entry->dev), MINOR(__entry->dev),
722 		  __entry->agno,
723 		  __entry->startino,
724 		  __entry->map_daddr,
725 		  __entry->map_len,
726 		  __entry->chunk_ino,
727 		  __entry->nr_inodes,
728 		  __entry->cluster_mask,
729 		  __entry->holemask,
730 		  __entry->cluster_ino)
731 )
732 
733 TRACE_EVENT(xchk_inode_is_allocated,
734 	TP_PROTO(struct xfs_inode *ip),
735 	TP_ARGS(ip),
736 	TP_STRUCT__entry(
737 		__field(dev_t, dev)
738 		__field(xfs_ino_t, ino)
739 		__field(unsigned long, iflags)
740 		__field(umode_t, mode)
741 	),
742 	TP_fast_assign(
743 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
744 		__entry->ino = ip->i_ino;
745 		__entry->iflags = ip->i_flags;
746 		__entry->mode = VFS_I(ip)->i_mode;
747 	),
748 	TP_printk("dev %d:%d ino 0x%llx iflags 0x%lx mode 0x%x",
749 		  MAJOR(__entry->dev), MINOR(__entry->dev),
750 		  __entry->ino,
751 		  __entry->iflags,
752 		  __entry->mode)
753 );
754 
755 TRACE_EVENT(xchk_fscounters_calc,
756 	TP_PROTO(struct xfs_mount *mp, uint64_t icount, uint64_t ifree,
757 		 uint64_t fdblocks, uint64_t delalloc),
758 	TP_ARGS(mp, icount, ifree, fdblocks, delalloc),
759 	TP_STRUCT__entry(
760 		__field(dev_t, dev)
761 		__field(int64_t, icount_sb)
762 		__field(uint64_t, icount_calculated)
763 		__field(int64_t, ifree_sb)
764 		__field(uint64_t, ifree_calculated)
765 		__field(int64_t, fdblocks_sb)
766 		__field(uint64_t, fdblocks_calculated)
767 		__field(uint64_t, delalloc)
768 	),
769 	TP_fast_assign(
770 		__entry->dev = mp->m_super->s_dev;
771 		__entry->icount_sb = mp->m_sb.sb_icount;
772 		__entry->icount_calculated = icount;
773 		__entry->ifree_sb = mp->m_sb.sb_ifree;
774 		__entry->ifree_calculated = ifree;
775 		__entry->fdblocks_sb = mp->m_sb.sb_fdblocks;
776 		__entry->fdblocks_calculated = fdblocks;
777 		__entry->delalloc = delalloc;
778 	),
779 	TP_printk("dev %d:%d icount %lld:%llu ifree %lld::%llu fdblocks %lld::%llu delalloc %llu",
780 		  MAJOR(__entry->dev), MINOR(__entry->dev),
781 		  __entry->icount_sb,
782 		  __entry->icount_calculated,
783 		  __entry->ifree_sb,
784 		  __entry->ifree_calculated,
785 		  __entry->fdblocks_sb,
786 		  __entry->fdblocks_calculated,
787 		  __entry->delalloc)
788 )
789 
790 TRACE_EVENT(xchk_fscounters_within_range,
791 	TP_PROTO(struct xfs_mount *mp, uint64_t expected, int64_t curr_value,
792 		 int64_t old_value),
793 	TP_ARGS(mp, expected, curr_value, old_value),
794 	TP_STRUCT__entry(
795 		__field(dev_t, dev)
796 		__field(uint64_t, expected)
797 		__field(int64_t, curr_value)
798 		__field(int64_t, old_value)
799 	),
800 	TP_fast_assign(
801 		__entry->dev = mp->m_super->s_dev;
802 		__entry->expected = expected;
803 		__entry->curr_value = curr_value;
804 		__entry->old_value = old_value;
805 	),
806 	TP_printk("dev %d:%d expected %llu curr_value %lld old_value %lld",
807 		  MAJOR(__entry->dev), MINOR(__entry->dev),
808 		  __entry->expected,
809 		  __entry->curr_value,
810 		  __entry->old_value)
811 )
812 
813 DECLARE_EVENT_CLASS(xchk_fsfreeze_class,
814 	TP_PROTO(struct xfs_scrub *sc, int error),
815 	TP_ARGS(sc, error),
816 	TP_STRUCT__entry(
817 		__field(dev_t, dev)
818 		__field(unsigned int, type)
819 		__field(int, error)
820 	),
821 	TP_fast_assign(
822 		__entry->dev = sc->mp->m_super->s_dev;
823 		__entry->type = sc->sm->sm_type;
824 		__entry->error = error;
825 	),
826 	TP_printk("dev %d:%d type %s error %d",
827 		  MAJOR(__entry->dev), MINOR(__entry->dev),
828 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
829 		  __entry->error)
830 );
831 #define DEFINE_XCHK_FSFREEZE_EVENT(name) \
832 DEFINE_EVENT(xchk_fsfreeze_class, name, \
833 	TP_PROTO(struct xfs_scrub *sc, int error), \
834 	TP_ARGS(sc, error))
835 DEFINE_XCHK_FSFREEZE_EVENT(xchk_fsfreeze);
836 DEFINE_XCHK_FSFREEZE_EVENT(xchk_fsthaw);
837 
838 TRACE_EVENT(xchk_refcount_incorrect,
839 	TP_PROTO(struct xfs_perag *pag, const struct xfs_refcount_irec *irec,
840 		 xfs_nlink_t seen),
841 	TP_ARGS(pag, irec, seen),
842 	TP_STRUCT__entry(
843 		__field(dev_t, dev)
844 		__field(xfs_agnumber_t, agno)
845 		__field(enum xfs_refc_domain, domain)
846 		__field(xfs_agblock_t, startblock)
847 		__field(xfs_extlen_t, blockcount)
848 		__field(xfs_nlink_t, refcount)
849 		__field(xfs_nlink_t, seen)
850 	),
851 	TP_fast_assign(
852 		__entry->dev = pag->pag_mount->m_super->s_dev;
853 		__entry->agno = pag->pag_agno;
854 		__entry->domain = irec->rc_domain;
855 		__entry->startblock = irec->rc_startblock;
856 		__entry->blockcount = irec->rc_blockcount;
857 		__entry->refcount = irec->rc_refcount;
858 		__entry->seen = seen;
859 	),
860 	TP_printk("dev %d:%d agno 0x%x dom %s agbno 0x%x fsbcount 0x%x refcount %u seen %u",
861 		  MAJOR(__entry->dev), MINOR(__entry->dev),
862 		  __entry->agno,
863 		  __print_symbolic(__entry->domain, XFS_REFC_DOMAIN_STRINGS),
864 		  __entry->startblock,
865 		  __entry->blockcount,
866 		  __entry->refcount,
867 		  __entry->seen)
868 )
869 
870 TRACE_EVENT(xfile_create,
871 	TP_PROTO(struct xfile *xf),
872 	TP_ARGS(xf),
873 	TP_STRUCT__entry(
874 		__field(dev_t, dev)
875 		__field(unsigned long, ino)
876 		__array(char, pathname, 256)
877 	),
878 	TP_fast_assign(
879 		char		pathname[257];
880 		char		*path;
881 
882 		__entry->ino = file_inode(xf->file)->i_ino;
883 		memset(pathname, 0, sizeof(pathname));
884 		path = file_path(xf->file, pathname, sizeof(pathname) - 1);
885 		if (IS_ERR(path))
886 			path = "(unknown)";
887 		strncpy(__entry->pathname, path, sizeof(__entry->pathname));
888 	),
889 	TP_printk("xfino 0x%lx path '%s'",
890 		  __entry->ino,
891 		  __entry->pathname)
892 );
893 
894 TRACE_EVENT(xfile_destroy,
895 	TP_PROTO(struct xfile *xf),
896 	TP_ARGS(xf),
897 	TP_STRUCT__entry(
898 		__field(unsigned long, ino)
899 		__field(unsigned long long, bytes)
900 		__field(loff_t, size)
901 	),
902 	TP_fast_assign(
903 		struct inode		*inode = file_inode(xf->file);
904 
905 		__entry->ino = inode->i_ino;
906 		__entry->bytes = inode->i_blocks << SECTOR_SHIFT;
907 		__entry->size = i_size_read(inode);
908 	),
909 	TP_printk("xfino 0x%lx mem_bytes 0x%llx isize 0x%llx",
910 		  __entry->ino,
911 		  __entry->bytes,
912 		  __entry->size)
913 );
914 
915 DECLARE_EVENT_CLASS(xfile_class,
916 	TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount),
917 	TP_ARGS(xf, pos, bytecount),
918 	TP_STRUCT__entry(
919 		__field(unsigned long, ino)
920 		__field(unsigned long long, bytes_used)
921 		__field(loff_t, pos)
922 		__field(loff_t, size)
923 		__field(unsigned long long, bytecount)
924 	),
925 	TP_fast_assign(
926 		struct inode		*inode = file_inode(xf->file);
927 
928 		__entry->ino = inode->i_ino;
929 		__entry->bytes_used = inode->i_blocks << SECTOR_SHIFT;
930 		__entry->pos = pos;
931 		__entry->size = i_size_read(inode);
932 		__entry->bytecount = bytecount;
933 	),
934 	TP_printk("xfino 0x%lx mem_bytes 0x%llx pos 0x%llx bytecount 0x%llx isize 0x%llx",
935 		  __entry->ino,
936 		  __entry->bytes_used,
937 		  __entry->pos,
938 		  __entry->bytecount,
939 		  __entry->size)
940 );
941 #define DEFINE_XFILE_EVENT(name) \
942 DEFINE_EVENT(xfile_class, name, \
943 	TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount), \
944 	TP_ARGS(xf, pos, bytecount))
945 DEFINE_XFILE_EVENT(xfile_load);
946 DEFINE_XFILE_EVENT(xfile_store);
947 DEFINE_XFILE_EVENT(xfile_seek_data);
948 DEFINE_XFILE_EVENT(xfile_get_folio);
949 DEFINE_XFILE_EVENT(xfile_put_folio);
950 
951 TRACE_EVENT(xfarray_create,
952 	TP_PROTO(struct xfarray *xfa, unsigned long long required_capacity),
953 	TP_ARGS(xfa, required_capacity),
954 	TP_STRUCT__entry(
955 		__field(unsigned long, ino)
956 		__field(uint64_t, max_nr)
957 		__field(size_t, obj_size)
958 		__field(int, obj_size_log)
959 		__field(unsigned long long, required_capacity)
960 	),
961 	TP_fast_assign(
962 		__entry->max_nr = xfa->max_nr;
963 		__entry->obj_size = xfa->obj_size;
964 		__entry->obj_size_log = xfa->obj_size_log;
965 		__entry->ino = file_inode(xfa->xfile->file)->i_ino;
966 		__entry->required_capacity = required_capacity;
967 	),
968 	TP_printk("xfino 0x%lx max_nr %llu reqd_nr %llu objsz %zu objszlog %d",
969 		  __entry->ino,
970 		  __entry->max_nr,
971 		  __entry->required_capacity,
972 		  __entry->obj_size,
973 		  __entry->obj_size_log)
974 );
975 
976 TRACE_EVENT(xfarray_isort,
977 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
978 	TP_ARGS(si, lo, hi),
979 	TP_STRUCT__entry(
980 		__field(unsigned long, ino)
981 		__field(unsigned long long, lo)
982 		__field(unsigned long long, hi)
983 	),
984 	TP_fast_assign(
985 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
986 		__entry->lo = lo;
987 		__entry->hi = hi;
988 	),
989 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu",
990 		  __entry->ino,
991 		  __entry->lo,
992 		  __entry->hi,
993 		  __entry->hi - __entry->lo)
994 );
995 
996 TRACE_EVENT(xfarray_foliosort,
997 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
998 	TP_ARGS(si, lo, hi),
999 	TP_STRUCT__entry(
1000 		__field(unsigned long, ino)
1001 		__field(unsigned long long, lo)
1002 		__field(unsigned long long, hi)
1003 	),
1004 	TP_fast_assign(
1005 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1006 		__entry->lo = lo;
1007 		__entry->hi = hi;
1008 	),
1009 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu",
1010 		  __entry->ino,
1011 		  __entry->lo,
1012 		  __entry->hi,
1013 		  __entry->hi - __entry->lo)
1014 );
1015 
1016 TRACE_EVENT(xfarray_qsort,
1017 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
1018 	TP_ARGS(si, lo, hi),
1019 	TP_STRUCT__entry(
1020 		__field(unsigned long, ino)
1021 		__field(unsigned long long, lo)
1022 		__field(unsigned long long, hi)
1023 		__field(int, stack_depth)
1024 		__field(int, max_stack_depth)
1025 	),
1026 	TP_fast_assign(
1027 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1028 		__entry->lo = lo;
1029 		__entry->hi = hi;
1030 		__entry->stack_depth = si->stack_depth;
1031 		__entry->max_stack_depth = si->max_stack_depth;
1032 	),
1033 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu stack %d/%d",
1034 		  __entry->ino,
1035 		  __entry->lo,
1036 		  __entry->hi,
1037 		  __entry->hi - __entry->lo,
1038 		  __entry->stack_depth,
1039 		  __entry->max_stack_depth)
1040 );
1041 
1042 TRACE_EVENT(xfarray_sort,
1043 	TP_PROTO(struct xfarray_sortinfo *si, size_t bytes),
1044 	TP_ARGS(si, bytes),
1045 	TP_STRUCT__entry(
1046 		__field(unsigned long, ino)
1047 		__field(unsigned long long, nr)
1048 		__field(size_t, obj_size)
1049 		__field(size_t, bytes)
1050 		__field(unsigned int, max_stack_depth)
1051 	),
1052 	TP_fast_assign(
1053 		__entry->nr = si->array->nr;
1054 		__entry->obj_size = si->array->obj_size;
1055 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1056 		__entry->bytes = bytes;
1057 		__entry->max_stack_depth = si->max_stack_depth;
1058 	),
1059 	TP_printk("xfino 0x%lx nr %llu objsz %zu stack %u bytes %zu",
1060 		  __entry->ino,
1061 		  __entry->nr,
1062 		  __entry->obj_size,
1063 		  __entry->max_stack_depth,
1064 		  __entry->bytes)
1065 );
1066 
1067 TRACE_EVENT(xfarray_sort_scan,
1068 	TP_PROTO(struct xfarray_sortinfo *si, unsigned long long idx),
1069 	TP_ARGS(si, idx),
1070 	TP_STRUCT__entry(
1071 		__field(unsigned long, ino)
1072 		__field(unsigned long long, nr)
1073 		__field(size_t, obj_size)
1074 		__field(unsigned long long, idx)
1075 		__field(unsigned long long, folio_pos)
1076 		__field(unsigned long, folio_bytes)
1077 		__field(unsigned long long, first_idx)
1078 		__field(unsigned long long, last_idx)
1079 	),
1080 	TP_fast_assign(
1081 		__entry->nr = si->array->nr;
1082 		__entry->obj_size = si->array->obj_size;
1083 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1084 		__entry->idx = idx;
1085 		if (si->folio) {
1086 			__entry->folio_pos = folio_pos(si->folio);
1087 			__entry->folio_bytes = folio_size(si->folio);
1088 			__entry->first_idx = si->first_folio_idx;
1089 			__entry->last_idx = si->last_folio_idx;
1090 		} else {
1091 			__entry->folio_pos = 0;
1092 			__entry->folio_bytes = 0;
1093 			__entry->first_idx = 0;
1094 			__entry->last_idx = 0;
1095 		}
1096 	),
1097 	TP_printk("xfino 0x%lx nr %llu objsz %zu idx %llu folio_pos 0x%llx folio_bytes 0x%lx first_idx %llu last_idx %llu",
1098 		  __entry->ino,
1099 		  __entry->nr,
1100 		  __entry->obj_size,
1101 		  __entry->idx,
1102 		  __entry->folio_pos,
1103 		  __entry->folio_bytes,
1104 		  __entry->first_idx,
1105 		  __entry->last_idx)
1106 );
1107 
1108 TRACE_EVENT(xfarray_sort_stats,
1109 	TP_PROTO(struct xfarray_sortinfo *si, int error),
1110 	TP_ARGS(si, error),
1111 	TP_STRUCT__entry(
1112 		__field(unsigned long, ino)
1113 #ifdef DEBUG
1114 		__field(unsigned long long, loads)
1115 		__field(unsigned long long, stores)
1116 		__field(unsigned long long, compares)
1117 		__field(unsigned long long, heapsorts)
1118 #endif
1119 		__field(unsigned int, max_stack_depth)
1120 		__field(unsigned int, max_stack_used)
1121 		__field(int, error)
1122 	),
1123 	TP_fast_assign(
1124 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1125 #ifdef DEBUG
1126 		__entry->loads = si->loads;
1127 		__entry->stores = si->stores;
1128 		__entry->compares = si->compares;
1129 		__entry->heapsorts = si->heapsorts;
1130 #endif
1131 		__entry->max_stack_depth = si->max_stack_depth;
1132 		__entry->max_stack_used = si->max_stack_used;
1133 		__entry->error = error;
1134 	),
1135 	TP_printk(
1136 #ifdef DEBUG
1137 		  "xfino 0x%lx loads %llu stores %llu compares %llu heapsorts %llu stack_depth %u/%u error %d",
1138 #else
1139 		  "xfino 0x%lx stack_depth %u/%u error %d",
1140 #endif
1141 		  __entry->ino,
1142 #ifdef DEBUG
1143 		  __entry->loads,
1144 		  __entry->stores,
1145 		  __entry->compares,
1146 		  __entry->heapsorts,
1147 #endif
1148 		  __entry->max_stack_used,
1149 		  __entry->max_stack_depth,
1150 		  __entry->error)
1151 );
1152 
1153 #ifdef CONFIG_XFS_RT
1154 TRACE_EVENT(xchk_rtsum_record_free,
1155 	TP_PROTO(struct xfs_mount *mp, xfs_rtxnum_t start,
1156 		 xfs_rtbxlen_t len, unsigned int log, loff_t pos,
1157 		 xfs_suminfo_t value),
1158 	TP_ARGS(mp, start, len, log, pos, value),
1159 	TP_STRUCT__entry(
1160 		__field(dev_t, dev)
1161 		__field(dev_t, rtdev)
1162 		__field(xfs_rtxnum_t, start)
1163 		__field(unsigned long long, len)
1164 		__field(unsigned int, log)
1165 		__field(loff_t, pos)
1166 		__field(xfs_suminfo_t, value)
1167 	),
1168 	TP_fast_assign(
1169 		__entry->dev = mp->m_super->s_dev;
1170 		__entry->rtdev = mp->m_rtdev_targp->bt_dev;
1171 		__entry->start = start;
1172 		__entry->len = len;
1173 		__entry->log = log;
1174 		__entry->pos = pos;
1175 		__entry->value = value;
1176 	),
1177 	TP_printk("dev %d:%d rtdev %d:%d rtx 0x%llx rtxcount 0x%llx log %u rsumpos 0x%llx sumcount %u",
1178 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1179 		  MAJOR(__entry->rtdev), MINOR(__entry->rtdev),
1180 		  __entry->start,
1181 		  __entry->len,
1182 		  __entry->log,
1183 		  __entry->pos,
1184 		  __entry->value)
1185 );
1186 #endif /* CONFIG_XFS_RT */
1187 
1188 DECLARE_EVENT_CLASS(xchk_iscan_class,
1189 	TP_PROTO(struct xchk_iscan *iscan),
1190 	TP_ARGS(iscan),
1191 	TP_STRUCT__entry(
1192 		__field(dev_t, dev)
1193 		__field(xfs_ino_t, cursor)
1194 		__field(xfs_ino_t, visited)
1195 	),
1196 	TP_fast_assign(
1197 		__entry->dev = iscan->sc->mp->m_super->s_dev;
1198 		__entry->cursor = iscan->cursor_ino;
1199 		__entry->visited = iscan->__visited_ino;
1200 	),
1201 	TP_printk("dev %d:%d iscan cursor 0x%llx visited 0x%llx",
1202 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1203 		  __entry->cursor,
1204 		  __entry->visited)
1205 )
1206 #define DEFINE_ISCAN_EVENT(name) \
1207 DEFINE_EVENT(xchk_iscan_class, name, \
1208 	TP_PROTO(struct xchk_iscan *iscan), \
1209 	TP_ARGS(iscan))
1210 DEFINE_ISCAN_EVENT(xchk_iscan_move_cursor);
1211 DEFINE_ISCAN_EVENT(xchk_iscan_visit);
1212 DEFINE_ISCAN_EVENT(xchk_iscan_skip);
1213 DEFINE_ISCAN_EVENT(xchk_iscan_advance_ag);
1214 
1215 DECLARE_EVENT_CLASS(xchk_iscan_ino_class,
1216 	TP_PROTO(struct xchk_iscan *iscan, xfs_ino_t ino),
1217 	TP_ARGS(iscan, ino),
1218 	TP_STRUCT__entry(
1219 		__field(dev_t, dev)
1220 		__field(xfs_ino_t, startino)
1221 		__field(xfs_ino_t, cursor)
1222 		__field(xfs_ino_t, visited)
1223 		__field(xfs_ino_t, ino)
1224 	),
1225 	TP_fast_assign(
1226 		__entry->dev = iscan->sc->mp->m_super->s_dev;
1227 		__entry->startino = iscan->scan_start_ino;
1228 		__entry->cursor = iscan->cursor_ino;
1229 		__entry->visited = iscan->__visited_ino;
1230 		__entry->ino = ino;
1231 	),
1232 	TP_printk("dev %d:%d iscan start 0x%llx cursor 0x%llx visited 0x%llx ino 0x%llx",
1233 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1234 		  __entry->startino,
1235 		  __entry->cursor,
1236 		  __entry->visited,
1237 		  __entry->ino)
1238 )
1239 #define DEFINE_ISCAN_INO_EVENT(name) \
1240 DEFINE_EVENT(xchk_iscan_ino_class, name, \
1241 	TP_PROTO(struct xchk_iscan *iscan, xfs_ino_t ino), \
1242 	TP_ARGS(iscan, ino))
1243 DEFINE_ISCAN_INO_EVENT(xchk_iscan_want_live_update);
1244 DEFINE_ISCAN_INO_EVENT(xchk_iscan_start);
1245 
1246 TRACE_EVENT(xchk_iscan_iget,
1247 	TP_PROTO(struct xchk_iscan *iscan, int error),
1248 	TP_ARGS(iscan, error),
1249 	TP_STRUCT__entry(
1250 		__field(dev_t, dev)
1251 		__field(xfs_ino_t, cursor)
1252 		__field(xfs_ino_t, visited)
1253 		__field(int, error)
1254 	),
1255 	TP_fast_assign(
1256 		__entry->dev = iscan->sc->mp->m_super->s_dev;
1257 		__entry->cursor = iscan->cursor_ino;
1258 		__entry->visited = iscan->__visited_ino;
1259 		__entry->error = error;
1260 	),
1261 	TP_printk("dev %d:%d iscan cursor 0x%llx visited 0x%llx error %d",
1262 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1263 		  __entry->cursor,
1264 		  __entry->visited,
1265 		  __entry->error)
1266 );
1267 
1268 TRACE_EVENT(xchk_iscan_iget_batch,
1269 	TP_PROTO(struct xfs_mount *mp, struct xchk_iscan *iscan,
1270 		 unsigned int nr, unsigned int avail),
1271 	TP_ARGS(mp, iscan, nr, avail),
1272 	TP_STRUCT__entry(
1273 		__field(dev_t, dev)
1274 		__field(xfs_ino_t, cursor)
1275 		__field(xfs_ino_t, visited)
1276 		__field(unsigned int, nr)
1277 		__field(unsigned int, avail)
1278 		__field(unsigned int, unavail)
1279 		__field(xfs_ino_t, batch_ino)
1280 		__field(unsigned long long, skipmask)
1281 	),
1282 	TP_fast_assign(
1283 		__entry->dev = mp->m_super->s_dev;
1284 		__entry->cursor = iscan->cursor_ino;
1285 		__entry->visited = iscan->__visited_ino;
1286 		__entry->nr = nr;
1287 		__entry->avail = avail;
1288 		__entry->unavail = hweight64(iscan->__skipped_inomask);
1289 		__entry->batch_ino = iscan->__batch_ino;
1290 		__entry->skipmask = iscan->__skipped_inomask;
1291 	),
1292 	TP_printk("dev %d:%d iscan cursor 0x%llx visited 0x%llx batchino 0x%llx skipmask 0x%llx nr %u avail %u unavail %u",
1293 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1294 		  __entry->cursor,
1295 		  __entry->visited,
1296 		  __entry->batch_ino,
1297 		  __entry->skipmask,
1298 		  __entry->nr,
1299 		  __entry->avail,
1300 		  __entry->unavail)
1301 );
1302 
1303 TRACE_EVENT(xchk_iscan_iget_retry_wait,
1304 	TP_PROTO(struct xchk_iscan *iscan),
1305 	TP_ARGS(iscan),
1306 	TP_STRUCT__entry(
1307 		__field(dev_t, dev)
1308 		__field(xfs_ino_t, cursor)
1309 		__field(xfs_ino_t, visited)
1310 		__field(unsigned int, retry_delay)
1311 		__field(unsigned long, remaining)
1312 		__field(unsigned int, iget_timeout)
1313 	),
1314 	TP_fast_assign(
1315 		__entry->dev = iscan->sc->mp->m_super->s_dev;
1316 		__entry->cursor = iscan->cursor_ino;
1317 		__entry->visited = iscan->__visited_ino;
1318 		__entry->retry_delay = iscan->iget_retry_delay;
1319 		__entry->remaining = jiffies_to_msecs(iscan->__iget_deadline - jiffies);
1320 		__entry->iget_timeout = iscan->iget_timeout;
1321 	),
1322 	TP_printk("dev %d:%d iscan cursor 0x%llx visited 0x%llx remaining %lu timeout %u delay %u",
1323 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1324 		  __entry->cursor,
1325 		  __entry->visited,
1326 		  __entry->remaining,
1327 		  __entry->iget_timeout,
1328 		  __entry->retry_delay)
1329 );
1330 
1331 TRACE_EVENT(xchk_nlinks_collect_dirent,
1332 	TP_PROTO(struct xfs_mount *mp, struct xfs_inode *dp,
1333 		 xfs_ino_t ino, const struct xfs_name *name),
1334 	TP_ARGS(mp, dp, ino, name),
1335 	TP_STRUCT__entry(
1336 		__field(dev_t, dev)
1337 		__field(xfs_ino_t, dir)
1338 		__field(xfs_ino_t, ino)
1339 		__field(unsigned int, namelen)
1340 		__dynamic_array(char, name, name->len)
1341 	),
1342 	TP_fast_assign(
1343 		__entry->dev = mp->m_super->s_dev;
1344 		__entry->dir = dp->i_ino;
1345 		__entry->ino = ino;
1346 		__entry->namelen = name->len;
1347 		memcpy(__get_str(name), name->name, name->len);
1348 	),
1349 	TP_printk("dev %d:%d dir 0x%llx -> ino 0x%llx name '%.*s'",
1350 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1351 		  __entry->dir,
1352 		  __entry->ino,
1353 		  __entry->namelen,
1354 		  __get_str(name))
1355 );
1356 
1357 TRACE_EVENT(xchk_nlinks_collect_metafile,
1358 	TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino),
1359 	TP_ARGS(mp, ino),
1360 	TP_STRUCT__entry(
1361 		__field(dev_t, dev)
1362 		__field(xfs_ino_t, ino)
1363 	),
1364 	TP_fast_assign(
1365 		__entry->dev = mp->m_super->s_dev;
1366 		__entry->ino = ino;
1367 	),
1368 	TP_printk("dev %d:%d ino 0x%llx",
1369 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1370 		  __entry->ino)
1371 );
1372 
1373 TRACE_EVENT(xchk_nlinks_live_update,
1374 	TP_PROTO(struct xfs_mount *mp, const struct xfs_inode *dp,
1375 		 int action, xfs_ino_t ino, int delta,
1376 		 const char *name, unsigned int namelen),
1377 	TP_ARGS(mp, dp, action, ino, delta, name, namelen),
1378 	TP_STRUCT__entry(
1379 		__field(dev_t, dev)
1380 		__field(xfs_ino_t, dir)
1381 		__field(int, action)
1382 		__field(xfs_ino_t, ino)
1383 		__field(int, delta)
1384 		__field(unsigned int, namelen)
1385 		__dynamic_array(char, name, namelen)
1386 	),
1387 	TP_fast_assign(
1388 		__entry->dev = mp->m_super->s_dev;
1389 		__entry->dir = dp ? dp->i_ino : NULLFSINO;
1390 		__entry->action = action;
1391 		__entry->ino = ino;
1392 		__entry->delta = delta;
1393 		__entry->namelen = namelen;
1394 		memcpy(__get_str(name), name, namelen);
1395 	),
1396 	TP_printk("dev %d:%d dir 0x%llx ino 0x%llx nlink_delta %d name '%.*s'",
1397 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1398 		  __entry->dir,
1399 		  __entry->ino,
1400 		  __entry->delta,
1401 		  __entry->namelen,
1402 		  __get_str(name))
1403 );
1404 
1405 TRACE_EVENT(xchk_nlinks_check_zero,
1406 	TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino,
1407 		 const struct xchk_nlink *live),
1408 	TP_ARGS(mp, ino, live),
1409 	TP_STRUCT__entry(
1410 		__field(dev_t, dev)
1411 		__field(xfs_ino_t, ino)
1412 		__field(xfs_nlink_t, parents)
1413 		__field(xfs_nlink_t, backrefs)
1414 		__field(xfs_nlink_t, children)
1415 	),
1416 	TP_fast_assign(
1417 		__entry->dev = mp->m_super->s_dev;
1418 		__entry->ino = ino;
1419 		__entry->parents = live->parents;
1420 		__entry->backrefs = live->backrefs;
1421 		__entry->children = live->children;
1422 	),
1423 	TP_printk("dev %d:%d ino 0x%llx parents %u backrefs %u children %u",
1424 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1425 		  __entry->ino,
1426 		  __entry->parents,
1427 		  __entry->backrefs,
1428 		  __entry->children)
1429 );
1430 
1431 TRACE_EVENT(xchk_nlinks_update_incore,
1432 	TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino,
1433 		 const struct xchk_nlink *live, int parents_delta,
1434 		 int backrefs_delta, int children_delta),
1435 	TP_ARGS(mp, ino, live, parents_delta, backrefs_delta, children_delta),
1436 	TP_STRUCT__entry(
1437 		__field(dev_t, dev)
1438 		__field(xfs_ino_t, ino)
1439 		__field(xfs_nlink_t, parents)
1440 		__field(xfs_nlink_t, backrefs)
1441 		__field(xfs_nlink_t, children)
1442 		__field(int, parents_delta)
1443 		__field(int, backrefs_delta)
1444 		__field(int, children_delta)
1445 	),
1446 	TP_fast_assign(
1447 		__entry->dev = mp->m_super->s_dev;
1448 		__entry->ino = ino;
1449 		__entry->parents = live->parents;
1450 		__entry->backrefs = live->backrefs;
1451 		__entry->children = live->children;
1452 		__entry->parents_delta = parents_delta;
1453 		__entry->backrefs_delta = backrefs_delta;
1454 		__entry->children_delta = children_delta;
1455 	),
1456 	TP_printk("dev %d:%d ino 0x%llx parents %d:%u backrefs %d:%u children %d:%u",
1457 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1458 		  __entry->ino,
1459 		  __entry->parents_delta,
1460 		  __entry->parents,
1461 		  __entry->backrefs_delta,
1462 		  __entry->backrefs,
1463 		  __entry->children_delta,
1464 		  __entry->children)
1465 );
1466 
1467 DECLARE_EVENT_CLASS(xchk_nlinks_diff_class,
1468 	TP_PROTO(struct xfs_mount *mp, struct xfs_inode *ip,
1469 		 const struct xchk_nlink *live),
1470 	TP_ARGS(mp, ip, live),
1471 	TP_STRUCT__entry(
1472 		__field(dev_t, dev)
1473 		__field(xfs_ino_t, ino)
1474 		__field(uint8_t, ftype)
1475 		__field(xfs_nlink_t, nlink)
1476 		__field(xfs_nlink_t, parents)
1477 		__field(xfs_nlink_t, backrefs)
1478 		__field(xfs_nlink_t, children)
1479 	),
1480 	TP_fast_assign(
1481 		__entry->dev = mp->m_super->s_dev;
1482 		__entry->ino = ip->i_ino;
1483 		__entry->ftype = xfs_mode_to_ftype(VFS_I(ip)->i_mode);
1484 		__entry->nlink = VFS_I(ip)->i_nlink;
1485 		__entry->parents = live->parents;
1486 		__entry->backrefs = live->backrefs;
1487 		__entry->children = live->children;
1488 	),
1489 	TP_printk("dev %d:%d ino 0x%llx ftype %s nlink %u parents %u backrefs %u children %u",
1490 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1491 		  __entry->ino,
1492 		  __print_symbolic(__entry->ftype, XFS_DIR3_FTYPE_STR),
1493 		  __entry->nlink,
1494 		  __entry->parents,
1495 		  __entry->backrefs,
1496 		  __entry->children)
1497 );
1498 #define DEFINE_SCRUB_NLINKS_DIFF_EVENT(name) \
1499 DEFINE_EVENT(xchk_nlinks_diff_class, name, \
1500 	TP_PROTO(struct xfs_mount *mp, struct xfs_inode *ip, \
1501 		 const struct xchk_nlink *live), \
1502 	TP_ARGS(mp, ip, live))
1503 DEFINE_SCRUB_NLINKS_DIFF_EVENT(xchk_nlinks_compare_inode);
1504 
1505 /* repair tracepoints */
1506 #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
1507 
1508 DECLARE_EVENT_CLASS(xrep_extent_class,
1509 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len),
1510 	TP_ARGS(pag, agbno, len),
1511 	TP_STRUCT__entry(
1512 		__field(dev_t, dev)
1513 		__field(xfs_agnumber_t, agno)
1514 		__field(xfs_agblock_t, agbno)
1515 		__field(xfs_extlen_t, len)
1516 	),
1517 	TP_fast_assign(
1518 		__entry->dev = pag->pag_mount->m_super->s_dev;
1519 		__entry->agno = pag->pag_agno;
1520 		__entry->agbno = agbno;
1521 		__entry->len = len;
1522 	),
1523 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
1524 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1525 		  __entry->agno,
1526 		  __entry->agbno,
1527 		  __entry->len)
1528 );
1529 #define DEFINE_REPAIR_EXTENT_EVENT(name) \
1530 DEFINE_EVENT(xrep_extent_class, name, \
1531 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len), \
1532 	TP_ARGS(pag, agbno, len))
1533 DEFINE_REPAIR_EXTENT_EVENT(xreap_dispose_unmap_extent);
1534 DEFINE_REPAIR_EXTENT_EVENT(xreap_dispose_free_extent);
1535 DEFINE_REPAIR_EXTENT_EVENT(xreap_agextent_binval);
1536 DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
1537 
1538 DECLARE_EVENT_CLASS(xrep_reap_find_class,
1539 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len,
1540 		bool crosslinked),
1541 	TP_ARGS(pag, agbno, len, crosslinked),
1542 	TP_STRUCT__entry(
1543 		__field(dev_t, dev)
1544 		__field(xfs_agnumber_t, agno)
1545 		__field(xfs_agblock_t, agbno)
1546 		__field(xfs_extlen_t, len)
1547 		__field(bool, crosslinked)
1548 	),
1549 	TP_fast_assign(
1550 		__entry->dev = pag->pag_mount->m_super->s_dev;
1551 		__entry->agno = pag->pag_agno;
1552 		__entry->agbno = agbno;
1553 		__entry->len = len;
1554 		__entry->crosslinked = crosslinked;
1555 	),
1556 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x crosslinked %d",
1557 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1558 		  __entry->agno,
1559 		  __entry->agbno,
1560 		  __entry->len,
1561 		  __entry->crosslinked ? 1 : 0)
1562 );
1563 #define DEFINE_REPAIR_REAP_FIND_EVENT(name) \
1564 DEFINE_EVENT(xrep_reap_find_class, name, \
1565 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len, \
1566 		 bool crosslinked), \
1567 	TP_ARGS(pag, agbno, len, crosslinked))
1568 DEFINE_REPAIR_REAP_FIND_EVENT(xreap_agextent_select);
1569 
1570 DECLARE_EVENT_CLASS(xrep_rmap_class,
1571 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1572 		 xfs_agblock_t agbno, xfs_extlen_t len,
1573 		 uint64_t owner, uint64_t offset, unsigned int flags),
1574 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
1575 	TP_STRUCT__entry(
1576 		__field(dev_t, dev)
1577 		__field(xfs_agnumber_t, agno)
1578 		__field(xfs_agblock_t, agbno)
1579 		__field(xfs_extlen_t, len)
1580 		__field(uint64_t, owner)
1581 		__field(uint64_t, offset)
1582 		__field(unsigned int, flags)
1583 	),
1584 	TP_fast_assign(
1585 		__entry->dev = mp->m_super->s_dev;
1586 		__entry->agno = agno;
1587 		__entry->agbno = agbno;
1588 		__entry->len = len;
1589 		__entry->owner = owner;
1590 		__entry->offset = offset;
1591 		__entry->flags = flags;
1592 	),
1593 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%x",
1594 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1595 		  __entry->agno,
1596 		  __entry->agbno,
1597 		  __entry->len,
1598 		  __entry->owner,
1599 		  __entry->offset,
1600 		  __entry->flags)
1601 );
1602 #define DEFINE_REPAIR_RMAP_EVENT(name) \
1603 DEFINE_EVENT(xrep_rmap_class, name, \
1604 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1605 		 xfs_agblock_t agbno, xfs_extlen_t len, \
1606 		 uint64_t owner, uint64_t offset, unsigned int flags), \
1607 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
1608 DEFINE_REPAIR_RMAP_EVENT(xrep_ibt_walk_rmap);
1609 DEFINE_REPAIR_RMAP_EVENT(xrep_bmap_walk_rmap);
1610 
1611 TRACE_EVENT(xrep_abt_found,
1612 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1613 		 const struct xfs_alloc_rec_incore *rec),
1614 	TP_ARGS(mp, agno, rec),
1615 	TP_STRUCT__entry(
1616 		__field(dev_t, dev)
1617 		__field(xfs_agnumber_t, agno)
1618 		__field(xfs_agblock_t, startblock)
1619 		__field(xfs_extlen_t, blockcount)
1620 	),
1621 	TP_fast_assign(
1622 		__entry->dev = mp->m_super->s_dev;
1623 		__entry->agno = agno;
1624 		__entry->startblock = rec->ar_startblock;
1625 		__entry->blockcount = rec->ar_blockcount;
1626 	),
1627 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
1628 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1629 		  __entry->agno,
1630 		  __entry->startblock,
1631 		  __entry->blockcount)
1632 )
1633 
1634 TRACE_EVENT(xrep_ibt_found,
1635 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1636 		 const struct xfs_inobt_rec_incore *rec),
1637 	TP_ARGS(mp, agno, rec),
1638 	TP_STRUCT__entry(
1639 		__field(dev_t, dev)
1640 		__field(xfs_agnumber_t, agno)
1641 		__field(xfs_agino_t, startino)
1642 		__field(uint16_t, holemask)
1643 		__field(uint8_t, count)
1644 		__field(uint8_t, freecount)
1645 		__field(uint64_t, freemask)
1646 	),
1647 	TP_fast_assign(
1648 		__entry->dev = mp->m_super->s_dev;
1649 		__entry->agno = agno;
1650 		__entry->startino = rec->ir_startino;
1651 		__entry->holemask = rec->ir_holemask;
1652 		__entry->count = rec->ir_count;
1653 		__entry->freecount = rec->ir_freecount;
1654 		__entry->freemask = rec->ir_free;
1655 	),
1656 	TP_printk("dev %d:%d agno 0x%x agino 0x%x holemask 0x%x count 0x%x freecount 0x%x freemask 0x%llx",
1657 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1658 		  __entry->agno,
1659 		  __entry->startino,
1660 		  __entry->holemask,
1661 		  __entry->count,
1662 		  __entry->freecount,
1663 		  __entry->freemask)
1664 )
1665 
1666 TRACE_EVENT(xrep_refc_found,
1667 	TP_PROTO(struct xfs_perag *pag, const struct xfs_refcount_irec *rec),
1668 	TP_ARGS(pag, rec),
1669 	TP_STRUCT__entry(
1670 		__field(dev_t, dev)
1671 		__field(xfs_agnumber_t, agno)
1672 		__field(enum xfs_refc_domain, domain)
1673 		__field(xfs_agblock_t, startblock)
1674 		__field(xfs_extlen_t, blockcount)
1675 		__field(xfs_nlink_t, refcount)
1676 	),
1677 	TP_fast_assign(
1678 		__entry->dev = pag->pag_mount->m_super->s_dev;
1679 		__entry->agno = pag->pag_agno;
1680 		__entry->domain = rec->rc_domain;
1681 		__entry->startblock = rec->rc_startblock;
1682 		__entry->blockcount = rec->rc_blockcount;
1683 		__entry->refcount = rec->rc_refcount;
1684 	),
1685 	TP_printk("dev %d:%d agno 0x%x dom %s agbno 0x%x fsbcount 0x%x refcount %u",
1686 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1687 		  __entry->agno,
1688 		  __print_symbolic(__entry->domain, XFS_REFC_DOMAIN_STRINGS),
1689 		  __entry->startblock,
1690 		  __entry->blockcount,
1691 		  __entry->refcount)
1692 )
1693 
1694 TRACE_EVENT(xrep_bmap_found,
1695 	TP_PROTO(struct xfs_inode *ip, int whichfork,
1696 		 struct xfs_bmbt_irec *irec),
1697 	TP_ARGS(ip, whichfork, irec),
1698 	TP_STRUCT__entry(
1699 		__field(dev_t, dev)
1700 		__field(xfs_ino_t, ino)
1701 		__field(int, whichfork)
1702 		__field(xfs_fileoff_t, lblk)
1703 		__field(xfs_filblks_t, len)
1704 		__field(xfs_fsblock_t, pblk)
1705 		__field(int, state)
1706 	),
1707 	TP_fast_assign(
1708 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1709 		__entry->ino = ip->i_ino;
1710 		__entry->whichfork = whichfork;
1711 		__entry->lblk = irec->br_startoff;
1712 		__entry->len = irec->br_blockcount;
1713 		__entry->pblk = irec->br_startblock;
1714 		__entry->state = irec->br_state;
1715 	),
1716 	TP_printk("dev %d:%d ino 0x%llx whichfork %s fileoff 0x%llx fsbcount 0x%llx startblock 0x%llx state %d",
1717 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1718 		  __entry->ino,
1719 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
1720 		  __entry->lblk,
1721 		  __entry->len,
1722 		  __entry->pblk,
1723 		  __entry->state)
1724 );
1725 
1726 TRACE_EVENT(xrep_rmap_found,
1727 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1728 		 const struct xfs_rmap_irec *rec),
1729 	TP_ARGS(mp, agno, rec),
1730 	TP_STRUCT__entry(
1731 		__field(dev_t, dev)
1732 		__field(xfs_agnumber_t, agno)
1733 		__field(xfs_agblock_t, agbno)
1734 		__field(xfs_extlen_t, len)
1735 		__field(uint64_t, owner)
1736 		__field(uint64_t, offset)
1737 		__field(unsigned int, flags)
1738 	),
1739 	TP_fast_assign(
1740 		__entry->dev = mp->m_super->s_dev;
1741 		__entry->agno = agno;
1742 		__entry->agbno = rec->rm_startblock;
1743 		__entry->len = rec->rm_blockcount;
1744 		__entry->owner = rec->rm_owner;
1745 		__entry->offset = rec->rm_offset;
1746 		__entry->flags = rec->rm_flags;
1747 	),
1748 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%x",
1749 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1750 		  __entry->agno,
1751 		  __entry->agbno,
1752 		  __entry->len,
1753 		  __entry->owner,
1754 		  __entry->offset,
1755 		  __entry->flags)
1756 );
1757 
1758 TRACE_EVENT(xrep_findroot_block,
1759 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
1760 		 uint32_t magic, uint16_t level),
1761 	TP_ARGS(mp, agno, agbno, magic, level),
1762 	TP_STRUCT__entry(
1763 		__field(dev_t, dev)
1764 		__field(xfs_agnumber_t, agno)
1765 		__field(xfs_agblock_t, agbno)
1766 		__field(uint32_t, magic)
1767 		__field(uint16_t, level)
1768 	),
1769 	TP_fast_assign(
1770 		__entry->dev = mp->m_super->s_dev;
1771 		__entry->agno = agno;
1772 		__entry->agbno = agbno;
1773 		__entry->magic = magic;
1774 		__entry->level = level;
1775 	),
1776 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x magic 0x%x level %u",
1777 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1778 		  __entry->agno,
1779 		  __entry->agbno,
1780 		  __entry->magic,
1781 		  __entry->level)
1782 )
1783 TRACE_EVENT(xrep_calc_ag_resblks,
1784 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1785 		 xfs_agino_t icount, xfs_agblock_t aglen, xfs_agblock_t freelen,
1786 		 xfs_agblock_t usedlen),
1787 	TP_ARGS(mp, agno, icount, aglen, freelen, usedlen),
1788 	TP_STRUCT__entry(
1789 		__field(dev_t, dev)
1790 		__field(xfs_agnumber_t, agno)
1791 		__field(xfs_agino_t, icount)
1792 		__field(xfs_agblock_t, aglen)
1793 		__field(xfs_agblock_t, freelen)
1794 		__field(xfs_agblock_t, usedlen)
1795 	),
1796 	TP_fast_assign(
1797 		__entry->dev = mp->m_super->s_dev;
1798 		__entry->agno = agno;
1799 		__entry->icount = icount;
1800 		__entry->aglen = aglen;
1801 		__entry->freelen = freelen;
1802 		__entry->usedlen = usedlen;
1803 	),
1804 	TP_printk("dev %d:%d agno 0x%x icount %u aglen %u freelen %u usedlen %u",
1805 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1806 		  __entry->agno,
1807 		  __entry->icount,
1808 		  __entry->aglen,
1809 		  __entry->freelen,
1810 		  __entry->usedlen)
1811 )
1812 TRACE_EVENT(xrep_calc_ag_resblks_btsize,
1813 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1814 		 xfs_agblock_t bnobt_sz, xfs_agblock_t inobt_sz,
1815 		 xfs_agblock_t rmapbt_sz, xfs_agblock_t refcbt_sz),
1816 	TP_ARGS(mp, agno, bnobt_sz, inobt_sz, rmapbt_sz, refcbt_sz),
1817 	TP_STRUCT__entry(
1818 		__field(dev_t, dev)
1819 		__field(xfs_agnumber_t, agno)
1820 		__field(xfs_agblock_t, bnobt_sz)
1821 		__field(xfs_agblock_t, inobt_sz)
1822 		__field(xfs_agblock_t, rmapbt_sz)
1823 		__field(xfs_agblock_t, refcbt_sz)
1824 	),
1825 	TP_fast_assign(
1826 		__entry->dev = mp->m_super->s_dev;
1827 		__entry->agno = agno;
1828 		__entry->bnobt_sz = bnobt_sz;
1829 		__entry->inobt_sz = inobt_sz;
1830 		__entry->rmapbt_sz = rmapbt_sz;
1831 		__entry->refcbt_sz = refcbt_sz;
1832 	),
1833 	TP_printk("dev %d:%d agno 0x%x bnobt %u inobt %u rmapbt %u refcountbt %u",
1834 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1835 		  __entry->agno,
1836 		  __entry->bnobt_sz,
1837 		  __entry->inobt_sz,
1838 		  __entry->rmapbt_sz,
1839 		  __entry->refcbt_sz)
1840 )
1841 TRACE_EVENT(xrep_reset_counters,
1842 	TP_PROTO(struct xfs_mount *mp, struct xchk_fscounters *fsc),
1843 	TP_ARGS(mp, fsc),
1844 	TP_STRUCT__entry(
1845 		__field(dev_t, dev)
1846 		__field(uint64_t, icount)
1847 		__field(uint64_t, ifree)
1848 		__field(uint64_t, fdblocks)
1849 		__field(uint64_t, frextents)
1850 	),
1851 	TP_fast_assign(
1852 		__entry->dev = mp->m_super->s_dev;
1853 		__entry->icount = fsc->icount;
1854 		__entry->ifree = fsc->ifree;
1855 		__entry->fdblocks = fsc->fdblocks;
1856 		__entry->frextents = fsc->frextents;
1857 	),
1858 	TP_printk("dev %d:%d icount %llu ifree %llu fdblocks %llu frextents %llu",
1859 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1860 		  __entry->icount,
1861 		  __entry->ifree,
1862 		  __entry->fdblocks,
1863 		  __entry->frextents)
1864 )
1865 
1866 DECLARE_EVENT_CLASS(xrep_newbt_extent_class,
1867 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1868 		 xfs_agblock_t agbno, xfs_extlen_t len,
1869 		 int64_t owner),
1870 	TP_ARGS(mp, agno, agbno, len, owner),
1871 	TP_STRUCT__entry(
1872 		__field(dev_t, dev)
1873 		__field(xfs_agnumber_t, agno)
1874 		__field(xfs_agblock_t, agbno)
1875 		__field(xfs_extlen_t, len)
1876 		__field(int64_t, owner)
1877 	),
1878 	TP_fast_assign(
1879 		__entry->dev = mp->m_super->s_dev;
1880 		__entry->agno = agno;
1881 		__entry->agbno = agbno;
1882 		__entry->len = len;
1883 		__entry->owner = owner;
1884 	),
1885 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx",
1886 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1887 		  __entry->agno,
1888 		  __entry->agbno,
1889 		  __entry->len,
1890 		  __entry->owner)
1891 );
1892 #define DEFINE_NEWBT_EXTENT_EVENT(name) \
1893 DEFINE_EVENT(xrep_newbt_extent_class, name, \
1894 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1895 		 xfs_agblock_t agbno, xfs_extlen_t len, \
1896 		 int64_t owner), \
1897 	TP_ARGS(mp, agno, agbno, len, owner))
1898 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_alloc_ag_blocks);
1899 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_alloc_file_blocks);
1900 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_free_blocks);
1901 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_claim_block);
1902 
1903 DECLARE_EVENT_CLASS(xrep_dinode_class,
1904 	TP_PROTO(struct xfs_scrub *sc, struct xfs_dinode *dip),
1905 	TP_ARGS(sc, dip),
1906 	TP_STRUCT__entry(
1907 		__field(dev_t, dev)
1908 		__field(xfs_ino_t, ino)
1909 		__field(uint16_t, mode)
1910 		__field(uint8_t, version)
1911 		__field(uint8_t, format)
1912 		__field(uint32_t, uid)
1913 		__field(uint32_t, gid)
1914 		__field(uint64_t, size)
1915 		__field(uint64_t, nblocks)
1916 		__field(uint32_t, extsize)
1917 		__field(uint32_t, nextents)
1918 		__field(uint16_t, anextents)
1919 		__field(uint8_t, forkoff)
1920 		__field(uint8_t, aformat)
1921 		__field(uint16_t, flags)
1922 		__field(uint32_t, gen)
1923 		__field(uint64_t, flags2)
1924 		__field(uint32_t, cowextsize)
1925 	),
1926 	TP_fast_assign(
1927 		__entry->dev = sc->mp->m_super->s_dev;
1928 		__entry->ino = sc->sm->sm_ino;
1929 		__entry->mode = be16_to_cpu(dip->di_mode);
1930 		__entry->version = dip->di_version;
1931 		__entry->format = dip->di_format;
1932 		__entry->uid = be32_to_cpu(dip->di_uid);
1933 		__entry->gid = be32_to_cpu(dip->di_gid);
1934 		__entry->size = be64_to_cpu(dip->di_size);
1935 		__entry->nblocks = be64_to_cpu(dip->di_nblocks);
1936 		__entry->extsize = be32_to_cpu(dip->di_extsize);
1937 		__entry->nextents = be32_to_cpu(dip->di_nextents);
1938 		__entry->anextents = be16_to_cpu(dip->di_anextents);
1939 		__entry->forkoff = dip->di_forkoff;
1940 		__entry->aformat = dip->di_aformat;
1941 		__entry->flags = be16_to_cpu(dip->di_flags);
1942 		__entry->gen = be32_to_cpu(dip->di_gen);
1943 		__entry->flags2 = be64_to_cpu(dip->di_flags2);
1944 		__entry->cowextsize = be32_to_cpu(dip->di_cowextsize);
1945 	),
1946 	TP_printk("dev %d:%d ino 0x%llx mode 0x%x version %u format %u uid %u gid %u disize 0x%llx nblocks 0x%llx extsize %u nextents %u anextents %u forkoff 0x%x aformat %u flags 0x%x gen 0x%x flags2 0x%llx cowextsize %u",
1947 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1948 		  __entry->ino,
1949 		  __entry->mode,
1950 		  __entry->version,
1951 		  __entry->format,
1952 		  __entry->uid,
1953 		  __entry->gid,
1954 		  __entry->size,
1955 		  __entry->nblocks,
1956 		  __entry->extsize,
1957 		  __entry->nextents,
1958 		  __entry->anextents,
1959 		  __entry->forkoff,
1960 		  __entry->aformat,
1961 		  __entry->flags,
1962 		  __entry->gen,
1963 		  __entry->flags2,
1964 		  __entry->cowextsize)
1965 )
1966 
1967 #define DEFINE_REPAIR_DINODE_EVENT(name) \
1968 DEFINE_EVENT(xrep_dinode_class, name, \
1969 	TP_PROTO(struct xfs_scrub *sc, struct xfs_dinode *dip), \
1970 	TP_ARGS(sc, dip))
1971 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_header);
1972 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_mode);
1973 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_flags);
1974 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_size);
1975 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_extsize_hints);
1976 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_symlink);
1977 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_dir);
1978 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_fixed);
1979 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_forks);
1980 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_dfork);
1981 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_afork);
1982 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_ensure_forkoff);
1983 
1984 DECLARE_EVENT_CLASS(xrep_inode_class,
1985 	TP_PROTO(struct xfs_scrub *sc),
1986 	TP_ARGS(sc),
1987 	TP_STRUCT__entry(
1988 		__field(dev_t, dev)
1989 		__field(xfs_ino_t, ino)
1990 		__field(xfs_fsize_t, size)
1991 		__field(xfs_rfsblock_t, nblocks)
1992 		__field(uint16_t, flags)
1993 		__field(uint64_t, flags2)
1994 		__field(uint32_t, nextents)
1995 		__field(uint8_t, format)
1996 		__field(uint32_t, anextents)
1997 		__field(uint8_t, aformat)
1998 	),
1999 	TP_fast_assign(
2000 		__entry->dev = sc->mp->m_super->s_dev;
2001 		__entry->ino = sc->sm->sm_ino;
2002 		__entry->size = sc->ip->i_disk_size;
2003 		__entry->nblocks = sc->ip->i_nblocks;
2004 		__entry->flags = sc->ip->i_diflags;
2005 		__entry->flags2 = sc->ip->i_diflags2;
2006 		__entry->nextents = sc->ip->i_df.if_nextents;
2007 		__entry->format = sc->ip->i_df.if_format;
2008 		__entry->anextents = sc->ip->i_af.if_nextents;
2009 		__entry->aformat = sc->ip->i_af.if_format;
2010 	),
2011 	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx nblocks 0x%llx flags 0x%x flags2 0x%llx nextents %u format %u anextents %u aformat %u",
2012 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2013 		  __entry->ino,
2014 		  __entry->size,
2015 		  __entry->nblocks,
2016 		  __entry->flags,
2017 		  __entry->flags2,
2018 		  __entry->nextents,
2019 		  __entry->format,
2020 		  __entry->anextents,
2021 		  __entry->aformat)
2022 )
2023 
2024 #define DEFINE_REPAIR_INODE_EVENT(name) \
2025 DEFINE_EVENT(xrep_inode_class, name, \
2026 	TP_PROTO(struct xfs_scrub *sc), \
2027 	TP_ARGS(sc))
2028 DEFINE_REPAIR_INODE_EVENT(xrep_inode_blockcounts);
2029 DEFINE_REPAIR_INODE_EVENT(xrep_inode_ids);
2030 DEFINE_REPAIR_INODE_EVENT(xrep_inode_flags);
2031 DEFINE_REPAIR_INODE_EVENT(xrep_inode_blockdir_size);
2032 DEFINE_REPAIR_INODE_EVENT(xrep_inode_sfdir_size);
2033 DEFINE_REPAIR_INODE_EVENT(xrep_inode_dir_size);
2034 DEFINE_REPAIR_INODE_EVENT(xrep_inode_fixed);
2035 
2036 TRACE_EVENT(xrep_dinode_count_rmaps,
2037 	TP_PROTO(struct xfs_scrub *sc, xfs_rfsblock_t data_blocks,
2038 		xfs_rfsblock_t rt_blocks, xfs_rfsblock_t attr_blocks,
2039 		xfs_extnum_t data_extents, xfs_extnum_t rt_extents,
2040 		xfs_aextnum_t attr_extents),
2041 	TP_ARGS(sc, data_blocks, rt_blocks, attr_blocks, data_extents,
2042 		rt_extents, attr_extents),
2043 	TP_STRUCT__entry(
2044 		__field(dev_t, dev)
2045 		__field(xfs_ino_t, ino)
2046 		__field(xfs_rfsblock_t, data_blocks)
2047 		__field(xfs_rfsblock_t, rt_blocks)
2048 		__field(xfs_rfsblock_t, attr_blocks)
2049 		__field(xfs_extnum_t, data_extents)
2050 		__field(xfs_extnum_t, rt_extents)
2051 		__field(xfs_aextnum_t, attr_extents)
2052 	),
2053 	TP_fast_assign(
2054 		__entry->dev = sc->mp->m_super->s_dev;
2055 		__entry->ino = sc->sm->sm_ino;
2056 		__entry->data_blocks = data_blocks;
2057 		__entry->rt_blocks = rt_blocks;
2058 		__entry->attr_blocks = attr_blocks;
2059 		__entry->data_extents = data_extents;
2060 		__entry->rt_extents = rt_extents;
2061 		__entry->attr_extents = attr_extents;
2062 	),
2063 	TP_printk("dev %d:%d ino 0x%llx dblocks 0x%llx rtblocks 0x%llx ablocks 0x%llx dextents %llu rtextents %llu aextents %u",
2064 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2065 		  __entry->ino,
2066 		  __entry->data_blocks,
2067 		  __entry->rt_blocks,
2068 		  __entry->attr_blocks,
2069 		  __entry->data_extents,
2070 		  __entry->rt_extents,
2071 		  __entry->attr_extents)
2072 );
2073 
2074 TRACE_EVENT(xrep_dinode_findmode_dirent,
2075 	TP_PROTO(struct xfs_scrub *sc, struct xfs_inode *dp,
2076 		 unsigned int ftype),
2077 	TP_ARGS(sc, dp, ftype),
2078 	TP_STRUCT__entry(
2079 		__field(dev_t, dev)
2080 		__field(xfs_ino_t, ino)
2081 		__field(xfs_ino_t, parent_ino)
2082 		__field(unsigned int, ftype)
2083 	),
2084 	TP_fast_assign(
2085 		__entry->dev = sc->mp->m_super->s_dev;
2086 		__entry->ino = sc->sm->sm_ino;
2087 		__entry->parent_ino = dp->i_ino;
2088 		__entry->ftype = ftype;
2089 	),
2090 	TP_printk("dev %d:%d ino 0x%llx parent_ino 0x%llx ftype '%s'",
2091 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2092 		  __entry->ino,
2093 		  __entry->parent_ino,
2094 		  __print_symbolic(__entry->ftype, XFS_DIR3_FTYPE_STR))
2095 );
2096 
2097 TRACE_EVENT(xrep_dinode_findmode_dirent_inval,
2098 	TP_PROTO(struct xfs_scrub *sc, struct xfs_inode *dp,
2099 		 unsigned int ftype, unsigned int found_ftype),
2100 	TP_ARGS(sc, dp, ftype, found_ftype),
2101 	TP_STRUCT__entry(
2102 		__field(dev_t, dev)
2103 		__field(xfs_ino_t, ino)
2104 		__field(xfs_ino_t, parent_ino)
2105 		__field(unsigned int, ftype)
2106 		__field(unsigned int, found_ftype)
2107 	),
2108 	TP_fast_assign(
2109 		__entry->dev = sc->mp->m_super->s_dev;
2110 		__entry->ino = sc->sm->sm_ino;
2111 		__entry->parent_ino = dp->i_ino;
2112 		__entry->ftype = ftype;
2113 		__entry->found_ftype = found_ftype;
2114 	),
2115 	TP_printk("dev %d:%d ino 0x%llx parent_ino 0x%llx ftype '%s' found_ftype '%s'",
2116 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2117 		  __entry->ino,
2118 		  __entry->parent_ino,
2119 		  __print_symbolic(__entry->ftype, XFS_DIR3_FTYPE_STR),
2120 		  __print_symbolic(__entry->found_ftype, XFS_DIR3_FTYPE_STR))
2121 );
2122 
2123 TRACE_EVENT(xrep_cow_mark_file_range,
2124 	TP_PROTO(struct xfs_inode *ip, xfs_fsblock_t startblock,
2125 		 xfs_fileoff_t startoff, xfs_filblks_t blockcount),
2126 	TP_ARGS(ip, startblock, startoff, blockcount),
2127 	TP_STRUCT__entry(
2128 		__field(dev_t, dev)
2129 		__field(xfs_ino_t, ino)
2130 		__field(xfs_fsblock_t, startblock)
2131 		__field(xfs_fileoff_t, startoff)
2132 		__field(xfs_filblks_t, blockcount)
2133 	),
2134 	TP_fast_assign(
2135 		__entry->dev = ip->i_mount->m_super->s_dev;
2136 		__entry->ino = ip->i_ino;
2137 		__entry->startoff = startoff;
2138 		__entry->startblock = startblock;
2139 		__entry->blockcount = blockcount;
2140 	),
2141 	TP_printk("dev %d:%d ino 0x%llx fileoff 0x%llx startblock 0x%llx fsbcount 0x%llx",
2142 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2143 		  __entry->ino,
2144 		  __entry->startoff,
2145 		  __entry->startblock,
2146 		  __entry->blockcount)
2147 );
2148 
2149 TRACE_EVENT(xrep_cow_replace_mapping,
2150 	TP_PROTO(struct xfs_inode *ip, const struct xfs_bmbt_irec *irec,
2151 		 xfs_fsblock_t new_startblock, xfs_extlen_t new_blockcount),
2152 	TP_ARGS(ip, irec, new_startblock, new_blockcount),
2153 	TP_STRUCT__entry(
2154 		__field(dev_t, dev)
2155 		__field(xfs_ino_t, ino)
2156 		__field(xfs_fsblock_t, startblock)
2157 		__field(xfs_fileoff_t, startoff)
2158 		__field(xfs_filblks_t, blockcount)
2159 		__field(xfs_exntst_t, state)
2160 		__field(xfs_fsblock_t, new_startblock)
2161 		__field(xfs_extlen_t, new_blockcount)
2162 	),
2163 	TP_fast_assign(
2164 		__entry->dev = ip->i_mount->m_super->s_dev;
2165 		__entry->ino = ip->i_ino;
2166 		__entry->startoff = irec->br_startoff;
2167 		__entry->startblock = irec->br_startblock;
2168 		__entry->blockcount = irec->br_blockcount;
2169 		__entry->state = irec->br_state;
2170 		__entry->new_startblock = new_startblock;
2171 		__entry->new_blockcount = new_blockcount;
2172 	),
2173 	TP_printk("dev %d:%d ino 0x%llx startoff 0x%llx startblock 0x%llx fsbcount 0x%llx state 0x%x new_startblock 0x%llx new_fsbcount 0x%x",
2174 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2175 		  __entry->ino,
2176 		  __entry->startoff,
2177 		  __entry->startblock,
2178 		  __entry->blockcount,
2179 		  __entry->state,
2180 		  __entry->new_startblock,
2181 		  __entry->new_blockcount)
2182 );
2183 
2184 TRACE_EVENT(xrep_cow_free_staging,
2185 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno,
2186 		 xfs_extlen_t blockcount),
2187 	TP_ARGS(pag, agbno, blockcount),
2188 	TP_STRUCT__entry(
2189 		__field(dev_t, dev)
2190 		__field(xfs_agnumber_t, agno)
2191 		__field(xfs_agblock_t, agbno)
2192 		__field(xfs_extlen_t, blockcount)
2193 	),
2194 	TP_fast_assign(
2195 		__entry->dev = pag->pag_mount->m_super->s_dev;
2196 		__entry->agno = pag->pag_agno;
2197 		__entry->agbno = agbno;
2198 		__entry->blockcount = blockcount;
2199 	),
2200 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
2201 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2202 		  __entry->agno,
2203 		  __entry->agbno,
2204 		  __entry->blockcount)
2205 );
2206 
2207 #ifdef CONFIG_XFS_QUOTA
2208 DECLARE_EVENT_CLASS(xrep_dquot_class,
2209 	TP_PROTO(struct xfs_mount *mp, uint8_t type, uint32_t id),
2210 	TP_ARGS(mp, type, id),
2211 	TP_STRUCT__entry(
2212 		__field(dev_t, dev)
2213 		__field(uint8_t, type)
2214 		__field(uint32_t, id)
2215 	),
2216 	TP_fast_assign(
2217 		__entry->dev = mp->m_super->s_dev;
2218 		__entry->id = id;
2219 		__entry->type = type;
2220 	),
2221 	TP_printk("dev %d:%d type %s id 0x%x",
2222 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2223 		  __print_flags(__entry->type, "|", XFS_DQTYPE_STRINGS),
2224 		  __entry->id)
2225 );
2226 
2227 #define DEFINE_XREP_DQUOT_EVENT(name) \
2228 DEFINE_EVENT(xrep_dquot_class, name, \
2229 	TP_PROTO(struct xfs_mount *mp, uint8_t type, uint32_t id), \
2230 	TP_ARGS(mp, type, id))
2231 DEFINE_XREP_DQUOT_EVENT(xrep_dquot_item);
2232 DEFINE_XREP_DQUOT_EVENT(xrep_disk_dquot);
2233 DEFINE_XREP_DQUOT_EVENT(xrep_dquot_item_fill_bmap_hole);
2234 DEFINE_XREP_DQUOT_EVENT(xrep_quotacheck_dquot);
2235 #endif /* CONFIG_XFS_QUOTA */
2236 
2237 DEFINE_SCRUB_NLINKS_DIFF_EVENT(xrep_nlinks_update_inode);
2238 DEFINE_SCRUB_NLINKS_DIFF_EVENT(xrep_nlinks_unfixable_inode);
2239 
2240 TRACE_EVENT(xrep_rmap_live_update,
2241 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int op,
2242 		 const struct xfs_rmap_update_params *p),
2243 	TP_ARGS(mp, agno, op, p),
2244 	TP_STRUCT__entry(
2245 		__field(dev_t, dev)
2246 		__field(xfs_agnumber_t, agno)
2247 		__field(unsigned int, op)
2248 		__field(xfs_agblock_t, agbno)
2249 		__field(xfs_extlen_t, len)
2250 		__field(uint64_t, owner)
2251 		__field(uint64_t, offset)
2252 		__field(unsigned int, flags)
2253 	),
2254 	TP_fast_assign(
2255 		__entry->dev = mp->m_super->s_dev;
2256 		__entry->agno = agno;
2257 		__entry->op = op;
2258 		__entry->agbno = p->startblock;
2259 		__entry->len = p->blockcount;
2260 		xfs_owner_info_unpack(&p->oinfo, &__entry->owner,
2261 				&__entry->offset, &__entry->flags);
2262 		if (p->unwritten)
2263 			__entry->flags |= XFS_RMAP_UNWRITTEN;
2264 	),
2265 	TP_printk("dev %d:%d agno 0x%x op %d agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%x",
2266 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2267 		  __entry->agno,
2268 		  __entry->op,
2269 		  __entry->agbno,
2270 		  __entry->len,
2271 		  __entry->owner,
2272 		  __entry->offset,
2273 		  __entry->flags)
2274 );
2275 
2276 #endif /* IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) */
2277 
2278 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
2279 
2280 #undef TRACE_INCLUDE_PATH
2281 #define TRACE_INCLUDE_PATH .
2282 #define TRACE_INCLUDE_FILE scrub/trace
2283 #include <trace/define_trace.h>
2284