xref: /openbmc/linux/fs/xfs/scrub/trace.h (revision b4e18b29)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2017 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5  */
6 #undef TRACE_SYSTEM
7 #define TRACE_SYSTEM xfs_scrub
8 
9 #if !defined(_TRACE_XFS_SCRUB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _TRACE_XFS_SCRUB_TRACE_H
11 
12 #include <linux/tracepoint.h>
13 #include "xfs_bit.h"
14 
15 /*
16  * ftrace's __print_symbolic requires that all enum values be wrapped in the
17  * TRACE_DEFINE_ENUM macro so that the enum value can be encoded in the ftrace
18  * ring buffer.  Somehow this was only worth mentioning in the ftrace sample
19  * code.
20  */
21 TRACE_DEFINE_ENUM(XFS_BTNUM_BNOi);
22 TRACE_DEFINE_ENUM(XFS_BTNUM_CNTi);
23 TRACE_DEFINE_ENUM(XFS_BTNUM_BMAPi);
24 TRACE_DEFINE_ENUM(XFS_BTNUM_INOi);
25 TRACE_DEFINE_ENUM(XFS_BTNUM_FINOi);
26 TRACE_DEFINE_ENUM(XFS_BTNUM_RMAPi);
27 TRACE_DEFINE_ENUM(XFS_BTNUM_REFCi);
28 
29 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PROBE);
30 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SB);
31 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGF);
32 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGFL);
33 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_AGI);
34 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BNOBT);
35 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_CNTBT);
36 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INOBT);
37 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FINOBT);
38 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RMAPBT);
39 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_REFCNTBT);
40 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_INODE);
41 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTD);
42 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTA);
43 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_BMBTC);
44 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_DIR);
45 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_XATTR);
46 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_SYMLINK);
47 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PARENT);
48 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTBITMAP);
49 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_RTSUM);
50 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_UQUOTA);
51 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_GQUOTA);
52 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_PQUOTA);
53 TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FSCOUNTERS);
54 
55 #define XFS_SCRUB_TYPE_STRINGS \
56 	{ XFS_SCRUB_TYPE_PROBE,		"probe" }, \
57 	{ XFS_SCRUB_TYPE_SB,		"sb" }, \
58 	{ XFS_SCRUB_TYPE_AGF,		"agf" }, \
59 	{ XFS_SCRUB_TYPE_AGFL,		"agfl" }, \
60 	{ XFS_SCRUB_TYPE_AGI,		"agi" }, \
61 	{ XFS_SCRUB_TYPE_BNOBT,		"bnobt" }, \
62 	{ XFS_SCRUB_TYPE_CNTBT,		"cntbt" }, \
63 	{ XFS_SCRUB_TYPE_INOBT,		"inobt" }, \
64 	{ XFS_SCRUB_TYPE_FINOBT,	"finobt" }, \
65 	{ XFS_SCRUB_TYPE_RMAPBT,	"rmapbt" }, \
66 	{ XFS_SCRUB_TYPE_REFCNTBT,	"refcountbt" }, \
67 	{ XFS_SCRUB_TYPE_INODE,		"inode" }, \
68 	{ XFS_SCRUB_TYPE_BMBTD,		"bmapbtd" }, \
69 	{ XFS_SCRUB_TYPE_BMBTA,		"bmapbta" }, \
70 	{ XFS_SCRUB_TYPE_BMBTC,		"bmapbtc" }, \
71 	{ XFS_SCRUB_TYPE_DIR,		"directory" }, \
72 	{ XFS_SCRUB_TYPE_XATTR,		"xattr" }, \
73 	{ XFS_SCRUB_TYPE_SYMLINK,	"symlink" }, \
74 	{ XFS_SCRUB_TYPE_PARENT,	"parent" }, \
75 	{ XFS_SCRUB_TYPE_RTBITMAP,	"rtbitmap" }, \
76 	{ XFS_SCRUB_TYPE_RTSUM,		"rtsummary" }, \
77 	{ XFS_SCRUB_TYPE_UQUOTA,	"usrquota" }, \
78 	{ XFS_SCRUB_TYPE_GQUOTA,	"grpquota" }, \
79 	{ XFS_SCRUB_TYPE_PQUOTA,	"prjquota" }, \
80 	{ XFS_SCRUB_TYPE_FSCOUNTERS,	"fscounters" }
81 
82 DECLARE_EVENT_CLASS(xchk_class,
83 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm,
84 		 int error),
85 	TP_ARGS(ip, sm, error),
86 	TP_STRUCT__entry(
87 		__field(dev_t, dev)
88 		__field(xfs_ino_t, ino)
89 		__field(unsigned int, type)
90 		__field(xfs_agnumber_t, agno)
91 		__field(xfs_ino_t, inum)
92 		__field(unsigned int, gen)
93 		__field(unsigned int, flags)
94 		__field(int, error)
95 	),
96 	TP_fast_assign(
97 		__entry->dev = ip->i_mount->m_super->s_dev;
98 		__entry->ino = ip->i_ino;
99 		__entry->type = sm->sm_type;
100 		__entry->agno = sm->sm_agno;
101 		__entry->inum = sm->sm_ino;
102 		__entry->gen = sm->sm_gen;
103 		__entry->flags = sm->sm_flags;
104 		__entry->error = error;
105 	),
106 	TP_printk("dev %d:%d ino 0x%llx type %s agno %u inum %llu gen %u flags 0x%x error %d",
107 		  MAJOR(__entry->dev), MINOR(__entry->dev),
108 		  __entry->ino,
109 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
110 		  __entry->agno,
111 		  __entry->inum,
112 		  __entry->gen,
113 		  __entry->flags,
114 		  __entry->error)
115 )
116 #define DEFINE_SCRUB_EVENT(name) \
117 DEFINE_EVENT(xchk_class, name, \
118 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, \
119 		 int error), \
120 	TP_ARGS(ip, sm, error))
121 
122 DEFINE_SCRUB_EVENT(xchk_start);
123 DEFINE_SCRUB_EVENT(xchk_done);
124 DEFINE_SCRUB_EVENT(xchk_deadlock_retry);
125 DEFINE_SCRUB_EVENT(xrep_attempt);
126 DEFINE_SCRUB_EVENT(xrep_done);
127 
128 TRACE_EVENT(xchk_op_error,
129 	TP_PROTO(struct xfs_scrub *sc, xfs_agnumber_t agno,
130 		 xfs_agblock_t bno, int error, void *ret_ip),
131 	TP_ARGS(sc, agno, bno, error, ret_ip),
132 	TP_STRUCT__entry(
133 		__field(dev_t, dev)
134 		__field(unsigned int, type)
135 		__field(xfs_agnumber_t, agno)
136 		__field(xfs_agblock_t, bno)
137 		__field(int, error)
138 		__field(void *, ret_ip)
139 	),
140 	TP_fast_assign(
141 		__entry->dev = sc->mp->m_super->s_dev;
142 		__entry->type = sc->sm->sm_type;
143 		__entry->agno = agno;
144 		__entry->bno = bno;
145 		__entry->error = error;
146 		__entry->ret_ip = ret_ip;
147 	),
148 	TP_printk("dev %d:%d type %s agno %u agbno %u error %d ret_ip %pS",
149 		  MAJOR(__entry->dev), MINOR(__entry->dev),
150 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
151 		  __entry->agno,
152 		  __entry->bno,
153 		  __entry->error,
154 		  __entry->ret_ip)
155 );
156 
157 TRACE_EVENT(xchk_file_op_error,
158 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
159 		 xfs_fileoff_t offset, int error, void *ret_ip),
160 	TP_ARGS(sc, whichfork, offset, error, ret_ip),
161 	TP_STRUCT__entry(
162 		__field(dev_t, dev)
163 		__field(xfs_ino_t, ino)
164 		__field(int, whichfork)
165 		__field(unsigned int, type)
166 		__field(xfs_fileoff_t, offset)
167 		__field(int, error)
168 		__field(void *, ret_ip)
169 	),
170 	TP_fast_assign(
171 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
172 		__entry->ino = sc->ip->i_ino;
173 		__entry->whichfork = whichfork;
174 		__entry->type = sc->sm->sm_type;
175 		__entry->offset = offset;
176 		__entry->error = error;
177 		__entry->ret_ip = ret_ip;
178 	),
179 	TP_printk("dev %d:%d ino 0x%llx fork %d type %s offset %llu error %d ret_ip %pS",
180 		  MAJOR(__entry->dev), MINOR(__entry->dev),
181 		  __entry->ino,
182 		  __entry->whichfork,
183 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
184 		  __entry->offset,
185 		  __entry->error,
186 		  __entry->ret_ip)
187 );
188 
189 DECLARE_EVENT_CLASS(xchk_block_error_class,
190 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, void *ret_ip),
191 	TP_ARGS(sc, daddr, ret_ip),
192 	TP_STRUCT__entry(
193 		__field(dev_t, dev)
194 		__field(unsigned int, type)
195 		__field(xfs_agnumber_t, agno)
196 		__field(xfs_agblock_t, bno)
197 		__field(void *, ret_ip)
198 	),
199 	TP_fast_assign(
200 		xfs_fsblock_t	fsbno;
201 		xfs_agnumber_t	agno;
202 		xfs_agblock_t	bno;
203 
204 		fsbno = XFS_DADDR_TO_FSB(sc->mp, daddr);
205 		agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
206 		bno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
207 
208 		__entry->dev = sc->mp->m_super->s_dev;
209 		__entry->type = sc->sm->sm_type;
210 		__entry->agno = agno;
211 		__entry->bno = bno;
212 		__entry->ret_ip = ret_ip;
213 	),
214 	TP_printk("dev %d:%d type %s agno %u agbno %u ret_ip %pS",
215 		  MAJOR(__entry->dev), MINOR(__entry->dev),
216 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
217 		  __entry->agno,
218 		  __entry->bno,
219 		  __entry->ret_ip)
220 )
221 
222 #define DEFINE_SCRUB_BLOCK_ERROR_EVENT(name) \
223 DEFINE_EVENT(xchk_block_error_class, name, \
224 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, \
225 		 void *ret_ip), \
226 	TP_ARGS(sc, daddr, ret_ip))
227 
228 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_fs_error);
229 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_error);
230 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_preen);
231 
232 DECLARE_EVENT_CLASS(xchk_ino_error_class,
233 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, void *ret_ip),
234 	TP_ARGS(sc, ino, ret_ip),
235 	TP_STRUCT__entry(
236 		__field(dev_t, dev)
237 		__field(xfs_ino_t, ino)
238 		__field(unsigned int, type)
239 		__field(void *, ret_ip)
240 	),
241 	TP_fast_assign(
242 		__entry->dev = sc->mp->m_super->s_dev;
243 		__entry->ino = ino;
244 		__entry->type = sc->sm->sm_type;
245 		__entry->ret_ip = ret_ip;
246 	),
247 	TP_printk("dev %d:%d ino 0x%llx type %s ret_ip %pS",
248 		  MAJOR(__entry->dev), MINOR(__entry->dev),
249 		  __entry->ino,
250 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
251 		  __entry->ret_ip)
252 )
253 
254 #define DEFINE_SCRUB_INO_ERROR_EVENT(name) \
255 DEFINE_EVENT(xchk_ino_error_class, name, \
256 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, \
257 		 void *ret_ip), \
258 	TP_ARGS(sc, ino, ret_ip))
259 
260 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_error);
261 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_preen);
262 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_warning);
263 
264 DECLARE_EVENT_CLASS(xchk_fblock_error_class,
265 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
266 		 xfs_fileoff_t offset, void *ret_ip),
267 	TP_ARGS(sc, whichfork, offset, ret_ip),
268 	TP_STRUCT__entry(
269 		__field(dev_t, dev)
270 		__field(xfs_ino_t, ino)
271 		__field(int, whichfork)
272 		__field(unsigned int, type)
273 		__field(xfs_fileoff_t, offset)
274 		__field(void *, ret_ip)
275 	),
276 	TP_fast_assign(
277 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
278 		__entry->ino = sc->ip->i_ino;
279 		__entry->whichfork = whichfork;
280 		__entry->type = sc->sm->sm_type;
281 		__entry->offset = offset;
282 		__entry->ret_ip = ret_ip;
283 	),
284 	TP_printk("dev %d:%d ino 0x%llx fork %d type %s offset %llu ret_ip %pS",
285 		  MAJOR(__entry->dev), MINOR(__entry->dev),
286 		  __entry->ino,
287 		  __entry->whichfork,
288 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
289 		  __entry->offset,
290 		  __entry->ret_ip)
291 );
292 
293 #define DEFINE_SCRUB_FBLOCK_ERROR_EVENT(name) \
294 DEFINE_EVENT(xchk_fblock_error_class, name, \
295 	TP_PROTO(struct xfs_scrub *sc, int whichfork, \
296 		 xfs_fileoff_t offset, void *ret_ip), \
297 	TP_ARGS(sc, whichfork, offset, ret_ip))
298 
299 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_error);
300 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_warning);
301 
302 TRACE_EVENT(xchk_incomplete,
303 	TP_PROTO(struct xfs_scrub *sc, void *ret_ip),
304 	TP_ARGS(sc, ret_ip),
305 	TP_STRUCT__entry(
306 		__field(dev_t, dev)
307 		__field(unsigned int, type)
308 		__field(void *, ret_ip)
309 	),
310 	TP_fast_assign(
311 		__entry->dev = sc->mp->m_super->s_dev;
312 		__entry->type = sc->sm->sm_type;
313 		__entry->ret_ip = ret_ip;
314 	),
315 	TP_printk("dev %d:%d type %s ret_ip %pS",
316 		  MAJOR(__entry->dev), MINOR(__entry->dev),
317 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
318 		  __entry->ret_ip)
319 );
320 
321 TRACE_EVENT(xchk_btree_op_error,
322 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
323 		 int level, int error, void *ret_ip),
324 	TP_ARGS(sc, cur, level, error, ret_ip),
325 	TP_STRUCT__entry(
326 		__field(dev_t, dev)
327 		__field(unsigned int, type)
328 		__field(xfs_btnum_t, btnum)
329 		__field(int, level)
330 		__field(xfs_agnumber_t, agno)
331 		__field(xfs_agblock_t, bno)
332 		__field(int, ptr)
333 		__field(int, error)
334 		__field(void *, ret_ip)
335 	),
336 	TP_fast_assign(
337 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
338 
339 		__entry->dev = sc->mp->m_super->s_dev;
340 		__entry->type = sc->sm->sm_type;
341 		__entry->btnum = cur->bc_btnum;
342 		__entry->level = level;
343 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
344 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
345 		__entry->ptr = cur->bc_ptrs[level];
346 		__entry->error = error;
347 		__entry->ret_ip = ret_ip;
348 	),
349 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
350 		  MAJOR(__entry->dev), MINOR(__entry->dev),
351 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
352 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
353 		  __entry->level,
354 		  __entry->ptr,
355 		  __entry->agno,
356 		  __entry->bno,
357 		  __entry->error,
358 		  __entry->ret_ip)
359 );
360 
361 TRACE_EVENT(xchk_ifork_btree_op_error,
362 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
363 		 int level, int error, void *ret_ip),
364 	TP_ARGS(sc, cur, level, error, ret_ip),
365 	TP_STRUCT__entry(
366 		__field(dev_t, dev)
367 		__field(xfs_ino_t, ino)
368 		__field(int, whichfork)
369 		__field(unsigned int, type)
370 		__field(xfs_btnum_t, btnum)
371 		__field(int, level)
372 		__field(int, ptr)
373 		__field(xfs_agnumber_t, agno)
374 		__field(xfs_agblock_t, bno)
375 		__field(int, error)
376 		__field(void *, ret_ip)
377 	),
378 	TP_fast_assign(
379 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
380 		__entry->dev = sc->mp->m_super->s_dev;
381 		__entry->ino = sc->ip->i_ino;
382 		__entry->whichfork = cur->bc_ino.whichfork;
383 		__entry->type = sc->sm->sm_type;
384 		__entry->btnum = cur->bc_btnum;
385 		__entry->level = level;
386 		__entry->ptr = cur->bc_ptrs[level];
387 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
388 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
389 		__entry->error = error;
390 		__entry->ret_ip = ret_ip;
391 	),
392 	TP_printk("dev %d:%d ino 0x%llx fork %d type %s btree %s level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
393 		  MAJOR(__entry->dev), MINOR(__entry->dev),
394 		  __entry->ino,
395 		  __entry->whichfork,
396 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
397 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
398 		  __entry->level,
399 		  __entry->ptr,
400 		  __entry->agno,
401 		  __entry->bno,
402 		  __entry->error,
403 		  __entry->ret_ip)
404 );
405 
406 TRACE_EVENT(xchk_btree_error,
407 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
408 		 int level, void *ret_ip),
409 	TP_ARGS(sc, cur, level, ret_ip),
410 	TP_STRUCT__entry(
411 		__field(dev_t, dev)
412 		__field(unsigned int, type)
413 		__field(xfs_btnum_t, btnum)
414 		__field(int, level)
415 		__field(xfs_agnumber_t, agno)
416 		__field(xfs_agblock_t, bno)
417 		__field(int, ptr)
418 		__field(void *, ret_ip)
419 	),
420 	TP_fast_assign(
421 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
422 		__entry->dev = sc->mp->m_super->s_dev;
423 		__entry->type = sc->sm->sm_type;
424 		__entry->btnum = cur->bc_btnum;
425 		__entry->level = level;
426 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
427 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
428 		__entry->ptr = cur->bc_ptrs[level];
429 		__entry->ret_ip = ret_ip;
430 	),
431 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno %u agbno %u ret_ip %pS",
432 		  MAJOR(__entry->dev), MINOR(__entry->dev),
433 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
434 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
435 		  __entry->level,
436 		  __entry->ptr,
437 		  __entry->agno,
438 		  __entry->bno,
439 		  __entry->ret_ip)
440 );
441 
442 TRACE_EVENT(xchk_ifork_btree_error,
443 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
444 		 int level, void *ret_ip),
445 	TP_ARGS(sc, cur, level, ret_ip),
446 	TP_STRUCT__entry(
447 		__field(dev_t, dev)
448 		__field(xfs_ino_t, ino)
449 		__field(int, whichfork)
450 		__field(unsigned int, type)
451 		__field(xfs_btnum_t, btnum)
452 		__field(int, level)
453 		__field(xfs_agnumber_t, agno)
454 		__field(xfs_agblock_t, bno)
455 		__field(int, ptr)
456 		__field(void *, ret_ip)
457 	),
458 	TP_fast_assign(
459 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
460 		__entry->dev = sc->mp->m_super->s_dev;
461 		__entry->ino = sc->ip->i_ino;
462 		__entry->whichfork = cur->bc_ino.whichfork;
463 		__entry->type = sc->sm->sm_type;
464 		__entry->btnum = cur->bc_btnum;
465 		__entry->level = level;
466 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
467 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
468 		__entry->ptr = cur->bc_ptrs[level];
469 		__entry->ret_ip = ret_ip;
470 	),
471 	TP_printk("dev %d:%d ino 0x%llx fork %d type %s btree %s level %d ptr %d agno %u agbno %u ret_ip %pS",
472 		  MAJOR(__entry->dev), MINOR(__entry->dev),
473 		  __entry->ino,
474 		  __entry->whichfork,
475 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
476 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
477 		  __entry->level,
478 		  __entry->ptr,
479 		  __entry->agno,
480 		  __entry->bno,
481 		  __entry->ret_ip)
482 );
483 
484 DECLARE_EVENT_CLASS(xchk_sbtree_class,
485 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
486 		 int level),
487 	TP_ARGS(sc, cur, level),
488 	TP_STRUCT__entry(
489 		__field(dev_t, dev)
490 		__field(int, type)
491 		__field(xfs_btnum_t, btnum)
492 		__field(xfs_agnumber_t, agno)
493 		__field(xfs_agblock_t, bno)
494 		__field(int, level)
495 		__field(int, nlevels)
496 		__field(int, ptr)
497 	),
498 	TP_fast_assign(
499 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
500 
501 		__entry->dev = sc->mp->m_super->s_dev;
502 		__entry->type = sc->sm->sm_type;
503 		__entry->btnum = cur->bc_btnum;
504 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
505 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
506 		__entry->level = level;
507 		__entry->nlevels = cur->bc_nlevels;
508 		__entry->ptr = cur->bc_ptrs[level];
509 	),
510 	TP_printk("dev %d:%d type %s btree %s agno %u agbno %u level %d nlevels %d ptr %d",
511 		  MAJOR(__entry->dev), MINOR(__entry->dev),
512 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
513 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
514 		  __entry->agno,
515 		  __entry->bno,
516 		  __entry->level,
517 		  __entry->nlevels,
518 		  __entry->ptr)
519 )
520 #define DEFINE_SCRUB_SBTREE_EVENT(name) \
521 DEFINE_EVENT(xchk_sbtree_class, name, \
522 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur, \
523 		 int level), \
524 	TP_ARGS(sc, cur, level))
525 
526 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_rec);
527 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_key);
528 
529 TRACE_EVENT(xchk_xref_error,
530 	TP_PROTO(struct xfs_scrub *sc, int error, void *ret_ip),
531 	TP_ARGS(sc, error, ret_ip),
532 	TP_STRUCT__entry(
533 		__field(dev_t, dev)
534 		__field(int, type)
535 		__field(int, error)
536 		__field(void *, ret_ip)
537 	),
538 	TP_fast_assign(
539 		__entry->dev = sc->mp->m_super->s_dev;
540 		__entry->type = sc->sm->sm_type;
541 		__entry->error = error;
542 		__entry->ret_ip = ret_ip;
543 	),
544 	TP_printk("dev %d:%d type %s xref error %d ret_ip %pS",
545 		  MAJOR(__entry->dev), MINOR(__entry->dev),
546 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
547 		  __entry->error,
548 		  __entry->ret_ip)
549 );
550 
551 TRACE_EVENT(xchk_iallocbt_check_cluster,
552 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
553 		 xfs_agino_t startino, xfs_daddr_t map_daddr,
554 		 unsigned short map_len, unsigned int chunk_ino,
555 		 unsigned int nr_inodes, uint16_t cluster_mask,
556 		 uint16_t holemask, unsigned int cluster_ino),
557 	TP_ARGS(mp, agno, startino, map_daddr, map_len, chunk_ino, nr_inodes,
558 		cluster_mask, holemask, cluster_ino),
559 	TP_STRUCT__entry(
560 		__field(dev_t, dev)
561 		__field(xfs_agnumber_t, agno)
562 		__field(xfs_agino_t, startino)
563 		__field(xfs_daddr_t, map_daddr)
564 		__field(unsigned short, map_len)
565 		__field(unsigned int, chunk_ino)
566 		__field(unsigned int, nr_inodes)
567 		__field(unsigned int, cluster_ino)
568 		__field(uint16_t, cluster_mask)
569 		__field(uint16_t, holemask)
570 	),
571 	TP_fast_assign(
572 		__entry->dev = mp->m_super->s_dev;
573 		__entry->agno = agno;
574 		__entry->startino = startino;
575 		__entry->map_daddr = map_daddr;
576 		__entry->map_len = map_len;
577 		__entry->chunk_ino = chunk_ino;
578 		__entry->nr_inodes = nr_inodes;
579 		__entry->cluster_mask = cluster_mask;
580 		__entry->holemask = holemask;
581 		__entry->cluster_ino = cluster_ino;
582 	),
583 	TP_printk("dev %d:%d agno %d startino %u daddr 0x%llx len %d chunkino %u nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino %u",
584 		  MAJOR(__entry->dev), MINOR(__entry->dev),
585 		  __entry->agno,
586 		  __entry->startino,
587 		  __entry->map_daddr,
588 		  __entry->map_len,
589 		  __entry->chunk_ino,
590 		  __entry->nr_inodes,
591 		  __entry->cluster_mask,
592 		  __entry->holemask,
593 		  __entry->cluster_ino)
594 )
595 
596 TRACE_EVENT(xchk_fscounters_calc,
597 	TP_PROTO(struct xfs_mount *mp, uint64_t icount, uint64_t ifree,
598 		 uint64_t fdblocks, uint64_t delalloc),
599 	TP_ARGS(mp, icount, ifree, fdblocks, delalloc),
600 	TP_STRUCT__entry(
601 		__field(dev_t, dev)
602 		__field(int64_t, icount_sb)
603 		__field(uint64_t, icount_calculated)
604 		__field(int64_t, ifree_sb)
605 		__field(uint64_t, ifree_calculated)
606 		__field(int64_t, fdblocks_sb)
607 		__field(uint64_t, fdblocks_calculated)
608 		__field(uint64_t, delalloc)
609 	),
610 	TP_fast_assign(
611 		__entry->dev = mp->m_super->s_dev;
612 		__entry->icount_sb = mp->m_sb.sb_icount;
613 		__entry->icount_calculated = icount;
614 		__entry->ifree_sb = mp->m_sb.sb_ifree;
615 		__entry->ifree_calculated = ifree;
616 		__entry->fdblocks_sb = mp->m_sb.sb_fdblocks;
617 		__entry->fdblocks_calculated = fdblocks;
618 		__entry->delalloc = delalloc;
619 	),
620 	TP_printk("dev %d:%d icount %lld:%llu ifree %lld::%llu fdblocks %lld::%llu delalloc %llu",
621 		  MAJOR(__entry->dev), MINOR(__entry->dev),
622 		  __entry->icount_sb,
623 		  __entry->icount_calculated,
624 		  __entry->ifree_sb,
625 		  __entry->ifree_calculated,
626 		  __entry->fdblocks_sb,
627 		  __entry->fdblocks_calculated,
628 		  __entry->delalloc)
629 )
630 
631 TRACE_EVENT(xchk_fscounters_within_range,
632 	TP_PROTO(struct xfs_mount *mp, uint64_t expected, int64_t curr_value,
633 		 int64_t old_value),
634 	TP_ARGS(mp, expected, curr_value, old_value),
635 	TP_STRUCT__entry(
636 		__field(dev_t, dev)
637 		__field(uint64_t, expected)
638 		__field(int64_t, curr_value)
639 		__field(int64_t, old_value)
640 	),
641 	TP_fast_assign(
642 		__entry->dev = mp->m_super->s_dev;
643 		__entry->expected = expected;
644 		__entry->curr_value = curr_value;
645 		__entry->old_value = old_value;
646 	),
647 	TP_printk("dev %d:%d expected %llu curr_value %lld old_value %lld",
648 		  MAJOR(__entry->dev), MINOR(__entry->dev),
649 		  __entry->expected,
650 		  __entry->curr_value,
651 		  __entry->old_value)
652 )
653 
654 /* repair tracepoints */
655 #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
656 
657 DECLARE_EVENT_CLASS(xrep_extent_class,
658 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
659 		 xfs_agblock_t agbno, xfs_extlen_t len),
660 	TP_ARGS(mp, agno, agbno, len),
661 	TP_STRUCT__entry(
662 		__field(dev_t, dev)
663 		__field(xfs_agnumber_t, agno)
664 		__field(xfs_agblock_t, agbno)
665 		__field(xfs_extlen_t, len)
666 	),
667 	TP_fast_assign(
668 		__entry->dev = mp->m_super->s_dev;
669 		__entry->agno = agno;
670 		__entry->agbno = agbno;
671 		__entry->len = len;
672 	),
673 	TP_printk("dev %d:%d agno %u agbno %u len %u",
674 		  MAJOR(__entry->dev), MINOR(__entry->dev),
675 		  __entry->agno,
676 		  __entry->agbno,
677 		  __entry->len)
678 );
679 #define DEFINE_REPAIR_EXTENT_EVENT(name) \
680 DEFINE_EVENT(xrep_extent_class, name, \
681 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
682 		 xfs_agblock_t agbno, xfs_extlen_t len), \
683 	TP_ARGS(mp, agno, agbno, len))
684 DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_btree_extent);
685 DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
686 
687 DECLARE_EVENT_CLASS(xrep_rmap_class,
688 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
689 		 xfs_agblock_t agbno, xfs_extlen_t len,
690 		 uint64_t owner, uint64_t offset, unsigned int flags),
691 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
692 	TP_STRUCT__entry(
693 		__field(dev_t, dev)
694 		__field(xfs_agnumber_t, agno)
695 		__field(xfs_agblock_t, agbno)
696 		__field(xfs_extlen_t, len)
697 		__field(uint64_t, owner)
698 		__field(uint64_t, offset)
699 		__field(unsigned int, flags)
700 	),
701 	TP_fast_assign(
702 		__entry->dev = mp->m_super->s_dev;
703 		__entry->agno = agno;
704 		__entry->agbno = agbno;
705 		__entry->len = len;
706 		__entry->owner = owner;
707 		__entry->offset = offset;
708 		__entry->flags = flags;
709 	),
710 	TP_printk("dev %d:%d agno %u agbno %u len %u owner %lld offset %llu flags 0x%x",
711 		  MAJOR(__entry->dev), MINOR(__entry->dev),
712 		  __entry->agno,
713 		  __entry->agbno,
714 		  __entry->len,
715 		  __entry->owner,
716 		  __entry->offset,
717 		  __entry->flags)
718 );
719 #define DEFINE_REPAIR_RMAP_EVENT(name) \
720 DEFINE_EVENT(xrep_rmap_class, name, \
721 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
722 		 xfs_agblock_t agbno, xfs_extlen_t len, \
723 		 uint64_t owner, uint64_t offset, unsigned int flags), \
724 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
725 DEFINE_REPAIR_RMAP_EVENT(xrep_alloc_extent_fn);
726 DEFINE_REPAIR_RMAP_EVENT(xrep_ialloc_extent_fn);
727 DEFINE_REPAIR_RMAP_EVENT(xrep_rmap_extent_fn);
728 DEFINE_REPAIR_RMAP_EVENT(xrep_bmap_extent_fn);
729 
730 TRACE_EVENT(xrep_refcount_extent_fn,
731 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
732 		 struct xfs_refcount_irec *irec),
733 	TP_ARGS(mp, agno, irec),
734 	TP_STRUCT__entry(
735 		__field(dev_t, dev)
736 		__field(xfs_agnumber_t, agno)
737 		__field(xfs_agblock_t, startblock)
738 		__field(xfs_extlen_t, blockcount)
739 		__field(xfs_nlink_t, refcount)
740 	),
741 	TP_fast_assign(
742 		__entry->dev = mp->m_super->s_dev;
743 		__entry->agno = agno;
744 		__entry->startblock = irec->rc_startblock;
745 		__entry->blockcount = irec->rc_blockcount;
746 		__entry->refcount = irec->rc_refcount;
747 	),
748 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u",
749 		  MAJOR(__entry->dev), MINOR(__entry->dev),
750 		  __entry->agno,
751 		  __entry->startblock,
752 		  __entry->blockcount,
753 		  __entry->refcount)
754 )
755 
756 TRACE_EVENT(xrep_init_btblock,
757 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
758 		 xfs_btnum_t btnum),
759 	TP_ARGS(mp, agno, agbno, btnum),
760 	TP_STRUCT__entry(
761 		__field(dev_t, dev)
762 		__field(xfs_agnumber_t, agno)
763 		__field(xfs_agblock_t, agbno)
764 		__field(uint32_t, btnum)
765 	),
766 	TP_fast_assign(
767 		__entry->dev = mp->m_super->s_dev;
768 		__entry->agno = agno;
769 		__entry->agbno = agbno;
770 		__entry->btnum = btnum;
771 	),
772 	TP_printk("dev %d:%d agno %u agbno %u btree %s",
773 		  MAJOR(__entry->dev), MINOR(__entry->dev),
774 		  __entry->agno,
775 		  __entry->agbno,
776 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS))
777 )
778 TRACE_EVENT(xrep_findroot_block,
779 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
780 		 uint32_t magic, uint16_t level),
781 	TP_ARGS(mp, agno, agbno, magic, level),
782 	TP_STRUCT__entry(
783 		__field(dev_t, dev)
784 		__field(xfs_agnumber_t, agno)
785 		__field(xfs_agblock_t, agbno)
786 		__field(uint32_t, magic)
787 		__field(uint16_t, level)
788 	),
789 	TP_fast_assign(
790 		__entry->dev = mp->m_super->s_dev;
791 		__entry->agno = agno;
792 		__entry->agbno = agbno;
793 		__entry->magic = magic;
794 		__entry->level = level;
795 	),
796 	TP_printk("dev %d:%d agno %u agbno %u magic 0x%x level %u",
797 		  MAJOR(__entry->dev), MINOR(__entry->dev),
798 		  __entry->agno,
799 		  __entry->agbno,
800 		  __entry->magic,
801 		  __entry->level)
802 )
803 TRACE_EVENT(xrep_calc_ag_resblks,
804 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
805 		 xfs_agino_t icount, xfs_agblock_t aglen, xfs_agblock_t freelen,
806 		 xfs_agblock_t usedlen),
807 	TP_ARGS(mp, agno, icount, aglen, freelen, usedlen),
808 	TP_STRUCT__entry(
809 		__field(dev_t, dev)
810 		__field(xfs_agnumber_t, agno)
811 		__field(xfs_agino_t, icount)
812 		__field(xfs_agblock_t, aglen)
813 		__field(xfs_agblock_t, freelen)
814 		__field(xfs_agblock_t, usedlen)
815 	),
816 	TP_fast_assign(
817 		__entry->dev = mp->m_super->s_dev;
818 		__entry->agno = agno;
819 		__entry->icount = icount;
820 		__entry->aglen = aglen;
821 		__entry->freelen = freelen;
822 		__entry->usedlen = usedlen;
823 	),
824 	TP_printk("dev %d:%d agno %d icount %u aglen %u freelen %u usedlen %u",
825 		  MAJOR(__entry->dev), MINOR(__entry->dev),
826 		  __entry->agno,
827 		  __entry->icount,
828 		  __entry->aglen,
829 		  __entry->freelen,
830 		  __entry->usedlen)
831 )
832 TRACE_EVENT(xrep_calc_ag_resblks_btsize,
833 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
834 		 xfs_agblock_t bnobt_sz, xfs_agblock_t inobt_sz,
835 		 xfs_agblock_t rmapbt_sz, xfs_agblock_t refcbt_sz),
836 	TP_ARGS(mp, agno, bnobt_sz, inobt_sz, rmapbt_sz, refcbt_sz),
837 	TP_STRUCT__entry(
838 		__field(dev_t, dev)
839 		__field(xfs_agnumber_t, agno)
840 		__field(xfs_agblock_t, bnobt_sz)
841 		__field(xfs_agblock_t, inobt_sz)
842 		__field(xfs_agblock_t, rmapbt_sz)
843 		__field(xfs_agblock_t, refcbt_sz)
844 	),
845 	TP_fast_assign(
846 		__entry->dev = mp->m_super->s_dev;
847 		__entry->agno = agno;
848 		__entry->bnobt_sz = bnobt_sz;
849 		__entry->inobt_sz = inobt_sz;
850 		__entry->rmapbt_sz = rmapbt_sz;
851 		__entry->refcbt_sz = refcbt_sz;
852 	),
853 	TP_printk("dev %d:%d agno %d bno %u ino %u rmap %u refcount %u",
854 		  MAJOR(__entry->dev), MINOR(__entry->dev),
855 		  __entry->agno,
856 		  __entry->bnobt_sz,
857 		  __entry->inobt_sz,
858 		  __entry->rmapbt_sz,
859 		  __entry->refcbt_sz)
860 )
861 TRACE_EVENT(xrep_reset_counters,
862 	TP_PROTO(struct xfs_mount *mp),
863 	TP_ARGS(mp),
864 	TP_STRUCT__entry(
865 		__field(dev_t, dev)
866 	),
867 	TP_fast_assign(
868 		__entry->dev = mp->m_super->s_dev;
869 	),
870 	TP_printk("dev %d:%d",
871 		  MAJOR(__entry->dev), MINOR(__entry->dev))
872 )
873 
874 TRACE_EVENT(xrep_ialloc_insert,
875 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
876 		 xfs_agino_t startino, uint16_t holemask, uint8_t count,
877 		 uint8_t freecount, uint64_t freemask),
878 	TP_ARGS(mp, agno, startino, holemask, count, freecount, freemask),
879 	TP_STRUCT__entry(
880 		__field(dev_t, dev)
881 		__field(xfs_agnumber_t, agno)
882 		__field(xfs_agino_t, startino)
883 		__field(uint16_t, holemask)
884 		__field(uint8_t, count)
885 		__field(uint8_t, freecount)
886 		__field(uint64_t, freemask)
887 	),
888 	TP_fast_assign(
889 		__entry->dev = mp->m_super->s_dev;
890 		__entry->agno = agno;
891 		__entry->startino = startino;
892 		__entry->holemask = holemask;
893 		__entry->count = count;
894 		__entry->freecount = freecount;
895 		__entry->freemask = freemask;
896 	),
897 	TP_printk("dev %d:%d agno %d startino %u holemask 0x%x count %u freecount %u freemask 0x%llx",
898 		  MAJOR(__entry->dev), MINOR(__entry->dev),
899 		  __entry->agno,
900 		  __entry->startino,
901 		  __entry->holemask,
902 		  __entry->count,
903 		  __entry->freecount,
904 		  __entry->freemask)
905 )
906 
907 #endif /* IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) */
908 
909 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
910 
911 #undef TRACE_INCLUDE_PATH
912 #define TRACE_INCLUDE_PATH .
913 #define TRACE_INCLUDE_FILE scrub/trace
914 #include <trace/define_trace.h>
915