xref: /linux/fs/xfs/scrub/trace.h (revision 8e3ed5440b0c305dcd1d5fa7419bd8066d22ef42)
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 struct xchk_dqiter;
23 
24 /*
25  * ftrace's __print_symbolic requires that all enum values be wrapped in the
26  * TRACE_DEFINE_ENUM macro so that the enum value can be encoded in the ftrace
27  * ring buffer.  Somehow this was only worth mentioning in the ftrace sample
28  * code.
29  */
30 TRACE_DEFINE_ENUM(XFS_BTNUM_BNOi);
31 TRACE_DEFINE_ENUM(XFS_BTNUM_CNTi);
32 TRACE_DEFINE_ENUM(XFS_BTNUM_BMAPi);
33 TRACE_DEFINE_ENUM(XFS_BTNUM_INOi);
34 TRACE_DEFINE_ENUM(XFS_BTNUM_FINOi);
35 TRACE_DEFINE_ENUM(XFS_BTNUM_RMAPi);
36 TRACE_DEFINE_ENUM(XFS_BTNUM_REFCi);
37 
38 TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_SHARED);
39 TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_COW);
40 
41 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PROBE);
42 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SB);
43 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGF);
44 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGFL);
45 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGI);
46 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BNOBT);
47 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_CNTBT);
48 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INOBT);
49 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FINOBT);
50 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RMAPBT);
51 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_REFCNTBT);
52 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INODE);
53 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTD);
54 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTA);
55 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTC);
56 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_DIR);
57 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_XATTR);
58 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SYMLINK);
59 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PARENT);
60 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTBITMAP);
61 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTSUM);
62 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_UQUOTA);
63 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_GQUOTA);
64 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PQUOTA);
65 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FSCOUNTERS);
66 
67 #define XFS_SCRUB_TYPE_STRINGS \
68 	{ XFS_SCRUB_TYPE_PROBE,		"probe" }, \
69 	{ XFS_SCRUB_TYPE_SB,		"sb" }, \
70 	{ XFS_SCRUB_TYPE_AGF,		"agf" }, \
71 	{ XFS_SCRUB_TYPE_AGFL,		"agfl" }, \
72 	{ XFS_SCRUB_TYPE_AGI,		"agi" }, \
73 	{ XFS_SCRUB_TYPE_BNOBT,		"bnobt" }, \
74 	{ XFS_SCRUB_TYPE_CNTBT,		"cntbt" }, \
75 	{ XFS_SCRUB_TYPE_INOBT,		"inobt" }, \
76 	{ XFS_SCRUB_TYPE_FINOBT,	"finobt" }, \
77 	{ XFS_SCRUB_TYPE_RMAPBT,	"rmapbt" }, \
78 	{ XFS_SCRUB_TYPE_REFCNTBT,	"refcountbt" }, \
79 	{ XFS_SCRUB_TYPE_INODE,		"inode" }, \
80 	{ XFS_SCRUB_TYPE_BMBTD,		"bmapbtd" }, \
81 	{ XFS_SCRUB_TYPE_BMBTA,		"bmapbta" }, \
82 	{ XFS_SCRUB_TYPE_BMBTC,		"bmapbtc" }, \
83 	{ XFS_SCRUB_TYPE_DIR,		"directory" }, \
84 	{ XFS_SCRUB_TYPE_XATTR,		"xattr" }, \
85 	{ XFS_SCRUB_TYPE_SYMLINK,	"symlink" }, \
86 	{ XFS_SCRUB_TYPE_PARENT,	"parent" }, \
87 	{ XFS_SCRUB_TYPE_RTBITMAP,	"rtbitmap" }, \
88 	{ XFS_SCRUB_TYPE_RTSUM,		"rtsummary" }, \
89 	{ XFS_SCRUB_TYPE_UQUOTA,	"usrquota" }, \
90 	{ XFS_SCRUB_TYPE_GQUOTA,	"grpquota" }, \
91 	{ XFS_SCRUB_TYPE_PQUOTA,	"prjquota" }, \
92 	{ XFS_SCRUB_TYPE_FSCOUNTERS,	"fscounters" }
93 
94 #define XFS_SCRUB_FLAG_STRINGS \
95 	{ XFS_SCRUB_IFLAG_REPAIR,		"repair" }, \
96 	{ XFS_SCRUB_OFLAG_CORRUPT,		"corrupt" }, \
97 	{ XFS_SCRUB_OFLAG_PREEN,		"preen" }, \
98 	{ XFS_SCRUB_OFLAG_XFAIL,		"xfail" }, \
99 	{ XFS_SCRUB_OFLAG_XCORRUPT,		"xcorrupt" }, \
100 	{ XFS_SCRUB_OFLAG_INCOMPLETE,		"incomplete" }, \
101 	{ XFS_SCRUB_OFLAG_WARNING,		"warning" }, \
102 	{ XFS_SCRUB_OFLAG_NO_REPAIR_NEEDED,	"norepair" }, \
103 	{ XFS_SCRUB_IFLAG_FORCE_REBUILD,	"rebuild" }
104 
105 #define XFS_SCRUB_STATE_STRINGS \
106 	{ XCHK_TRY_HARDER,			"try_harder" }, \
107 	{ XCHK_HAVE_FREEZE_PROT,		"nofreeze" }, \
108 	{ XCHK_FSGATES_DRAIN,			"fsgates_drain" }, \
109 	{ XCHK_NEED_DRAIN,			"need_drain" }, \
110 	{ XREP_RESET_PERAG_RESV,		"reset_perag_resv" }, \
111 	{ XREP_ALREADY_FIXED,			"already_fixed" }
112 
113 DECLARE_EVENT_CLASS(xchk_class,
114 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm,
115 		 int error),
116 	TP_ARGS(ip, sm, error),
117 	TP_STRUCT__entry(
118 		__field(dev_t, dev)
119 		__field(xfs_ino_t, ino)
120 		__field(unsigned int, type)
121 		__field(xfs_agnumber_t, agno)
122 		__field(xfs_ino_t, inum)
123 		__field(unsigned int, gen)
124 		__field(unsigned int, flags)
125 		__field(int, error)
126 	),
127 	TP_fast_assign(
128 		__entry->dev = ip->i_mount->m_super->s_dev;
129 		__entry->ino = ip->i_ino;
130 		__entry->type = sm->sm_type;
131 		__entry->agno = sm->sm_agno;
132 		__entry->inum = sm->sm_ino;
133 		__entry->gen = sm->sm_gen;
134 		__entry->flags = sm->sm_flags;
135 		__entry->error = error;
136 	),
137 	TP_printk("dev %d:%d ino 0x%llx type %s agno 0x%x inum 0x%llx gen 0x%x flags (%s) error %d",
138 		  MAJOR(__entry->dev), MINOR(__entry->dev),
139 		  __entry->ino,
140 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
141 		  __entry->agno,
142 		  __entry->inum,
143 		  __entry->gen,
144 		  __print_flags(__entry->flags, "|", XFS_SCRUB_FLAG_STRINGS),
145 		  __entry->error)
146 )
147 #define DEFINE_SCRUB_EVENT(name) \
148 DEFINE_EVENT(xchk_class, name, \
149 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, \
150 		 int error), \
151 	TP_ARGS(ip, sm, error))
152 
153 DEFINE_SCRUB_EVENT(xchk_start);
154 DEFINE_SCRUB_EVENT(xchk_done);
155 DEFINE_SCRUB_EVENT(xchk_deadlock_retry);
156 DEFINE_SCRUB_EVENT(xrep_attempt);
157 DEFINE_SCRUB_EVENT(xrep_done);
158 
159 DECLARE_EVENT_CLASS(xchk_fsgate_class,
160 	TP_PROTO(struct xfs_scrub *sc, unsigned int fsgate_flags),
161 	TP_ARGS(sc, fsgate_flags),
162 	TP_STRUCT__entry(
163 		__field(dev_t, dev)
164 		__field(unsigned int, type)
165 		__field(unsigned int, fsgate_flags)
166 	),
167 	TP_fast_assign(
168 		__entry->dev = sc->mp->m_super->s_dev;
169 		__entry->type = sc->sm->sm_type;
170 		__entry->fsgate_flags = fsgate_flags;
171 	),
172 	TP_printk("dev %d:%d type %s fsgates '%s'",
173 		  MAJOR(__entry->dev), MINOR(__entry->dev),
174 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
175 		  __print_flags(__entry->fsgate_flags, "|", XFS_SCRUB_STATE_STRINGS))
176 )
177 
178 #define DEFINE_SCRUB_FSHOOK_EVENT(name) \
179 DEFINE_EVENT(xchk_fsgate_class, name, \
180 	TP_PROTO(struct xfs_scrub *sc, unsigned int fsgates_flags), \
181 	TP_ARGS(sc, fsgates_flags))
182 
183 DEFINE_SCRUB_FSHOOK_EVENT(xchk_fsgates_enable);
184 DEFINE_SCRUB_FSHOOK_EVENT(xchk_fsgates_disable);
185 
186 TRACE_EVENT(xchk_op_error,
187 	TP_PROTO(struct xfs_scrub *sc, xfs_agnumber_t agno,
188 		 xfs_agblock_t bno, int error, void *ret_ip),
189 	TP_ARGS(sc, agno, bno, error, ret_ip),
190 	TP_STRUCT__entry(
191 		__field(dev_t, dev)
192 		__field(unsigned int, type)
193 		__field(xfs_agnumber_t, agno)
194 		__field(xfs_agblock_t, bno)
195 		__field(int, error)
196 		__field(void *, ret_ip)
197 	),
198 	TP_fast_assign(
199 		__entry->dev = sc->mp->m_super->s_dev;
200 		__entry->type = sc->sm->sm_type;
201 		__entry->agno = agno;
202 		__entry->bno = bno;
203 		__entry->error = error;
204 		__entry->ret_ip = ret_ip;
205 	),
206 	TP_printk("dev %d:%d type %s agno 0x%x agbno 0x%x error %d ret_ip %pS",
207 		  MAJOR(__entry->dev), MINOR(__entry->dev),
208 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
209 		  __entry->agno,
210 		  __entry->bno,
211 		  __entry->error,
212 		  __entry->ret_ip)
213 );
214 
215 TRACE_EVENT(xchk_file_op_error,
216 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
217 		 xfs_fileoff_t offset, int error, void *ret_ip),
218 	TP_ARGS(sc, whichfork, offset, error, ret_ip),
219 	TP_STRUCT__entry(
220 		__field(dev_t, dev)
221 		__field(xfs_ino_t, ino)
222 		__field(int, whichfork)
223 		__field(unsigned int, type)
224 		__field(xfs_fileoff_t, offset)
225 		__field(int, error)
226 		__field(void *, ret_ip)
227 	),
228 	TP_fast_assign(
229 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
230 		__entry->ino = sc->ip->i_ino;
231 		__entry->whichfork = whichfork;
232 		__entry->type = sc->sm->sm_type;
233 		__entry->offset = offset;
234 		__entry->error = error;
235 		__entry->ret_ip = ret_ip;
236 	),
237 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s fileoff 0x%llx error %d ret_ip %pS",
238 		  MAJOR(__entry->dev), MINOR(__entry->dev),
239 		  __entry->ino,
240 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
241 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
242 		  __entry->offset,
243 		  __entry->error,
244 		  __entry->ret_ip)
245 );
246 
247 DECLARE_EVENT_CLASS(xchk_block_error_class,
248 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, void *ret_ip),
249 	TP_ARGS(sc, daddr, ret_ip),
250 	TP_STRUCT__entry(
251 		__field(dev_t, dev)
252 		__field(unsigned int, type)
253 		__field(xfs_agnumber_t, agno)
254 		__field(xfs_agblock_t, agbno)
255 		__field(void *, ret_ip)
256 	),
257 	TP_fast_assign(
258 		__entry->dev = sc->mp->m_super->s_dev;
259 		__entry->type = sc->sm->sm_type;
260 		__entry->agno = xfs_daddr_to_agno(sc->mp, daddr);
261 		__entry->agbno = xfs_daddr_to_agbno(sc->mp, daddr);
262 		__entry->ret_ip = ret_ip;
263 	),
264 	TP_printk("dev %d:%d type %s agno 0x%x agbno 0x%x ret_ip %pS",
265 		  MAJOR(__entry->dev), MINOR(__entry->dev),
266 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
267 		  __entry->agno,
268 		  __entry->agbno,
269 		  __entry->ret_ip)
270 )
271 
272 #define DEFINE_SCRUB_BLOCK_ERROR_EVENT(name) \
273 DEFINE_EVENT(xchk_block_error_class, name, \
274 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, \
275 		 void *ret_ip), \
276 	TP_ARGS(sc, daddr, ret_ip))
277 
278 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_fs_error);
279 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_error);
280 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_preen);
281 
282 DECLARE_EVENT_CLASS(xchk_ino_error_class,
283 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, void *ret_ip),
284 	TP_ARGS(sc, ino, ret_ip),
285 	TP_STRUCT__entry(
286 		__field(dev_t, dev)
287 		__field(xfs_ino_t, ino)
288 		__field(unsigned int, type)
289 		__field(void *, ret_ip)
290 	),
291 	TP_fast_assign(
292 		__entry->dev = sc->mp->m_super->s_dev;
293 		__entry->ino = ino;
294 		__entry->type = sc->sm->sm_type;
295 		__entry->ret_ip = ret_ip;
296 	),
297 	TP_printk("dev %d:%d ino 0x%llx type %s ret_ip %pS",
298 		  MAJOR(__entry->dev), MINOR(__entry->dev),
299 		  __entry->ino,
300 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
301 		  __entry->ret_ip)
302 )
303 
304 #define DEFINE_SCRUB_INO_ERROR_EVENT(name) \
305 DEFINE_EVENT(xchk_ino_error_class, name, \
306 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, \
307 		 void *ret_ip), \
308 	TP_ARGS(sc, ino, ret_ip))
309 
310 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_error);
311 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_preen);
312 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_warning);
313 
314 DECLARE_EVENT_CLASS(xchk_fblock_error_class,
315 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
316 		 xfs_fileoff_t offset, void *ret_ip),
317 	TP_ARGS(sc, whichfork, offset, ret_ip),
318 	TP_STRUCT__entry(
319 		__field(dev_t, dev)
320 		__field(xfs_ino_t, ino)
321 		__field(int, whichfork)
322 		__field(unsigned int, type)
323 		__field(xfs_fileoff_t, offset)
324 		__field(void *, ret_ip)
325 	),
326 	TP_fast_assign(
327 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
328 		__entry->ino = sc->ip->i_ino;
329 		__entry->whichfork = whichfork;
330 		__entry->type = sc->sm->sm_type;
331 		__entry->offset = offset;
332 		__entry->ret_ip = ret_ip;
333 	),
334 	TP_printk("dev %d:%d ino 0x%llx fork %s type %s fileoff 0x%llx ret_ip %pS",
335 		  MAJOR(__entry->dev), MINOR(__entry->dev),
336 		  __entry->ino,
337 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
338 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
339 		  __entry->offset,
340 		  __entry->ret_ip)
341 );
342 
343 #define DEFINE_SCRUB_FBLOCK_ERROR_EVENT(name) \
344 DEFINE_EVENT(xchk_fblock_error_class, name, \
345 	TP_PROTO(struct xfs_scrub *sc, int whichfork, \
346 		 xfs_fileoff_t offset, void *ret_ip), \
347 	TP_ARGS(sc, whichfork, offset, ret_ip))
348 
349 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_error);
350 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_warning);
351 
352 #ifdef CONFIG_XFS_QUOTA
353 DECLARE_EVENT_CLASS(xchk_dqiter_class,
354 	TP_PROTO(struct xchk_dqiter *cursor, uint64_t id),
355 	TP_ARGS(cursor, id),
356 	TP_STRUCT__entry(
357 		__field(dev_t, dev)
358 		__field(xfs_dqtype_t, dqtype)
359 		__field(xfs_ino_t, ino)
360 		__field(unsigned long long, cur_id)
361 		__field(unsigned long long, id)
362 		__field(xfs_fileoff_t, startoff)
363 		__field(xfs_fsblock_t, startblock)
364 		__field(xfs_filblks_t, blockcount)
365 		__field(xfs_exntst_t, state)
366 	),
367 	TP_fast_assign(
368 		__entry->dev = cursor->sc->ip->i_mount->m_super->s_dev;
369 		__entry->dqtype = cursor->dqtype;
370 		__entry->ino = cursor->quota_ip->i_ino;
371 		__entry->cur_id = cursor->id;
372 		__entry->startoff = cursor->bmap.br_startoff;
373 		__entry->startblock = cursor->bmap.br_startblock;
374 		__entry->blockcount = cursor->bmap.br_blockcount;
375 		__entry->state = cursor->bmap.br_state;
376 		__entry->id = id;
377 	),
378 	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",
379 		  MAJOR(__entry->dev), MINOR(__entry->dev),
380 		  __print_symbolic(__entry->dqtype, XFS_DQTYPE_STRINGS),
381 		  __entry->ino,
382 		  __entry->cur_id,
383 		  __entry->startoff,
384 		  __entry->startblock,
385 		  __entry->blockcount,
386 		  __entry->state,
387 		  __entry->id)
388 );
389 
390 #define DEFINE_SCRUB_DQITER_EVENT(name) \
391 DEFINE_EVENT(xchk_dqiter_class, name, \
392 	TP_PROTO(struct xchk_dqiter *cursor, uint64_t id), \
393 	TP_ARGS(cursor, id))
394 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter_revalidate_bmap);
395 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter_advance_bmap);
396 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter_advance_incore);
397 DEFINE_SCRUB_DQITER_EVENT(xchk_dquot_iter);
398 #endif /* CONFIG_XFS_QUOTA */
399 
400 TRACE_EVENT(xchk_incomplete,
401 	TP_PROTO(struct xfs_scrub *sc, void *ret_ip),
402 	TP_ARGS(sc, ret_ip),
403 	TP_STRUCT__entry(
404 		__field(dev_t, dev)
405 		__field(unsigned int, type)
406 		__field(void *, ret_ip)
407 	),
408 	TP_fast_assign(
409 		__entry->dev = sc->mp->m_super->s_dev;
410 		__entry->type = sc->sm->sm_type;
411 		__entry->ret_ip = ret_ip;
412 	),
413 	TP_printk("dev %d:%d type %s ret_ip %pS",
414 		  MAJOR(__entry->dev), MINOR(__entry->dev),
415 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
416 		  __entry->ret_ip)
417 );
418 
419 TRACE_EVENT(xchk_btree_op_error,
420 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
421 		 int level, int error, void *ret_ip),
422 	TP_ARGS(sc, cur, level, error, ret_ip),
423 	TP_STRUCT__entry(
424 		__field(dev_t, dev)
425 		__field(unsigned int, type)
426 		__field(xfs_btnum_t, btnum)
427 		__field(int, level)
428 		__field(xfs_agnumber_t, agno)
429 		__field(xfs_agblock_t, bno)
430 		__field(int, ptr)
431 		__field(int, error)
432 		__field(void *, ret_ip)
433 	),
434 	TP_fast_assign(
435 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
436 
437 		__entry->dev = sc->mp->m_super->s_dev;
438 		__entry->type = sc->sm->sm_type;
439 		__entry->btnum = cur->bc_btnum;
440 		__entry->level = level;
441 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
442 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
443 		__entry->ptr = cur->bc_levels[level].ptr;
444 		__entry->error = error;
445 		__entry->ret_ip = ret_ip;
446 	),
447 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno 0x%x agbno 0x%x error %d ret_ip %pS",
448 		  MAJOR(__entry->dev), MINOR(__entry->dev),
449 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
450 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
451 		  __entry->level,
452 		  __entry->ptr,
453 		  __entry->agno,
454 		  __entry->bno,
455 		  __entry->error,
456 		  __entry->ret_ip)
457 );
458 
459 TRACE_EVENT(xchk_ifork_btree_op_error,
460 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
461 		 int level, int error, void *ret_ip),
462 	TP_ARGS(sc, cur, level, error, ret_ip),
463 	TP_STRUCT__entry(
464 		__field(dev_t, dev)
465 		__field(xfs_ino_t, ino)
466 		__field(int, whichfork)
467 		__field(unsigned int, type)
468 		__field(xfs_btnum_t, btnum)
469 		__field(int, level)
470 		__field(int, ptr)
471 		__field(xfs_agnumber_t, agno)
472 		__field(xfs_agblock_t, bno)
473 		__field(int, error)
474 		__field(void *, ret_ip)
475 	),
476 	TP_fast_assign(
477 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
478 		__entry->dev = sc->mp->m_super->s_dev;
479 		__entry->ino = sc->ip->i_ino;
480 		__entry->whichfork = cur->bc_ino.whichfork;
481 		__entry->type = sc->sm->sm_type;
482 		__entry->btnum = cur->bc_btnum;
483 		__entry->level = level;
484 		__entry->ptr = cur->bc_levels[level].ptr;
485 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
486 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
487 		__entry->error = error;
488 		__entry->ret_ip = ret_ip;
489 	),
490 	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",
491 		  MAJOR(__entry->dev), MINOR(__entry->dev),
492 		  __entry->ino,
493 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
494 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
495 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
496 		  __entry->level,
497 		  __entry->ptr,
498 		  __entry->agno,
499 		  __entry->bno,
500 		  __entry->error,
501 		  __entry->ret_ip)
502 );
503 
504 TRACE_EVENT(xchk_btree_error,
505 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
506 		 int level, void *ret_ip),
507 	TP_ARGS(sc, cur, level, ret_ip),
508 	TP_STRUCT__entry(
509 		__field(dev_t, dev)
510 		__field(unsigned int, type)
511 		__field(xfs_btnum_t, btnum)
512 		__field(int, level)
513 		__field(xfs_agnumber_t, agno)
514 		__field(xfs_agblock_t, bno)
515 		__field(int, ptr)
516 		__field(void *, ret_ip)
517 	),
518 	TP_fast_assign(
519 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
520 		__entry->dev = sc->mp->m_super->s_dev;
521 		__entry->type = sc->sm->sm_type;
522 		__entry->btnum = cur->bc_btnum;
523 		__entry->level = level;
524 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
525 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
526 		__entry->ptr = cur->bc_levels[level].ptr;
527 		__entry->ret_ip = ret_ip;
528 	),
529 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno 0x%x agbno 0x%x ret_ip %pS",
530 		  MAJOR(__entry->dev), MINOR(__entry->dev),
531 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
532 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
533 		  __entry->level,
534 		  __entry->ptr,
535 		  __entry->agno,
536 		  __entry->bno,
537 		  __entry->ret_ip)
538 );
539 
540 TRACE_EVENT(xchk_ifork_btree_error,
541 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
542 		 int level, void *ret_ip),
543 	TP_ARGS(sc, cur, level, ret_ip),
544 	TP_STRUCT__entry(
545 		__field(dev_t, dev)
546 		__field(xfs_ino_t, ino)
547 		__field(int, whichfork)
548 		__field(unsigned int, type)
549 		__field(xfs_btnum_t, btnum)
550 		__field(int, level)
551 		__field(xfs_agnumber_t, agno)
552 		__field(xfs_agblock_t, bno)
553 		__field(int, ptr)
554 		__field(void *, ret_ip)
555 	),
556 	TP_fast_assign(
557 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
558 		__entry->dev = sc->mp->m_super->s_dev;
559 		__entry->ino = sc->ip->i_ino;
560 		__entry->whichfork = cur->bc_ino.whichfork;
561 		__entry->type = sc->sm->sm_type;
562 		__entry->btnum = cur->bc_btnum;
563 		__entry->level = level;
564 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
565 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
566 		__entry->ptr = cur->bc_levels[level].ptr;
567 		__entry->ret_ip = ret_ip;
568 	),
569 	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",
570 		  MAJOR(__entry->dev), MINOR(__entry->dev),
571 		  __entry->ino,
572 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
573 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
574 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
575 		  __entry->level,
576 		  __entry->ptr,
577 		  __entry->agno,
578 		  __entry->bno,
579 		  __entry->ret_ip)
580 );
581 
582 DECLARE_EVENT_CLASS(xchk_sbtree_class,
583 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
584 		 int level),
585 	TP_ARGS(sc, cur, level),
586 	TP_STRUCT__entry(
587 		__field(dev_t, dev)
588 		__field(int, type)
589 		__field(xfs_btnum_t, btnum)
590 		__field(xfs_agnumber_t, agno)
591 		__field(xfs_agblock_t, bno)
592 		__field(int, level)
593 		__field(int, nlevels)
594 		__field(int, ptr)
595 	),
596 	TP_fast_assign(
597 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
598 
599 		__entry->dev = sc->mp->m_super->s_dev;
600 		__entry->type = sc->sm->sm_type;
601 		__entry->btnum = cur->bc_btnum;
602 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
603 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
604 		__entry->level = level;
605 		__entry->nlevels = cur->bc_nlevels;
606 		__entry->ptr = cur->bc_levels[level].ptr;
607 	),
608 	TP_printk("dev %d:%d type %s btree %s agno 0x%x agbno 0x%x level %d nlevels %d ptr %d",
609 		  MAJOR(__entry->dev), MINOR(__entry->dev),
610 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
611 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
612 		  __entry->agno,
613 		  __entry->bno,
614 		  __entry->level,
615 		  __entry->nlevels,
616 		  __entry->ptr)
617 )
618 #define DEFINE_SCRUB_SBTREE_EVENT(name) \
619 DEFINE_EVENT(xchk_sbtree_class, name, \
620 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur, \
621 		 int level), \
622 	TP_ARGS(sc, cur, level))
623 
624 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_rec);
625 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_key);
626 
627 TRACE_EVENT(xchk_xref_error,
628 	TP_PROTO(struct xfs_scrub *sc, int error, void *ret_ip),
629 	TP_ARGS(sc, error, ret_ip),
630 	TP_STRUCT__entry(
631 		__field(dev_t, dev)
632 		__field(int, type)
633 		__field(int, error)
634 		__field(void *, ret_ip)
635 	),
636 	TP_fast_assign(
637 		__entry->dev = sc->mp->m_super->s_dev;
638 		__entry->type = sc->sm->sm_type;
639 		__entry->error = error;
640 		__entry->ret_ip = ret_ip;
641 	),
642 	TP_printk("dev %d:%d type %s xref error %d ret_ip %pS",
643 		  MAJOR(__entry->dev), MINOR(__entry->dev),
644 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
645 		  __entry->error,
646 		  __entry->ret_ip)
647 );
648 
649 TRACE_EVENT(xchk_iallocbt_check_cluster,
650 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
651 		 xfs_agino_t startino, xfs_daddr_t map_daddr,
652 		 unsigned short map_len, unsigned int chunk_ino,
653 		 unsigned int nr_inodes, uint16_t cluster_mask,
654 		 uint16_t holemask, unsigned int cluster_ino),
655 	TP_ARGS(mp, agno, startino, map_daddr, map_len, chunk_ino, nr_inodes,
656 		cluster_mask, holemask, cluster_ino),
657 	TP_STRUCT__entry(
658 		__field(dev_t, dev)
659 		__field(xfs_agnumber_t, agno)
660 		__field(xfs_agino_t, startino)
661 		__field(xfs_daddr_t, map_daddr)
662 		__field(unsigned short, map_len)
663 		__field(unsigned int, chunk_ino)
664 		__field(unsigned int, nr_inodes)
665 		__field(unsigned int, cluster_ino)
666 		__field(uint16_t, cluster_mask)
667 		__field(uint16_t, holemask)
668 	),
669 	TP_fast_assign(
670 		__entry->dev = mp->m_super->s_dev;
671 		__entry->agno = agno;
672 		__entry->startino = startino;
673 		__entry->map_daddr = map_daddr;
674 		__entry->map_len = map_len;
675 		__entry->chunk_ino = chunk_ino;
676 		__entry->nr_inodes = nr_inodes;
677 		__entry->cluster_mask = cluster_mask;
678 		__entry->holemask = holemask;
679 		__entry->cluster_ino = cluster_ino;
680 	),
681 	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",
682 		  MAJOR(__entry->dev), MINOR(__entry->dev),
683 		  __entry->agno,
684 		  __entry->startino,
685 		  __entry->map_daddr,
686 		  __entry->map_len,
687 		  __entry->chunk_ino,
688 		  __entry->nr_inodes,
689 		  __entry->cluster_mask,
690 		  __entry->holemask,
691 		  __entry->cluster_ino)
692 )
693 
694 TRACE_EVENT(xchk_inode_is_allocated,
695 	TP_PROTO(struct xfs_inode *ip),
696 	TP_ARGS(ip),
697 	TP_STRUCT__entry(
698 		__field(dev_t, dev)
699 		__field(xfs_ino_t, ino)
700 		__field(unsigned long, iflags)
701 		__field(umode_t, mode)
702 	),
703 	TP_fast_assign(
704 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
705 		__entry->ino = ip->i_ino;
706 		__entry->iflags = ip->i_flags;
707 		__entry->mode = VFS_I(ip)->i_mode;
708 	),
709 	TP_printk("dev %d:%d ino 0x%llx iflags 0x%lx mode 0x%x",
710 		  MAJOR(__entry->dev), MINOR(__entry->dev),
711 		  __entry->ino,
712 		  __entry->iflags,
713 		  __entry->mode)
714 );
715 
716 TRACE_EVENT(xchk_fscounters_calc,
717 	TP_PROTO(struct xfs_mount *mp, uint64_t icount, uint64_t ifree,
718 		 uint64_t fdblocks, uint64_t delalloc),
719 	TP_ARGS(mp, icount, ifree, fdblocks, delalloc),
720 	TP_STRUCT__entry(
721 		__field(dev_t, dev)
722 		__field(int64_t, icount_sb)
723 		__field(uint64_t, icount_calculated)
724 		__field(int64_t, ifree_sb)
725 		__field(uint64_t, ifree_calculated)
726 		__field(int64_t, fdblocks_sb)
727 		__field(uint64_t, fdblocks_calculated)
728 		__field(uint64_t, delalloc)
729 	),
730 	TP_fast_assign(
731 		__entry->dev = mp->m_super->s_dev;
732 		__entry->icount_sb = mp->m_sb.sb_icount;
733 		__entry->icount_calculated = icount;
734 		__entry->ifree_sb = mp->m_sb.sb_ifree;
735 		__entry->ifree_calculated = ifree;
736 		__entry->fdblocks_sb = mp->m_sb.sb_fdblocks;
737 		__entry->fdblocks_calculated = fdblocks;
738 		__entry->delalloc = delalloc;
739 	),
740 	TP_printk("dev %d:%d icount %lld:%llu ifree %lld::%llu fdblocks %lld::%llu delalloc %llu",
741 		  MAJOR(__entry->dev), MINOR(__entry->dev),
742 		  __entry->icount_sb,
743 		  __entry->icount_calculated,
744 		  __entry->ifree_sb,
745 		  __entry->ifree_calculated,
746 		  __entry->fdblocks_sb,
747 		  __entry->fdblocks_calculated,
748 		  __entry->delalloc)
749 )
750 
751 TRACE_EVENT(xchk_fscounters_within_range,
752 	TP_PROTO(struct xfs_mount *mp, uint64_t expected, int64_t curr_value,
753 		 int64_t old_value),
754 	TP_ARGS(mp, expected, curr_value, old_value),
755 	TP_STRUCT__entry(
756 		__field(dev_t, dev)
757 		__field(uint64_t, expected)
758 		__field(int64_t, curr_value)
759 		__field(int64_t, old_value)
760 	),
761 	TP_fast_assign(
762 		__entry->dev = mp->m_super->s_dev;
763 		__entry->expected = expected;
764 		__entry->curr_value = curr_value;
765 		__entry->old_value = old_value;
766 	),
767 	TP_printk("dev %d:%d expected %llu curr_value %lld old_value %lld",
768 		  MAJOR(__entry->dev), MINOR(__entry->dev),
769 		  __entry->expected,
770 		  __entry->curr_value,
771 		  __entry->old_value)
772 )
773 
774 DECLARE_EVENT_CLASS(xchk_fsfreeze_class,
775 	TP_PROTO(struct xfs_scrub *sc, int error),
776 	TP_ARGS(sc, error),
777 	TP_STRUCT__entry(
778 		__field(dev_t, dev)
779 		__field(unsigned int, type)
780 		__field(int, error)
781 	),
782 	TP_fast_assign(
783 		__entry->dev = sc->mp->m_super->s_dev;
784 		__entry->type = sc->sm->sm_type;
785 		__entry->error = error;
786 	),
787 	TP_printk("dev %d:%d type %s error %d",
788 		  MAJOR(__entry->dev), MINOR(__entry->dev),
789 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
790 		  __entry->error)
791 );
792 #define DEFINE_XCHK_FSFREEZE_EVENT(name) \
793 DEFINE_EVENT(xchk_fsfreeze_class, name, \
794 	TP_PROTO(struct xfs_scrub *sc, int error), \
795 	TP_ARGS(sc, error))
796 DEFINE_XCHK_FSFREEZE_EVENT(xchk_fsfreeze);
797 DEFINE_XCHK_FSFREEZE_EVENT(xchk_fsthaw);
798 
799 TRACE_EVENT(xchk_refcount_incorrect,
800 	TP_PROTO(struct xfs_perag *pag, const struct xfs_refcount_irec *irec,
801 		 xfs_nlink_t seen),
802 	TP_ARGS(pag, irec, seen),
803 	TP_STRUCT__entry(
804 		__field(dev_t, dev)
805 		__field(xfs_agnumber_t, agno)
806 		__field(enum xfs_refc_domain, domain)
807 		__field(xfs_agblock_t, startblock)
808 		__field(xfs_extlen_t, blockcount)
809 		__field(xfs_nlink_t, refcount)
810 		__field(xfs_nlink_t, seen)
811 	),
812 	TP_fast_assign(
813 		__entry->dev = pag->pag_mount->m_super->s_dev;
814 		__entry->agno = pag->pag_agno;
815 		__entry->domain = irec->rc_domain;
816 		__entry->startblock = irec->rc_startblock;
817 		__entry->blockcount = irec->rc_blockcount;
818 		__entry->refcount = irec->rc_refcount;
819 		__entry->seen = seen;
820 	),
821 	TP_printk("dev %d:%d agno 0x%x dom %s agbno 0x%x fsbcount 0x%x refcount %u seen %u",
822 		  MAJOR(__entry->dev), MINOR(__entry->dev),
823 		  __entry->agno,
824 		  __print_symbolic(__entry->domain, XFS_REFC_DOMAIN_STRINGS),
825 		  __entry->startblock,
826 		  __entry->blockcount,
827 		  __entry->refcount,
828 		  __entry->seen)
829 )
830 
831 TRACE_EVENT(xfile_create,
832 	TP_PROTO(struct xfile *xf),
833 	TP_ARGS(xf),
834 	TP_STRUCT__entry(
835 		__field(dev_t, dev)
836 		__field(unsigned long, ino)
837 		__array(char, pathname, 256)
838 	),
839 	TP_fast_assign(
840 		char		pathname[257];
841 		char		*path;
842 
843 		__entry->ino = file_inode(xf->file)->i_ino;
844 		memset(pathname, 0, sizeof(pathname));
845 		path = file_path(xf->file, pathname, sizeof(pathname) - 1);
846 		if (IS_ERR(path))
847 			path = "(unknown)";
848 		strncpy(__entry->pathname, path, sizeof(__entry->pathname));
849 	),
850 	TP_printk("xfino 0x%lx path '%s'",
851 		  __entry->ino,
852 		  __entry->pathname)
853 );
854 
855 TRACE_EVENT(xfile_destroy,
856 	TP_PROTO(struct xfile *xf),
857 	TP_ARGS(xf),
858 	TP_STRUCT__entry(
859 		__field(unsigned long, ino)
860 		__field(unsigned long long, bytes)
861 		__field(loff_t, size)
862 	),
863 	TP_fast_assign(
864 		struct xfile_stat	statbuf;
865 		int			ret;
866 
867 		ret = xfile_stat(xf, &statbuf);
868 		if (!ret) {
869 			__entry->bytes = statbuf.bytes;
870 			__entry->size = statbuf.size;
871 		} else {
872 			__entry->bytes = -1;
873 			__entry->size = -1;
874 		}
875 		__entry->ino = file_inode(xf->file)->i_ino;
876 	),
877 	TP_printk("xfino 0x%lx mem_bytes 0x%llx isize 0x%llx",
878 		  __entry->ino,
879 		  __entry->bytes,
880 		  __entry->size)
881 );
882 
883 DECLARE_EVENT_CLASS(xfile_class,
884 	TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount),
885 	TP_ARGS(xf, pos, bytecount),
886 	TP_STRUCT__entry(
887 		__field(unsigned long, ino)
888 		__field(unsigned long long, bytes_used)
889 		__field(loff_t, pos)
890 		__field(loff_t, size)
891 		__field(unsigned long long, bytecount)
892 	),
893 	TP_fast_assign(
894 		struct xfile_stat	statbuf;
895 		int			ret;
896 
897 		ret = xfile_stat(xf, &statbuf);
898 		if (!ret) {
899 			__entry->bytes_used = statbuf.bytes;
900 			__entry->size = statbuf.size;
901 		} else {
902 			__entry->bytes_used = -1;
903 			__entry->size = -1;
904 		}
905 		__entry->ino = file_inode(xf->file)->i_ino;
906 		__entry->pos = pos;
907 		__entry->bytecount = bytecount;
908 	),
909 	TP_printk("xfino 0x%lx mem_bytes 0x%llx pos 0x%llx bytecount 0x%llx isize 0x%llx",
910 		  __entry->ino,
911 		  __entry->bytes_used,
912 		  __entry->pos,
913 		  __entry->bytecount,
914 		  __entry->size)
915 );
916 #define DEFINE_XFILE_EVENT(name) \
917 DEFINE_EVENT(xfile_class, name, \
918 	TP_PROTO(struct xfile *xf, loff_t pos, unsigned long long bytecount), \
919 	TP_ARGS(xf, pos, bytecount))
920 DEFINE_XFILE_EVENT(xfile_pread);
921 DEFINE_XFILE_EVENT(xfile_pwrite);
922 DEFINE_XFILE_EVENT(xfile_seek_data);
923 DEFINE_XFILE_EVENT(xfile_get_page);
924 DEFINE_XFILE_EVENT(xfile_put_page);
925 
926 TRACE_EVENT(xfarray_create,
927 	TP_PROTO(struct xfarray *xfa, unsigned long long required_capacity),
928 	TP_ARGS(xfa, required_capacity),
929 	TP_STRUCT__entry(
930 		__field(unsigned long, ino)
931 		__field(uint64_t, max_nr)
932 		__field(size_t, obj_size)
933 		__field(int, obj_size_log)
934 		__field(unsigned long long, required_capacity)
935 	),
936 	TP_fast_assign(
937 		__entry->max_nr = xfa->max_nr;
938 		__entry->obj_size = xfa->obj_size;
939 		__entry->obj_size_log = xfa->obj_size_log;
940 		__entry->ino = file_inode(xfa->xfile->file)->i_ino;
941 		__entry->required_capacity = required_capacity;
942 	),
943 	TP_printk("xfino 0x%lx max_nr %llu reqd_nr %llu objsz %zu objszlog %d",
944 		  __entry->ino,
945 		  __entry->max_nr,
946 		  __entry->required_capacity,
947 		  __entry->obj_size,
948 		  __entry->obj_size_log)
949 );
950 
951 TRACE_EVENT(xfarray_isort,
952 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
953 	TP_ARGS(si, lo, hi),
954 	TP_STRUCT__entry(
955 		__field(unsigned long, ino)
956 		__field(unsigned long long, lo)
957 		__field(unsigned long long, hi)
958 	),
959 	TP_fast_assign(
960 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
961 		__entry->lo = lo;
962 		__entry->hi = hi;
963 	),
964 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu",
965 		  __entry->ino,
966 		  __entry->lo,
967 		  __entry->hi,
968 		  __entry->hi - __entry->lo)
969 );
970 
971 TRACE_EVENT(xfarray_pagesort,
972 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
973 	TP_ARGS(si, lo, hi),
974 	TP_STRUCT__entry(
975 		__field(unsigned long, ino)
976 		__field(unsigned long long, lo)
977 		__field(unsigned long long, hi)
978 	),
979 	TP_fast_assign(
980 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
981 		__entry->lo = lo;
982 		__entry->hi = hi;
983 	),
984 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu",
985 		  __entry->ino,
986 		  __entry->lo,
987 		  __entry->hi,
988 		  __entry->hi - __entry->lo)
989 );
990 
991 TRACE_EVENT(xfarray_qsort,
992 	TP_PROTO(struct xfarray_sortinfo *si, uint64_t lo, uint64_t hi),
993 	TP_ARGS(si, lo, hi),
994 	TP_STRUCT__entry(
995 		__field(unsigned long, ino)
996 		__field(unsigned long long, lo)
997 		__field(unsigned long long, hi)
998 		__field(int, stack_depth)
999 		__field(int, max_stack_depth)
1000 	),
1001 	TP_fast_assign(
1002 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1003 		__entry->lo = lo;
1004 		__entry->hi = hi;
1005 		__entry->stack_depth = si->stack_depth;
1006 		__entry->max_stack_depth = si->max_stack_depth;
1007 	),
1008 	TP_printk("xfino 0x%lx lo %llu hi %llu elts %llu stack %d/%d",
1009 		  __entry->ino,
1010 		  __entry->lo,
1011 		  __entry->hi,
1012 		  __entry->hi - __entry->lo,
1013 		  __entry->stack_depth,
1014 		  __entry->max_stack_depth)
1015 );
1016 
1017 TRACE_EVENT(xfarray_sort,
1018 	TP_PROTO(struct xfarray_sortinfo *si, size_t bytes),
1019 	TP_ARGS(si, bytes),
1020 	TP_STRUCT__entry(
1021 		__field(unsigned long, ino)
1022 		__field(unsigned long long, nr)
1023 		__field(size_t, obj_size)
1024 		__field(size_t, bytes)
1025 		__field(unsigned int, max_stack_depth)
1026 	),
1027 	TP_fast_assign(
1028 		__entry->nr = si->array->nr;
1029 		__entry->obj_size = si->array->obj_size;
1030 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1031 		__entry->bytes = bytes;
1032 		__entry->max_stack_depth = si->max_stack_depth;
1033 	),
1034 	TP_printk("xfino 0x%lx nr %llu objsz %zu stack %u bytes %zu",
1035 		  __entry->ino,
1036 		  __entry->nr,
1037 		  __entry->obj_size,
1038 		  __entry->max_stack_depth,
1039 		  __entry->bytes)
1040 );
1041 
1042 TRACE_EVENT(xfarray_sort_stats,
1043 	TP_PROTO(struct xfarray_sortinfo *si, int error),
1044 	TP_ARGS(si, error),
1045 	TP_STRUCT__entry(
1046 		__field(unsigned long, ino)
1047 #ifdef DEBUG
1048 		__field(unsigned long long, loads)
1049 		__field(unsigned long long, stores)
1050 		__field(unsigned long long, compares)
1051 		__field(unsigned long long, heapsorts)
1052 #endif
1053 		__field(unsigned int, max_stack_depth)
1054 		__field(unsigned int, max_stack_used)
1055 		__field(int, error)
1056 	),
1057 	TP_fast_assign(
1058 		__entry->ino = file_inode(si->array->xfile->file)->i_ino;
1059 #ifdef DEBUG
1060 		__entry->loads = si->loads;
1061 		__entry->stores = si->stores;
1062 		__entry->compares = si->compares;
1063 		__entry->heapsorts = si->heapsorts;
1064 #endif
1065 		__entry->max_stack_depth = si->max_stack_depth;
1066 		__entry->max_stack_used = si->max_stack_used;
1067 		__entry->error = error;
1068 	),
1069 	TP_printk(
1070 #ifdef DEBUG
1071 		  "xfino 0x%lx loads %llu stores %llu compares %llu heapsorts %llu stack_depth %u/%u error %d",
1072 #else
1073 		  "xfino 0x%lx stack_depth %u/%u error %d",
1074 #endif
1075 		  __entry->ino,
1076 #ifdef DEBUG
1077 		  __entry->loads,
1078 		  __entry->stores,
1079 		  __entry->compares,
1080 		  __entry->heapsorts,
1081 #endif
1082 		  __entry->max_stack_used,
1083 		  __entry->max_stack_depth,
1084 		  __entry->error)
1085 );
1086 
1087 #ifdef CONFIG_XFS_RT
1088 TRACE_EVENT(xchk_rtsum_record_free,
1089 	TP_PROTO(struct xfs_mount *mp, xfs_rtxnum_t start,
1090 		 xfs_rtbxlen_t len, unsigned int log, loff_t pos,
1091 		 xfs_suminfo_t value),
1092 	TP_ARGS(mp, start, len, log, pos, value),
1093 	TP_STRUCT__entry(
1094 		__field(dev_t, dev)
1095 		__field(dev_t, rtdev)
1096 		__field(xfs_rtxnum_t, start)
1097 		__field(unsigned long long, len)
1098 		__field(unsigned int, log)
1099 		__field(loff_t, pos)
1100 		__field(xfs_suminfo_t, value)
1101 	),
1102 	TP_fast_assign(
1103 		__entry->dev = mp->m_super->s_dev;
1104 		__entry->rtdev = mp->m_rtdev_targp->bt_dev;
1105 		__entry->start = start;
1106 		__entry->len = len;
1107 		__entry->log = log;
1108 		__entry->pos = pos;
1109 		__entry->value = value;
1110 	),
1111 	TP_printk("dev %d:%d rtdev %d:%d rtx 0x%llx rtxcount 0x%llx log %u rsumpos 0x%llx sumcount %u",
1112 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1113 		  MAJOR(__entry->rtdev), MINOR(__entry->rtdev),
1114 		  __entry->start,
1115 		  __entry->len,
1116 		  __entry->log,
1117 		  __entry->pos,
1118 		  __entry->value)
1119 );
1120 #endif /* CONFIG_XFS_RT */
1121 
1122 /* repair tracepoints */
1123 #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
1124 
1125 DECLARE_EVENT_CLASS(xrep_extent_class,
1126 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len),
1127 	TP_ARGS(pag, agbno, len),
1128 	TP_STRUCT__entry(
1129 		__field(dev_t, dev)
1130 		__field(xfs_agnumber_t, agno)
1131 		__field(xfs_agblock_t, agbno)
1132 		__field(xfs_extlen_t, len)
1133 	),
1134 	TP_fast_assign(
1135 		__entry->dev = pag->pag_mount->m_super->s_dev;
1136 		__entry->agno = pag->pag_agno;
1137 		__entry->agbno = agbno;
1138 		__entry->len = len;
1139 	),
1140 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
1141 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1142 		  __entry->agno,
1143 		  __entry->agbno,
1144 		  __entry->len)
1145 );
1146 #define DEFINE_REPAIR_EXTENT_EVENT(name) \
1147 DEFINE_EVENT(xrep_extent_class, name, \
1148 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len), \
1149 	TP_ARGS(pag, agbno, len))
1150 DEFINE_REPAIR_EXTENT_EVENT(xreap_dispose_unmap_extent);
1151 DEFINE_REPAIR_EXTENT_EVENT(xreap_dispose_free_extent);
1152 DEFINE_REPAIR_EXTENT_EVENT(xreap_agextent_binval);
1153 DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
1154 
1155 DECLARE_EVENT_CLASS(xrep_reap_find_class,
1156 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len,
1157 		bool crosslinked),
1158 	TP_ARGS(pag, agbno, len, crosslinked),
1159 	TP_STRUCT__entry(
1160 		__field(dev_t, dev)
1161 		__field(xfs_agnumber_t, agno)
1162 		__field(xfs_agblock_t, agbno)
1163 		__field(xfs_extlen_t, len)
1164 		__field(bool, crosslinked)
1165 	),
1166 	TP_fast_assign(
1167 		__entry->dev = pag->pag_mount->m_super->s_dev;
1168 		__entry->agno = pag->pag_agno;
1169 		__entry->agbno = agbno;
1170 		__entry->len = len;
1171 		__entry->crosslinked = crosslinked;
1172 	),
1173 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x crosslinked %d",
1174 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1175 		  __entry->agno,
1176 		  __entry->agbno,
1177 		  __entry->len,
1178 		  __entry->crosslinked ? 1 : 0)
1179 );
1180 #define DEFINE_REPAIR_REAP_FIND_EVENT(name) \
1181 DEFINE_EVENT(xrep_reap_find_class, name, \
1182 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno, xfs_extlen_t len, \
1183 		 bool crosslinked), \
1184 	TP_ARGS(pag, agbno, len, crosslinked))
1185 DEFINE_REPAIR_REAP_FIND_EVENT(xreap_agextent_select);
1186 
1187 DECLARE_EVENT_CLASS(xrep_rmap_class,
1188 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1189 		 xfs_agblock_t agbno, xfs_extlen_t len,
1190 		 uint64_t owner, uint64_t offset, unsigned int flags),
1191 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
1192 	TP_STRUCT__entry(
1193 		__field(dev_t, dev)
1194 		__field(xfs_agnumber_t, agno)
1195 		__field(xfs_agblock_t, agbno)
1196 		__field(xfs_extlen_t, len)
1197 		__field(uint64_t, owner)
1198 		__field(uint64_t, offset)
1199 		__field(unsigned int, flags)
1200 	),
1201 	TP_fast_assign(
1202 		__entry->dev = mp->m_super->s_dev;
1203 		__entry->agno = agno;
1204 		__entry->agbno = agbno;
1205 		__entry->len = len;
1206 		__entry->owner = owner;
1207 		__entry->offset = offset;
1208 		__entry->flags = flags;
1209 	),
1210 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%x",
1211 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1212 		  __entry->agno,
1213 		  __entry->agbno,
1214 		  __entry->len,
1215 		  __entry->owner,
1216 		  __entry->offset,
1217 		  __entry->flags)
1218 );
1219 #define DEFINE_REPAIR_RMAP_EVENT(name) \
1220 DEFINE_EVENT(xrep_rmap_class, name, \
1221 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1222 		 xfs_agblock_t agbno, xfs_extlen_t len, \
1223 		 uint64_t owner, uint64_t offset, unsigned int flags), \
1224 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
1225 DEFINE_REPAIR_RMAP_EVENT(xrep_ibt_walk_rmap);
1226 DEFINE_REPAIR_RMAP_EVENT(xrep_rmap_extent_fn);
1227 DEFINE_REPAIR_RMAP_EVENT(xrep_bmap_walk_rmap);
1228 
1229 TRACE_EVENT(xrep_abt_found,
1230 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1231 		 const struct xfs_alloc_rec_incore *rec),
1232 	TP_ARGS(mp, agno, rec),
1233 	TP_STRUCT__entry(
1234 		__field(dev_t, dev)
1235 		__field(xfs_agnumber_t, agno)
1236 		__field(xfs_agblock_t, startblock)
1237 		__field(xfs_extlen_t, blockcount)
1238 	),
1239 	TP_fast_assign(
1240 		__entry->dev = mp->m_super->s_dev;
1241 		__entry->agno = agno;
1242 		__entry->startblock = rec->ar_startblock;
1243 		__entry->blockcount = rec->ar_blockcount;
1244 	),
1245 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
1246 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1247 		  __entry->agno,
1248 		  __entry->startblock,
1249 		  __entry->blockcount)
1250 )
1251 
1252 TRACE_EVENT(xrep_ibt_found,
1253 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1254 		 const struct xfs_inobt_rec_incore *rec),
1255 	TP_ARGS(mp, agno, rec),
1256 	TP_STRUCT__entry(
1257 		__field(dev_t, dev)
1258 		__field(xfs_agnumber_t, agno)
1259 		__field(xfs_agino_t, startino)
1260 		__field(uint16_t, holemask)
1261 		__field(uint8_t, count)
1262 		__field(uint8_t, freecount)
1263 		__field(uint64_t, freemask)
1264 	),
1265 	TP_fast_assign(
1266 		__entry->dev = mp->m_super->s_dev;
1267 		__entry->agno = agno;
1268 		__entry->startino = rec->ir_startino;
1269 		__entry->holemask = rec->ir_holemask;
1270 		__entry->count = rec->ir_count;
1271 		__entry->freecount = rec->ir_freecount;
1272 		__entry->freemask = rec->ir_free;
1273 	),
1274 	TP_printk("dev %d:%d agno 0x%x agino 0x%x holemask 0x%x count 0x%x freecount 0x%x freemask 0x%llx",
1275 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1276 		  __entry->agno,
1277 		  __entry->startino,
1278 		  __entry->holemask,
1279 		  __entry->count,
1280 		  __entry->freecount,
1281 		  __entry->freemask)
1282 )
1283 
1284 TRACE_EVENT(xrep_refc_found,
1285 	TP_PROTO(struct xfs_perag *pag, const struct xfs_refcount_irec *rec),
1286 	TP_ARGS(pag, rec),
1287 	TP_STRUCT__entry(
1288 		__field(dev_t, dev)
1289 		__field(xfs_agnumber_t, agno)
1290 		__field(enum xfs_refc_domain, domain)
1291 		__field(xfs_agblock_t, startblock)
1292 		__field(xfs_extlen_t, blockcount)
1293 		__field(xfs_nlink_t, refcount)
1294 	),
1295 	TP_fast_assign(
1296 		__entry->dev = pag->pag_mount->m_super->s_dev;
1297 		__entry->agno = pag->pag_agno;
1298 		__entry->domain = rec->rc_domain;
1299 		__entry->startblock = rec->rc_startblock;
1300 		__entry->blockcount = rec->rc_blockcount;
1301 		__entry->refcount = rec->rc_refcount;
1302 	),
1303 	TP_printk("dev %d:%d agno 0x%x dom %s agbno 0x%x fsbcount 0x%x refcount %u",
1304 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1305 		  __entry->agno,
1306 		  __print_symbolic(__entry->domain, XFS_REFC_DOMAIN_STRINGS),
1307 		  __entry->startblock,
1308 		  __entry->blockcount,
1309 		  __entry->refcount)
1310 )
1311 
1312 TRACE_EVENT(xrep_bmap_found,
1313 	TP_PROTO(struct xfs_inode *ip, int whichfork,
1314 		 struct xfs_bmbt_irec *irec),
1315 	TP_ARGS(ip, whichfork, irec),
1316 	TP_STRUCT__entry(
1317 		__field(dev_t, dev)
1318 		__field(xfs_ino_t, ino)
1319 		__field(int, whichfork)
1320 		__field(xfs_fileoff_t, lblk)
1321 		__field(xfs_filblks_t, len)
1322 		__field(xfs_fsblock_t, pblk)
1323 		__field(int, state)
1324 	),
1325 	TP_fast_assign(
1326 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1327 		__entry->ino = ip->i_ino;
1328 		__entry->whichfork = whichfork;
1329 		__entry->lblk = irec->br_startoff;
1330 		__entry->len = irec->br_blockcount;
1331 		__entry->pblk = irec->br_startblock;
1332 		__entry->state = irec->br_state;
1333 	),
1334 	TP_printk("dev %d:%d ino 0x%llx whichfork %s fileoff 0x%llx fsbcount 0x%llx startblock 0x%llx state %d",
1335 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1336 		  __entry->ino,
1337 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
1338 		  __entry->lblk,
1339 		  __entry->len,
1340 		  __entry->pblk,
1341 		  __entry->state)
1342 );
1343 
1344 TRACE_EVENT(xrep_findroot_block,
1345 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
1346 		 uint32_t magic, uint16_t level),
1347 	TP_ARGS(mp, agno, agbno, magic, level),
1348 	TP_STRUCT__entry(
1349 		__field(dev_t, dev)
1350 		__field(xfs_agnumber_t, agno)
1351 		__field(xfs_agblock_t, agbno)
1352 		__field(uint32_t, magic)
1353 		__field(uint16_t, level)
1354 	),
1355 	TP_fast_assign(
1356 		__entry->dev = mp->m_super->s_dev;
1357 		__entry->agno = agno;
1358 		__entry->agbno = agbno;
1359 		__entry->magic = magic;
1360 		__entry->level = level;
1361 	),
1362 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x magic 0x%x level %u",
1363 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1364 		  __entry->agno,
1365 		  __entry->agbno,
1366 		  __entry->magic,
1367 		  __entry->level)
1368 )
1369 TRACE_EVENT(xrep_calc_ag_resblks,
1370 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1371 		 xfs_agino_t icount, xfs_agblock_t aglen, xfs_agblock_t freelen,
1372 		 xfs_agblock_t usedlen),
1373 	TP_ARGS(mp, agno, icount, aglen, freelen, usedlen),
1374 	TP_STRUCT__entry(
1375 		__field(dev_t, dev)
1376 		__field(xfs_agnumber_t, agno)
1377 		__field(xfs_agino_t, icount)
1378 		__field(xfs_agblock_t, aglen)
1379 		__field(xfs_agblock_t, freelen)
1380 		__field(xfs_agblock_t, usedlen)
1381 	),
1382 	TP_fast_assign(
1383 		__entry->dev = mp->m_super->s_dev;
1384 		__entry->agno = agno;
1385 		__entry->icount = icount;
1386 		__entry->aglen = aglen;
1387 		__entry->freelen = freelen;
1388 		__entry->usedlen = usedlen;
1389 	),
1390 	TP_printk("dev %d:%d agno 0x%x icount %u aglen %u freelen %u usedlen %u",
1391 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1392 		  __entry->agno,
1393 		  __entry->icount,
1394 		  __entry->aglen,
1395 		  __entry->freelen,
1396 		  __entry->usedlen)
1397 )
1398 TRACE_EVENT(xrep_calc_ag_resblks_btsize,
1399 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1400 		 xfs_agblock_t bnobt_sz, xfs_agblock_t inobt_sz,
1401 		 xfs_agblock_t rmapbt_sz, xfs_agblock_t refcbt_sz),
1402 	TP_ARGS(mp, agno, bnobt_sz, inobt_sz, rmapbt_sz, refcbt_sz),
1403 	TP_STRUCT__entry(
1404 		__field(dev_t, dev)
1405 		__field(xfs_agnumber_t, agno)
1406 		__field(xfs_agblock_t, bnobt_sz)
1407 		__field(xfs_agblock_t, inobt_sz)
1408 		__field(xfs_agblock_t, rmapbt_sz)
1409 		__field(xfs_agblock_t, refcbt_sz)
1410 	),
1411 	TP_fast_assign(
1412 		__entry->dev = mp->m_super->s_dev;
1413 		__entry->agno = agno;
1414 		__entry->bnobt_sz = bnobt_sz;
1415 		__entry->inobt_sz = inobt_sz;
1416 		__entry->rmapbt_sz = rmapbt_sz;
1417 		__entry->refcbt_sz = refcbt_sz;
1418 	),
1419 	TP_printk("dev %d:%d agno 0x%x bnobt %u inobt %u rmapbt %u refcountbt %u",
1420 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1421 		  __entry->agno,
1422 		  __entry->bnobt_sz,
1423 		  __entry->inobt_sz,
1424 		  __entry->rmapbt_sz,
1425 		  __entry->refcbt_sz)
1426 )
1427 TRACE_EVENT(xrep_reset_counters,
1428 	TP_PROTO(struct xfs_mount *mp),
1429 	TP_ARGS(mp),
1430 	TP_STRUCT__entry(
1431 		__field(dev_t, dev)
1432 	),
1433 	TP_fast_assign(
1434 		__entry->dev = mp->m_super->s_dev;
1435 	),
1436 	TP_printk("dev %d:%d",
1437 		  MAJOR(__entry->dev), MINOR(__entry->dev))
1438 )
1439 
1440 DECLARE_EVENT_CLASS(xrep_newbt_extent_class,
1441 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1442 		 xfs_agblock_t agbno, xfs_extlen_t len,
1443 		 int64_t owner),
1444 	TP_ARGS(mp, agno, agbno, len, owner),
1445 	TP_STRUCT__entry(
1446 		__field(dev_t, dev)
1447 		__field(xfs_agnumber_t, agno)
1448 		__field(xfs_agblock_t, agbno)
1449 		__field(xfs_extlen_t, len)
1450 		__field(int64_t, owner)
1451 	),
1452 	TP_fast_assign(
1453 		__entry->dev = mp->m_super->s_dev;
1454 		__entry->agno = agno;
1455 		__entry->agbno = agbno;
1456 		__entry->len = len;
1457 		__entry->owner = owner;
1458 	),
1459 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx",
1460 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1461 		  __entry->agno,
1462 		  __entry->agbno,
1463 		  __entry->len,
1464 		  __entry->owner)
1465 );
1466 #define DEFINE_NEWBT_EXTENT_EVENT(name) \
1467 DEFINE_EVENT(xrep_newbt_extent_class, name, \
1468 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1469 		 xfs_agblock_t agbno, xfs_extlen_t len, \
1470 		 int64_t owner), \
1471 	TP_ARGS(mp, agno, agbno, len, owner))
1472 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_alloc_ag_blocks);
1473 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_alloc_file_blocks);
1474 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_free_blocks);
1475 DEFINE_NEWBT_EXTENT_EVENT(xrep_newbt_claim_block);
1476 
1477 DECLARE_EVENT_CLASS(xrep_dinode_class,
1478 	TP_PROTO(struct xfs_scrub *sc, struct xfs_dinode *dip),
1479 	TP_ARGS(sc, dip),
1480 	TP_STRUCT__entry(
1481 		__field(dev_t, dev)
1482 		__field(xfs_ino_t, ino)
1483 		__field(uint16_t, mode)
1484 		__field(uint8_t, version)
1485 		__field(uint8_t, format)
1486 		__field(uint32_t, uid)
1487 		__field(uint32_t, gid)
1488 		__field(uint64_t, size)
1489 		__field(uint64_t, nblocks)
1490 		__field(uint32_t, extsize)
1491 		__field(uint32_t, nextents)
1492 		__field(uint16_t, anextents)
1493 		__field(uint8_t, forkoff)
1494 		__field(uint8_t, aformat)
1495 		__field(uint16_t, flags)
1496 		__field(uint32_t, gen)
1497 		__field(uint64_t, flags2)
1498 		__field(uint32_t, cowextsize)
1499 	),
1500 	TP_fast_assign(
1501 		__entry->dev = sc->mp->m_super->s_dev;
1502 		__entry->ino = sc->sm->sm_ino;
1503 		__entry->mode = be16_to_cpu(dip->di_mode);
1504 		__entry->version = dip->di_version;
1505 		__entry->format = dip->di_format;
1506 		__entry->uid = be32_to_cpu(dip->di_uid);
1507 		__entry->gid = be32_to_cpu(dip->di_gid);
1508 		__entry->size = be64_to_cpu(dip->di_size);
1509 		__entry->nblocks = be64_to_cpu(dip->di_nblocks);
1510 		__entry->extsize = be32_to_cpu(dip->di_extsize);
1511 		__entry->nextents = be32_to_cpu(dip->di_nextents);
1512 		__entry->anextents = be16_to_cpu(dip->di_anextents);
1513 		__entry->forkoff = dip->di_forkoff;
1514 		__entry->aformat = dip->di_aformat;
1515 		__entry->flags = be16_to_cpu(dip->di_flags);
1516 		__entry->gen = be32_to_cpu(dip->di_gen);
1517 		__entry->flags2 = be64_to_cpu(dip->di_flags2);
1518 		__entry->cowextsize = be32_to_cpu(dip->di_cowextsize);
1519 	),
1520 	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",
1521 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1522 		  __entry->ino,
1523 		  __entry->mode,
1524 		  __entry->version,
1525 		  __entry->format,
1526 		  __entry->uid,
1527 		  __entry->gid,
1528 		  __entry->size,
1529 		  __entry->nblocks,
1530 		  __entry->extsize,
1531 		  __entry->nextents,
1532 		  __entry->anextents,
1533 		  __entry->forkoff,
1534 		  __entry->aformat,
1535 		  __entry->flags,
1536 		  __entry->gen,
1537 		  __entry->flags2,
1538 		  __entry->cowextsize)
1539 )
1540 
1541 #define DEFINE_REPAIR_DINODE_EVENT(name) \
1542 DEFINE_EVENT(xrep_dinode_class, name, \
1543 	TP_PROTO(struct xfs_scrub *sc, struct xfs_dinode *dip), \
1544 	TP_ARGS(sc, dip))
1545 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_header);
1546 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_mode);
1547 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_flags);
1548 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_size);
1549 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_extsize_hints);
1550 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_symlink);
1551 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_dir);
1552 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_fixed);
1553 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_forks);
1554 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_dfork);
1555 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_zap_afork);
1556 DEFINE_REPAIR_DINODE_EVENT(xrep_dinode_ensure_forkoff);
1557 
1558 DECLARE_EVENT_CLASS(xrep_inode_class,
1559 	TP_PROTO(struct xfs_scrub *sc),
1560 	TP_ARGS(sc),
1561 	TP_STRUCT__entry(
1562 		__field(dev_t, dev)
1563 		__field(xfs_ino_t, ino)
1564 		__field(xfs_fsize_t, size)
1565 		__field(xfs_rfsblock_t, nblocks)
1566 		__field(uint16_t, flags)
1567 		__field(uint64_t, flags2)
1568 		__field(uint32_t, nextents)
1569 		__field(uint8_t, format)
1570 		__field(uint32_t, anextents)
1571 		__field(uint8_t, aformat)
1572 	),
1573 	TP_fast_assign(
1574 		__entry->dev = sc->mp->m_super->s_dev;
1575 		__entry->ino = sc->sm->sm_ino;
1576 		__entry->size = sc->ip->i_disk_size;
1577 		__entry->nblocks = sc->ip->i_nblocks;
1578 		__entry->flags = sc->ip->i_diflags;
1579 		__entry->flags2 = sc->ip->i_diflags2;
1580 		__entry->nextents = sc->ip->i_df.if_nextents;
1581 		__entry->format = sc->ip->i_df.if_format;
1582 		__entry->anextents = sc->ip->i_af.if_nextents;
1583 		__entry->aformat = sc->ip->i_af.if_format;
1584 	),
1585 	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",
1586 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1587 		  __entry->ino,
1588 		  __entry->size,
1589 		  __entry->nblocks,
1590 		  __entry->flags,
1591 		  __entry->flags2,
1592 		  __entry->nextents,
1593 		  __entry->format,
1594 		  __entry->anextents,
1595 		  __entry->aformat)
1596 )
1597 
1598 #define DEFINE_REPAIR_INODE_EVENT(name) \
1599 DEFINE_EVENT(xrep_inode_class, name, \
1600 	TP_PROTO(struct xfs_scrub *sc), \
1601 	TP_ARGS(sc))
1602 DEFINE_REPAIR_INODE_EVENT(xrep_inode_blockcounts);
1603 DEFINE_REPAIR_INODE_EVENT(xrep_inode_ids);
1604 DEFINE_REPAIR_INODE_EVENT(xrep_inode_flags);
1605 DEFINE_REPAIR_INODE_EVENT(xrep_inode_blockdir_size);
1606 DEFINE_REPAIR_INODE_EVENT(xrep_inode_sfdir_size);
1607 DEFINE_REPAIR_INODE_EVENT(xrep_inode_dir_size);
1608 DEFINE_REPAIR_INODE_EVENT(xrep_inode_fixed);
1609 
1610 TRACE_EVENT(xrep_dinode_count_rmaps,
1611 	TP_PROTO(struct xfs_scrub *sc, xfs_rfsblock_t data_blocks,
1612 		xfs_rfsblock_t rt_blocks, xfs_rfsblock_t attr_blocks,
1613 		xfs_extnum_t data_extents, xfs_extnum_t rt_extents,
1614 		xfs_aextnum_t attr_extents),
1615 	TP_ARGS(sc, data_blocks, rt_blocks, attr_blocks, data_extents,
1616 		rt_extents, attr_extents),
1617 	TP_STRUCT__entry(
1618 		__field(dev_t, dev)
1619 		__field(xfs_ino_t, ino)
1620 		__field(xfs_rfsblock_t, data_blocks)
1621 		__field(xfs_rfsblock_t, rt_blocks)
1622 		__field(xfs_rfsblock_t, attr_blocks)
1623 		__field(xfs_extnum_t, data_extents)
1624 		__field(xfs_extnum_t, rt_extents)
1625 		__field(xfs_aextnum_t, attr_extents)
1626 	),
1627 	TP_fast_assign(
1628 		__entry->dev = sc->mp->m_super->s_dev;
1629 		__entry->ino = sc->sm->sm_ino;
1630 		__entry->data_blocks = data_blocks;
1631 		__entry->rt_blocks = rt_blocks;
1632 		__entry->attr_blocks = attr_blocks;
1633 		__entry->data_extents = data_extents;
1634 		__entry->rt_extents = rt_extents;
1635 		__entry->attr_extents = attr_extents;
1636 	),
1637 	TP_printk("dev %d:%d ino 0x%llx dblocks 0x%llx rtblocks 0x%llx ablocks 0x%llx dextents %llu rtextents %llu aextents %u",
1638 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1639 		  __entry->ino,
1640 		  __entry->data_blocks,
1641 		  __entry->rt_blocks,
1642 		  __entry->attr_blocks,
1643 		  __entry->data_extents,
1644 		  __entry->rt_extents,
1645 		  __entry->attr_extents)
1646 );
1647 
1648 TRACE_EVENT(xrep_cow_mark_file_range,
1649 	TP_PROTO(struct xfs_inode *ip, xfs_fsblock_t startblock,
1650 		 xfs_fileoff_t startoff, xfs_filblks_t blockcount),
1651 	TP_ARGS(ip, startblock, startoff, blockcount),
1652 	TP_STRUCT__entry(
1653 		__field(dev_t, dev)
1654 		__field(xfs_ino_t, ino)
1655 		__field(xfs_fsblock_t, startblock)
1656 		__field(xfs_fileoff_t, startoff)
1657 		__field(xfs_filblks_t, blockcount)
1658 	),
1659 	TP_fast_assign(
1660 		__entry->dev = ip->i_mount->m_super->s_dev;
1661 		__entry->ino = ip->i_ino;
1662 		__entry->startoff = startoff;
1663 		__entry->startblock = startblock;
1664 		__entry->blockcount = blockcount;
1665 	),
1666 	TP_printk("dev %d:%d ino 0x%llx fileoff 0x%llx startblock 0x%llx fsbcount 0x%llx",
1667 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1668 		  __entry->ino,
1669 		  __entry->startoff,
1670 		  __entry->startblock,
1671 		  __entry->blockcount)
1672 );
1673 
1674 TRACE_EVENT(xrep_cow_replace_mapping,
1675 	TP_PROTO(struct xfs_inode *ip, const struct xfs_bmbt_irec *irec,
1676 		 xfs_fsblock_t new_startblock, xfs_extlen_t new_blockcount),
1677 	TP_ARGS(ip, irec, new_startblock, new_blockcount),
1678 	TP_STRUCT__entry(
1679 		__field(dev_t, dev)
1680 		__field(xfs_ino_t, ino)
1681 		__field(xfs_fsblock_t, startblock)
1682 		__field(xfs_fileoff_t, startoff)
1683 		__field(xfs_filblks_t, blockcount)
1684 		__field(xfs_exntst_t, state)
1685 		__field(xfs_fsblock_t, new_startblock)
1686 		__field(xfs_extlen_t, new_blockcount)
1687 	),
1688 	TP_fast_assign(
1689 		__entry->dev = ip->i_mount->m_super->s_dev;
1690 		__entry->ino = ip->i_ino;
1691 		__entry->startoff = irec->br_startoff;
1692 		__entry->startblock = irec->br_startblock;
1693 		__entry->blockcount = irec->br_blockcount;
1694 		__entry->state = irec->br_state;
1695 		__entry->new_startblock = new_startblock;
1696 		__entry->new_blockcount = new_blockcount;
1697 	),
1698 	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",
1699 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1700 		  __entry->ino,
1701 		  __entry->startoff,
1702 		  __entry->startblock,
1703 		  __entry->blockcount,
1704 		  __entry->state,
1705 		  __entry->new_startblock,
1706 		  __entry->new_blockcount)
1707 );
1708 
1709 TRACE_EVENT(xrep_cow_free_staging,
1710 	TP_PROTO(struct xfs_perag *pag, xfs_agblock_t agbno,
1711 		 xfs_extlen_t blockcount),
1712 	TP_ARGS(pag, agbno, blockcount),
1713 	TP_STRUCT__entry(
1714 		__field(dev_t, dev)
1715 		__field(xfs_agnumber_t, agno)
1716 		__field(xfs_agblock_t, agbno)
1717 		__field(xfs_extlen_t, blockcount)
1718 	),
1719 	TP_fast_assign(
1720 		__entry->dev = pag->pag_mount->m_super->s_dev;
1721 		__entry->agno = pag->pag_agno;
1722 		__entry->agbno = agbno;
1723 		__entry->blockcount = blockcount;
1724 	),
1725 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
1726 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1727 		  __entry->agno,
1728 		  __entry->agbno,
1729 		  __entry->blockcount)
1730 );
1731 
1732 #ifdef CONFIG_XFS_QUOTA
1733 DECLARE_EVENT_CLASS(xrep_dquot_class,
1734 	TP_PROTO(struct xfs_mount *mp, uint8_t type, uint32_t id),
1735 	TP_ARGS(mp, type, id),
1736 	TP_STRUCT__entry(
1737 		__field(dev_t, dev)
1738 		__field(uint8_t, type)
1739 		__field(uint32_t, id)
1740 	),
1741 	TP_fast_assign(
1742 		__entry->dev = mp->m_super->s_dev;
1743 		__entry->id = id;
1744 		__entry->type = type;
1745 	),
1746 	TP_printk("dev %d:%d type %s id 0x%x",
1747 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1748 		  __print_flags(__entry->type, "|", XFS_DQTYPE_STRINGS),
1749 		  __entry->id)
1750 );
1751 
1752 #define DEFINE_XREP_DQUOT_EVENT(name) \
1753 DEFINE_EVENT(xrep_dquot_class, name, \
1754 	TP_PROTO(struct xfs_mount *mp, uint8_t type, uint32_t id), \
1755 	TP_ARGS(mp, type, id))
1756 DEFINE_XREP_DQUOT_EVENT(xrep_dquot_item);
1757 DEFINE_XREP_DQUOT_EVENT(xrep_disk_dquot);
1758 DEFINE_XREP_DQUOT_EVENT(xrep_dquot_item_fill_bmap_hole);
1759 #endif /* CONFIG_XFS_QUOTA */
1760 
1761 #endif /* IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) */
1762 
1763 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
1764 
1765 #undef TRACE_INCLUDE_PATH
1766 #define TRACE_INCLUDE_PATH .
1767 #define TRACE_INCLUDE_FILE scrub/trace
1768 #include <trace/define_trace.h>
1769