xref: /openbmc/linux/fs/xfs/scrub/trace.h (revision 5b4cb650)
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 
54 #define XFS_SCRUB_TYPE_STRINGS \
55 	{ XFS_SCRUB_TYPE_PROBE,		"probe" }, \
56 	{ XFS_SCRUB_TYPE_SB,		"sb" }, \
57 	{ XFS_SCRUB_TYPE_AGF,		"agf" }, \
58 	{ XFS_SCRUB_TYPE_AGFL,		"agfl" }, \
59 	{ XFS_SCRUB_TYPE_AGI,		"agi" }, \
60 	{ XFS_SCRUB_TYPE_BNOBT,		"bnobt" }, \
61 	{ XFS_SCRUB_TYPE_CNTBT,		"cntbt" }, \
62 	{ XFS_SCRUB_TYPE_INOBT,		"inobt" }, \
63 	{ XFS_SCRUB_TYPE_FINOBT,	"finobt" }, \
64 	{ XFS_SCRUB_TYPE_RMAPBT,	"rmapbt" }, \
65 	{ XFS_SCRUB_TYPE_REFCNTBT,	"refcountbt" }, \
66 	{ XFS_SCRUB_TYPE_INODE,		"inode" }, \
67 	{ XFS_SCRUB_TYPE_BMBTD,		"bmapbtd" }, \
68 	{ XFS_SCRUB_TYPE_BMBTA,		"bmapbta" }, \
69 	{ XFS_SCRUB_TYPE_BMBTC,		"bmapbtc" }, \
70 	{ XFS_SCRUB_TYPE_DIR,		"directory" }, \
71 	{ XFS_SCRUB_TYPE_XATTR,		"xattr" }, \
72 	{ XFS_SCRUB_TYPE_SYMLINK,	"symlink" }, \
73 	{ XFS_SCRUB_TYPE_PARENT,	"parent" }, \
74 	{ XFS_SCRUB_TYPE_RTBITMAP,	"rtbitmap" }, \
75 	{ XFS_SCRUB_TYPE_RTSUM,		"rtsummary" }, \
76 	{ XFS_SCRUB_TYPE_UQUOTA,	"usrquota" }, \
77 	{ XFS_SCRUB_TYPE_GQUOTA,	"grpquota" }, \
78 	{ XFS_SCRUB_TYPE_PQUOTA,	"prjquota" }
79 
80 DECLARE_EVENT_CLASS(xchk_class,
81 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm,
82 		 int error),
83 	TP_ARGS(ip, sm, error),
84 	TP_STRUCT__entry(
85 		__field(dev_t, dev)
86 		__field(xfs_ino_t, ino)
87 		__field(unsigned int, type)
88 		__field(xfs_agnumber_t, agno)
89 		__field(xfs_ino_t, inum)
90 		__field(unsigned int, gen)
91 		__field(unsigned int, flags)
92 		__field(int, error)
93 	),
94 	TP_fast_assign(
95 		__entry->dev = ip->i_mount->m_super->s_dev;
96 		__entry->ino = ip->i_ino;
97 		__entry->type = sm->sm_type;
98 		__entry->agno = sm->sm_agno;
99 		__entry->inum = sm->sm_ino;
100 		__entry->gen = sm->sm_gen;
101 		__entry->flags = sm->sm_flags;
102 		__entry->error = error;
103 	),
104 	TP_printk("dev %d:%d ino 0x%llx type %s agno %u inum %llu gen %u flags 0x%x error %d",
105 		  MAJOR(__entry->dev), MINOR(__entry->dev),
106 		  __entry->ino,
107 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
108 		  __entry->agno,
109 		  __entry->inum,
110 		  __entry->gen,
111 		  __entry->flags,
112 		  __entry->error)
113 )
114 #define DEFINE_SCRUB_EVENT(name) \
115 DEFINE_EVENT(xchk_class, name, \
116 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, \
117 		 int error), \
118 	TP_ARGS(ip, sm, error))
119 
120 DEFINE_SCRUB_EVENT(xchk_start);
121 DEFINE_SCRUB_EVENT(xchk_done);
122 DEFINE_SCRUB_EVENT(xchk_deadlock_retry);
123 DEFINE_SCRUB_EVENT(xrep_attempt);
124 DEFINE_SCRUB_EVENT(xrep_done);
125 
126 TRACE_EVENT(xchk_op_error,
127 	TP_PROTO(struct xfs_scrub *sc, xfs_agnumber_t agno,
128 		 xfs_agblock_t bno, int error, void *ret_ip),
129 	TP_ARGS(sc, agno, bno, error, ret_ip),
130 	TP_STRUCT__entry(
131 		__field(dev_t, dev)
132 		__field(unsigned int, type)
133 		__field(xfs_agnumber_t, agno)
134 		__field(xfs_agblock_t, bno)
135 		__field(int, error)
136 		__field(void *, ret_ip)
137 	),
138 	TP_fast_assign(
139 		__entry->dev = sc->mp->m_super->s_dev;
140 		__entry->type = sc->sm->sm_type;
141 		__entry->agno = agno;
142 		__entry->bno = bno;
143 		__entry->error = error;
144 		__entry->ret_ip = ret_ip;
145 	),
146 	TP_printk("dev %d:%d type %s agno %u agbno %u error %d ret_ip %pS",
147 		  MAJOR(__entry->dev), MINOR(__entry->dev),
148 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
149 		  __entry->agno,
150 		  __entry->bno,
151 		  __entry->error,
152 		  __entry->ret_ip)
153 );
154 
155 TRACE_EVENT(xchk_file_op_error,
156 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
157 		 xfs_fileoff_t offset, int error, void *ret_ip),
158 	TP_ARGS(sc, whichfork, offset, error, ret_ip),
159 	TP_STRUCT__entry(
160 		__field(dev_t, dev)
161 		__field(xfs_ino_t, ino)
162 		__field(int, whichfork)
163 		__field(unsigned int, type)
164 		__field(xfs_fileoff_t, offset)
165 		__field(int, error)
166 		__field(void *, ret_ip)
167 	),
168 	TP_fast_assign(
169 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
170 		__entry->ino = sc->ip->i_ino;
171 		__entry->whichfork = whichfork;
172 		__entry->type = sc->sm->sm_type;
173 		__entry->offset = offset;
174 		__entry->error = error;
175 		__entry->ret_ip = ret_ip;
176 	),
177 	TP_printk("dev %d:%d ino 0x%llx fork %d type %s offset %llu error %d ret_ip %pS",
178 		  MAJOR(__entry->dev), MINOR(__entry->dev),
179 		  __entry->ino,
180 		  __entry->whichfork,
181 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
182 		  __entry->offset,
183 		  __entry->error,
184 		  __entry->ret_ip)
185 );
186 
187 DECLARE_EVENT_CLASS(xchk_block_error_class,
188 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, void *ret_ip),
189 	TP_ARGS(sc, daddr, 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(void *, ret_ip)
196 	),
197 	TP_fast_assign(
198 		xfs_fsblock_t	fsbno;
199 		xfs_agnumber_t	agno;
200 		xfs_agblock_t	bno;
201 
202 		fsbno = XFS_DADDR_TO_FSB(sc->mp, daddr);
203 		agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
204 		bno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
205 
206 		__entry->dev = sc->mp->m_super->s_dev;
207 		__entry->type = sc->sm->sm_type;
208 		__entry->agno = agno;
209 		__entry->bno = bno;
210 		__entry->ret_ip = ret_ip;
211 	),
212 	TP_printk("dev %d:%d type %s agno %u agbno %u ret_ip %pS",
213 		  MAJOR(__entry->dev), MINOR(__entry->dev),
214 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
215 		  __entry->agno,
216 		  __entry->bno,
217 		  __entry->ret_ip)
218 )
219 
220 #define DEFINE_SCRUB_BLOCK_ERROR_EVENT(name) \
221 DEFINE_EVENT(xchk_block_error_class, name, \
222 	TP_PROTO(struct xfs_scrub *sc, xfs_daddr_t daddr, \
223 		 void *ret_ip), \
224 	TP_ARGS(sc, daddr, ret_ip))
225 
226 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_error);
227 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xchk_block_preen);
228 
229 DECLARE_EVENT_CLASS(xchk_ino_error_class,
230 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, void *ret_ip),
231 	TP_ARGS(sc, ino, ret_ip),
232 	TP_STRUCT__entry(
233 		__field(dev_t, dev)
234 		__field(xfs_ino_t, ino)
235 		__field(unsigned int, type)
236 		__field(void *, ret_ip)
237 	),
238 	TP_fast_assign(
239 		__entry->dev = sc->mp->m_super->s_dev;
240 		__entry->ino = ino;
241 		__entry->type = sc->sm->sm_type;
242 		__entry->ret_ip = ret_ip;
243 	),
244 	TP_printk("dev %d:%d ino 0x%llx type %s ret_ip %pS",
245 		  MAJOR(__entry->dev), MINOR(__entry->dev),
246 		  __entry->ino,
247 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
248 		  __entry->ret_ip)
249 )
250 
251 #define DEFINE_SCRUB_INO_ERROR_EVENT(name) \
252 DEFINE_EVENT(xchk_ino_error_class, name, \
253 	TP_PROTO(struct xfs_scrub *sc, xfs_ino_t ino, \
254 		 void *ret_ip), \
255 	TP_ARGS(sc, ino, ret_ip))
256 
257 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_error);
258 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_preen);
259 DEFINE_SCRUB_INO_ERROR_EVENT(xchk_ino_warning);
260 
261 DECLARE_EVENT_CLASS(xchk_fblock_error_class,
262 	TP_PROTO(struct xfs_scrub *sc, int whichfork,
263 		 xfs_fileoff_t offset, void *ret_ip),
264 	TP_ARGS(sc, whichfork, offset, ret_ip),
265 	TP_STRUCT__entry(
266 		__field(dev_t, dev)
267 		__field(xfs_ino_t, ino)
268 		__field(int, whichfork)
269 		__field(unsigned int, type)
270 		__field(xfs_fileoff_t, offset)
271 		__field(void *, ret_ip)
272 	),
273 	TP_fast_assign(
274 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
275 		__entry->ino = sc->ip->i_ino;
276 		__entry->whichfork = whichfork;
277 		__entry->type = sc->sm->sm_type;
278 		__entry->offset = offset;
279 		__entry->ret_ip = ret_ip;
280 	),
281 	TP_printk("dev %d:%d ino 0x%llx fork %d type %s offset %llu ret_ip %pS",
282 		  MAJOR(__entry->dev), MINOR(__entry->dev),
283 		  __entry->ino,
284 		  __entry->whichfork,
285 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
286 		  __entry->offset,
287 		  __entry->ret_ip)
288 );
289 
290 #define DEFINE_SCRUB_FBLOCK_ERROR_EVENT(name) \
291 DEFINE_EVENT(xchk_fblock_error_class, name, \
292 	TP_PROTO(struct xfs_scrub *sc, int whichfork, \
293 		 xfs_fileoff_t offset, void *ret_ip), \
294 	TP_ARGS(sc, whichfork, offset, ret_ip))
295 
296 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_error);
297 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_warning);
298 
299 TRACE_EVENT(xchk_incomplete,
300 	TP_PROTO(struct xfs_scrub *sc, void *ret_ip),
301 	TP_ARGS(sc, ret_ip),
302 	TP_STRUCT__entry(
303 		__field(dev_t, dev)
304 		__field(unsigned int, type)
305 		__field(void *, ret_ip)
306 	),
307 	TP_fast_assign(
308 		__entry->dev = sc->mp->m_super->s_dev;
309 		__entry->type = sc->sm->sm_type;
310 		__entry->ret_ip = ret_ip;
311 	),
312 	TP_printk("dev %d:%d type %s ret_ip %pS",
313 		  MAJOR(__entry->dev), MINOR(__entry->dev),
314 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
315 		  __entry->ret_ip)
316 );
317 
318 TRACE_EVENT(xchk_btree_op_error,
319 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
320 		 int level, int error, void *ret_ip),
321 	TP_ARGS(sc, cur, level, error, ret_ip),
322 	TP_STRUCT__entry(
323 		__field(dev_t, dev)
324 		__field(unsigned int, type)
325 		__field(xfs_btnum_t, btnum)
326 		__field(int, level)
327 		__field(xfs_agnumber_t, agno)
328 		__field(xfs_agblock_t, bno)
329 		__field(int, ptr);
330 		__field(int, error)
331 		__field(void *, ret_ip)
332 	),
333 	TP_fast_assign(
334 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
335 
336 		__entry->dev = sc->mp->m_super->s_dev;
337 		__entry->type = sc->sm->sm_type;
338 		__entry->btnum = cur->bc_btnum;
339 		__entry->level = level;
340 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
341 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
342 		__entry->ptr = cur->bc_ptrs[level];
343 		__entry->error = error;
344 		__entry->ret_ip = ret_ip;
345 	),
346 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
347 		  MAJOR(__entry->dev), MINOR(__entry->dev),
348 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
349 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
350 		  __entry->level,
351 		  __entry->ptr,
352 		  __entry->agno,
353 		  __entry->bno,
354 		  __entry->error,
355 		  __entry->ret_ip)
356 );
357 
358 TRACE_EVENT(xchk_ifork_btree_op_error,
359 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
360 		 int level, int error, void *ret_ip),
361 	TP_ARGS(sc, cur, level, error, ret_ip),
362 	TP_STRUCT__entry(
363 		__field(dev_t, dev)
364 		__field(xfs_ino_t, ino)
365 		__field(int, whichfork)
366 		__field(unsigned int, type)
367 		__field(xfs_btnum_t, btnum)
368 		__field(int, level)
369 		__field(int, ptr)
370 		__field(xfs_agnumber_t, agno)
371 		__field(xfs_agblock_t, bno)
372 		__field(int, error)
373 		__field(void *, ret_ip)
374 	),
375 	TP_fast_assign(
376 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
377 		__entry->dev = sc->mp->m_super->s_dev;
378 		__entry->ino = sc->ip->i_ino;
379 		__entry->whichfork = cur->bc_private.b.whichfork;
380 		__entry->type = sc->sm->sm_type;
381 		__entry->btnum = cur->bc_btnum;
382 		__entry->level = level;
383 		__entry->ptr = cur->bc_ptrs[level];
384 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
385 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
386 		__entry->error = error;
387 		__entry->ret_ip = ret_ip;
388 	),
389 	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",
390 		  MAJOR(__entry->dev), MINOR(__entry->dev),
391 		  __entry->ino,
392 		  __entry->whichfork,
393 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
394 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
395 		  __entry->level,
396 		  __entry->ptr,
397 		  __entry->agno,
398 		  __entry->bno,
399 		  __entry->error,
400 		  __entry->ret_ip)
401 );
402 
403 TRACE_EVENT(xchk_btree_error,
404 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
405 		 int level, void *ret_ip),
406 	TP_ARGS(sc, cur, level, ret_ip),
407 	TP_STRUCT__entry(
408 		__field(dev_t, dev)
409 		__field(unsigned int, type)
410 		__field(xfs_btnum_t, btnum)
411 		__field(int, level)
412 		__field(xfs_agnumber_t, agno)
413 		__field(xfs_agblock_t, bno)
414 		__field(int, ptr);
415 		__field(void *, ret_ip)
416 	),
417 	TP_fast_assign(
418 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
419 		__entry->dev = sc->mp->m_super->s_dev;
420 		__entry->type = sc->sm->sm_type;
421 		__entry->btnum = cur->bc_btnum;
422 		__entry->level = level;
423 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
424 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
425 		__entry->ptr = cur->bc_ptrs[level];
426 		__entry->ret_ip = ret_ip;
427 	),
428 	TP_printk("dev %d:%d type %s btree %s level %d ptr %d agno %u agbno %u ret_ip %pS",
429 		  MAJOR(__entry->dev), MINOR(__entry->dev),
430 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
431 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
432 		  __entry->level,
433 		  __entry->ptr,
434 		  __entry->agno,
435 		  __entry->bno,
436 		  __entry->ret_ip)
437 );
438 
439 TRACE_EVENT(xchk_ifork_btree_error,
440 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
441 		 int level, void *ret_ip),
442 	TP_ARGS(sc, cur, level, ret_ip),
443 	TP_STRUCT__entry(
444 		__field(dev_t, dev)
445 		__field(xfs_ino_t, ino)
446 		__field(int, whichfork)
447 		__field(unsigned int, type)
448 		__field(xfs_btnum_t, btnum)
449 		__field(int, level)
450 		__field(xfs_agnumber_t, agno)
451 		__field(xfs_agblock_t, bno)
452 		__field(int, ptr);
453 		__field(void *, ret_ip)
454 	),
455 	TP_fast_assign(
456 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
457 		__entry->dev = sc->mp->m_super->s_dev;
458 		__entry->ino = sc->ip->i_ino;
459 		__entry->whichfork = cur->bc_private.b.whichfork;
460 		__entry->type = sc->sm->sm_type;
461 		__entry->btnum = cur->bc_btnum;
462 		__entry->level = level;
463 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
464 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
465 		__entry->ptr = cur->bc_ptrs[level];
466 		__entry->ret_ip = ret_ip;
467 	),
468 	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",
469 		  MAJOR(__entry->dev), MINOR(__entry->dev),
470 		  __entry->ino,
471 		  __entry->whichfork,
472 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
473 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
474 		  __entry->level,
475 		  __entry->ptr,
476 		  __entry->agno,
477 		  __entry->bno,
478 		  __entry->ret_ip)
479 );
480 
481 DECLARE_EVENT_CLASS(xchk_sbtree_class,
482 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
483 		 int level),
484 	TP_ARGS(sc, cur, level),
485 	TP_STRUCT__entry(
486 		__field(dev_t, dev)
487 		__field(int, type)
488 		__field(xfs_btnum_t, btnum)
489 		__field(xfs_agnumber_t, agno)
490 		__field(xfs_agblock_t, bno)
491 		__field(int, level)
492 		__field(int, nlevels)
493 		__field(int, ptr)
494 	),
495 	TP_fast_assign(
496 		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
497 
498 		__entry->dev = sc->mp->m_super->s_dev;
499 		__entry->type = sc->sm->sm_type;
500 		__entry->btnum = cur->bc_btnum;
501 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
502 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
503 		__entry->level = level;
504 		__entry->nlevels = cur->bc_nlevels;
505 		__entry->ptr = cur->bc_ptrs[level];
506 	),
507 	TP_printk("dev %d:%d type %s btree %s agno %u agbno %u level %d nlevels %d ptr %d",
508 		  MAJOR(__entry->dev), MINOR(__entry->dev),
509 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
510 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
511 		  __entry->agno,
512 		  __entry->bno,
513 		  __entry->level,
514 		  __entry->nlevels,
515 		  __entry->ptr)
516 )
517 #define DEFINE_SCRUB_SBTREE_EVENT(name) \
518 DEFINE_EVENT(xchk_sbtree_class, name, \
519 	TP_PROTO(struct xfs_scrub *sc, struct xfs_btree_cur *cur, \
520 		 int level), \
521 	TP_ARGS(sc, cur, level))
522 
523 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_rec);
524 DEFINE_SCRUB_SBTREE_EVENT(xchk_btree_key);
525 
526 TRACE_EVENT(xchk_xref_error,
527 	TP_PROTO(struct xfs_scrub *sc, int error, void *ret_ip),
528 	TP_ARGS(sc, error, ret_ip),
529 	TP_STRUCT__entry(
530 		__field(dev_t, dev)
531 		__field(int, type)
532 		__field(int, error)
533 		__field(void *, ret_ip)
534 	),
535 	TP_fast_assign(
536 		__entry->dev = sc->mp->m_super->s_dev;
537 		__entry->type = sc->sm->sm_type;
538 		__entry->error = error;
539 		__entry->ret_ip = ret_ip;
540 	),
541 	TP_printk("dev %d:%d type %s xref error %d ret_ip %pS",
542 		  MAJOR(__entry->dev), MINOR(__entry->dev),
543 		  __print_symbolic(__entry->type, XFS_SCRUB_TYPE_STRINGS),
544 		  __entry->error,
545 		  __entry->ret_ip)
546 );
547 
548 /* repair tracepoints */
549 #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
550 
551 DECLARE_EVENT_CLASS(xrep_extent_class,
552 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
553 		 xfs_agblock_t agbno, xfs_extlen_t len),
554 	TP_ARGS(mp, agno, agbno, len),
555 	TP_STRUCT__entry(
556 		__field(dev_t, dev)
557 		__field(xfs_agnumber_t, agno)
558 		__field(xfs_agblock_t, agbno)
559 		__field(xfs_extlen_t, len)
560 	),
561 	TP_fast_assign(
562 		__entry->dev = mp->m_super->s_dev;
563 		__entry->agno = agno;
564 		__entry->agbno = agbno;
565 		__entry->len = len;
566 	),
567 	TP_printk("dev %d:%d agno %u agbno %u len %u",
568 		  MAJOR(__entry->dev), MINOR(__entry->dev),
569 		  __entry->agno,
570 		  __entry->agbno,
571 		  __entry->len)
572 );
573 #define DEFINE_REPAIR_EXTENT_EVENT(name) \
574 DEFINE_EVENT(xrep_extent_class, name, \
575 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
576 		 xfs_agblock_t agbno, xfs_extlen_t len), \
577 	TP_ARGS(mp, agno, agbno, len))
578 DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_btree_extent);
579 DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
580 
581 DECLARE_EVENT_CLASS(xrep_rmap_class,
582 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
583 		 xfs_agblock_t agbno, xfs_extlen_t len,
584 		 uint64_t owner, uint64_t offset, unsigned int flags),
585 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
586 	TP_STRUCT__entry(
587 		__field(dev_t, dev)
588 		__field(xfs_agnumber_t, agno)
589 		__field(xfs_agblock_t, agbno)
590 		__field(xfs_extlen_t, len)
591 		__field(uint64_t, owner)
592 		__field(uint64_t, offset)
593 		__field(unsigned int, flags)
594 	),
595 	TP_fast_assign(
596 		__entry->dev = mp->m_super->s_dev;
597 		__entry->agno = agno;
598 		__entry->agbno = agbno;
599 		__entry->len = len;
600 		__entry->owner = owner;
601 		__entry->offset = offset;
602 		__entry->flags = flags;
603 	),
604 	TP_printk("dev %d:%d agno %u agbno %u len %u owner %lld offset %llu flags 0x%x",
605 		  MAJOR(__entry->dev), MINOR(__entry->dev),
606 		  __entry->agno,
607 		  __entry->agbno,
608 		  __entry->len,
609 		  __entry->owner,
610 		  __entry->offset,
611 		  __entry->flags)
612 );
613 #define DEFINE_REPAIR_RMAP_EVENT(name) \
614 DEFINE_EVENT(xrep_rmap_class, name, \
615 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
616 		 xfs_agblock_t agbno, xfs_extlen_t len, \
617 		 uint64_t owner, uint64_t offset, unsigned int flags), \
618 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
619 DEFINE_REPAIR_RMAP_EVENT(xrep_alloc_extent_fn);
620 DEFINE_REPAIR_RMAP_EVENT(xrep_ialloc_extent_fn);
621 DEFINE_REPAIR_RMAP_EVENT(xrep_rmap_extent_fn);
622 DEFINE_REPAIR_RMAP_EVENT(xrep_bmap_extent_fn);
623 
624 TRACE_EVENT(xrep_refcount_extent_fn,
625 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
626 		 struct xfs_refcount_irec *irec),
627 	TP_ARGS(mp, agno, irec),
628 	TP_STRUCT__entry(
629 		__field(dev_t, dev)
630 		__field(xfs_agnumber_t, agno)
631 		__field(xfs_agblock_t, startblock)
632 		__field(xfs_extlen_t, blockcount)
633 		__field(xfs_nlink_t, refcount)
634 	),
635 	TP_fast_assign(
636 		__entry->dev = mp->m_super->s_dev;
637 		__entry->agno = agno;
638 		__entry->startblock = irec->rc_startblock;
639 		__entry->blockcount = irec->rc_blockcount;
640 		__entry->refcount = irec->rc_refcount;
641 	),
642 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u",
643 		  MAJOR(__entry->dev), MINOR(__entry->dev),
644 		  __entry->agno,
645 		  __entry->startblock,
646 		  __entry->blockcount,
647 		  __entry->refcount)
648 )
649 
650 TRACE_EVENT(xrep_init_btblock,
651 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
652 		 xfs_btnum_t btnum),
653 	TP_ARGS(mp, agno, agbno, btnum),
654 	TP_STRUCT__entry(
655 		__field(dev_t, dev)
656 		__field(xfs_agnumber_t, agno)
657 		__field(xfs_agblock_t, agbno)
658 		__field(uint32_t, btnum)
659 	),
660 	TP_fast_assign(
661 		__entry->dev = mp->m_super->s_dev;
662 		__entry->agno = agno;
663 		__entry->agbno = agbno;
664 		__entry->btnum = btnum;
665 	),
666 	TP_printk("dev %d:%d agno %u agbno %u btree %s",
667 		  MAJOR(__entry->dev), MINOR(__entry->dev),
668 		  __entry->agno,
669 		  __entry->agbno,
670 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS))
671 )
672 TRACE_EVENT(xrep_findroot_block,
673 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
674 		 uint32_t magic, uint16_t level),
675 	TP_ARGS(mp, agno, agbno, magic, level),
676 	TP_STRUCT__entry(
677 		__field(dev_t, dev)
678 		__field(xfs_agnumber_t, agno)
679 		__field(xfs_agblock_t, agbno)
680 		__field(uint32_t, magic)
681 		__field(uint16_t, level)
682 	),
683 	TP_fast_assign(
684 		__entry->dev = mp->m_super->s_dev;
685 		__entry->agno = agno;
686 		__entry->agbno = agbno;
687 		__entry->magic = magic;
688 		__entry->level = level;
689 	),
690 	TP_printk("dev %d:%d agno %u agbno %u magic 0x%x level %u",
691 		  MAJOR(__entry->dev), MINOR(__entry->dev),
692 		  __entry->agno,
693 		  __entry->agbno,
694 		  __entry->magic,
695 		  __entry->level)
696 )
697 TRACE_EVENT(xrep_calc_ag_resblks,
698 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
699 		 xfs_agino_t icount, xfs_agblock_t aglen, xfs_agblock_t freelen,
700 		 xfs_agblock_t usedlen),
701 	TP_ARGS(mp, agno, icount, aglen, freelen, usedlen),
702 	TP_STRUCT__entry(
703 		__field(dev_t, dev)
704 		__field(xfs_agnumber_t, agno)
705 		__field(xfs_agino_t, icount)
706 		__field(xfs_agblock_t, aglen)
707 		__field(xfs_agblock_t, freelen)
708 		__field(xfs_agblock_t, usedlen)
709 	),
710 	TP_fast_assign(
711 		__entry->dev = mp->m_super->s_dev;
712 		__entry->agno = agno;
713 		__entry->icount = icount;
714 		__entry->aglen = aglen;
715 		__entry->freelen = freelen;
716 		__entry->usedlen = usedlen;
717 	),
718 	TP_printk("dev %d:%d agno %d icount %u aglen %u freelen %u usedlen %u",
719 		  MAJOR(__entry->dev), MINOR(__entry->dev),
720 		  __entry->agno,
721 		  __entry->icount,
722 		  __entry->aglen,
723 		  __entry->freelen,
724 		  __entry->usedlen)
725 )
726 TRACE_EVENT(xrep_calc_ag_resblks_btsize,
727 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
728 		 xfs_agblock_t bnobt_sz, xfs_agblock_t inobt_sz,
729 		 xfs_agblock_t rmapbt_sz, xfs_agblock_t refcbt_sz),
730 	TP_ARGS(mp, agno, bnobt_sz, inobt_sz, rmapbt_sz, refcbt_sz),
731 	TP_STRUCT__entry(
732 		__field(dev_t, dev)
733 		__field(xfs_agnumber_t, agno)
734 		__field(xfs_agblock_t, bnobt_sz)
735 		__field(xfs_agblock_t, inobt_sz)
736 		__field(xfs_agblock_t, rmapbt_sz)
737 		__field(xfs_agblock_t, refcbt_sz)
738 	),
739 	TP_fast_assign(
740 		__entry->dev = mp->m_super->s_dev;
741 		__entry->agno = agno;
742 		__entry->bnobt_sz = bnobt_sz;
743 		__entry->inobt_sz = inobt_sz;
744 		__entry->rmapbt_sz = rmapbt_sz;
745 		__entry->refcbt_sz = refcbt_sz;
746 	),
747 	TP_printk("dev %d:%d agno %d bno %u ino %u rmap %u refcount %u",
748 		  MAJOR(__entry->dev), MINOR(__entry->dev),
749 		  __entry->agno,
750 		  __entry->bnobt_sz,
751 		  __entry->inobt_sz,
752 		  __entry->rmapbt_sz,
753 		  __entry->refcbt_sz)
754 )
755 TRACE_EVENT(xrep_reset_counters,
756 	TP_PROTO(struct xfs_mount *mp),
757 	TP_ARGS(mp),
758 	TP_STRUCT__entry(
759 		__field(dev_t, dev)
760 	),
761 	TP_fast_assign(
762 		__entry->dev = mp->m_super->s_dev;
763 	),
764 	TP_printk("dev %d:%d",
765 		  MAJOR(__entry->dev), MINOR(__entry->dev))
766 )
767 
768 TRACE_EVENT(xrep_ialloc_insert,
769 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
770 		 xfs_agino_t startino, uint16_t holemask, uint8_t count,
771 		 uint8_t freecount, uint64_t freemask),
772 	TP_ARGS(mp, agno, startino, holemask, count, freecount, freemask),
773 	TP_STRUCT__entry(
774 		__field(dev_t, dev)
775 		__field(xfs_agnumber_t, agno)
776 		__field(xfs_agino_t, startino)
777 		__field(uint16_t, holemask)
778 		__field(uint8_t, count)
779 		__field(uint8_t, freecount)
780 		__field(uint64_t, freemask)
781 	),
782 	TP_fast_assign(
783 		__entry->dev = mp->m_super->s_dev;
784 		__entry->agno = agno;
785 		__entry->startino = startino;
786 		__entry->holemask = holemask;
787 		__entry->count = count;
788 		__entry->freecount = freecount;
789 		__entry->freemask = freemask;
790 	),
791 	TP_printk("dev %d:%d agno %d startino %u holemask 0x%x count %u freecount %u freemask 0x%llx",
792 		  MAJOR(__entry->dev), MINOR(__entry->dev),
793 		  __entry->agno,
794 		  __entry->startino,
795 		  __entry->holemask,
796 		  __entry->count,
797 		  __entry->freecount,
798 		  __entry->freemask)
799 )
800 
801 #endif /* IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) */
802 
803 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
804 
805 #undef TRACE_INCLUDE_PATH
806 #define TRACE_INCLUDE_PATH .
807 #define TRACE_INCLUDE_FILE scrub/trace
808 #include <trace/define_trace.h>
809