xref: /openbmc/linux/fs/xfs/scrub/trace.h (revision dd5b2498)
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 TRACE_EVENT(xchk_iallocbt_check_cluster,
549 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
550 		 xfs_agino_t startino, xfs_daddr_t map_daddr,
551 		 unsigned short map_len, unsigned int chunk_ino,
552 		 unsigned int nr_inodes, uint16_t cluster_mask,
553 		 uint16_t holemask, unsigned int cluster_ino),
554 	TP_ARGS(mp, agno, startino, map_daddr, map_len, chunk_ino, nr_inodes,
555 		cluster_mask, holemask, cluster_ino),
556 	TP_STRUCT__entry(
557 		__field(dev_t, dev)
558 		__field(xfs_agnumber_t, agno)
559 		__field(xfs_agino_t, startino)
560 		__field(xfs_daddr_t, map_daddr)
561 		__field(unsigned short, map_len)
562 		__field(unsigned int, chunk_ino)
563 		__field(unsigned int, nr_inodes)
564 		__field(unsigned int, cluster_ino)
565 		__field(uint16_t, cluster_mask)
566 		__field(uint16_t, holemask)
567 	),
568 	TP_fast_assign(
569 		__entry->dev = mp->m_super->s_dev;
570 		__entry->agno = agno;
571 		__entry->startino = startino;
572 		__entry->map_daddr = map_daddr;
573 		__entry->map_len = map_len;
574 		__entry->chunk_ino = chunk_ino;
575 		__entry->nr_inodes = nr_inodes;
576 		__entry->cluster_mask = cluster_mask;
577 		__entry->holemask = holemask;
578 		__entry->cluster_ino = cluster_ino;
579 	),
580 	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",
581 		  MAJOR(__entry->dev), MINOR(__entry->dev),
582 		  __entry->agno,
583 		  __entry->startino,
584 		  __entry->map_daddr,
585 		  __entry->map_len,
586 		  __entry->chunk_ino,
587 		  __entry->nr_inodes,
588 		  __entry->cluster_mask,
589 		  __entry->holemask,
590 		  __entry->cluster_ino)
591 )
592 
593 /* repair tracepoints */
594 #if IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)
595 
596 DECLARE_EVENT_CLASS(xrep_extent_class,
597 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
598 		 xfs_agblock_t agbno, xfs_extlen_t len),
599 	TP_ARGS(mp, agno, agbno, len),
600 	TP_STRUCT__entry(
601 		__field(dev_t, dev)
602 		__field(xfs_agnumber_t, agno)
603 		__field(xfs_agblock_t, agbno)
604 		__field(xfs_extlen_t, len)
605 	),
606 	TP_fast_assign(
607 		__entry->dev = mp->m_super->s_dev;
608 		__entry->agno = agno;
609 		__entry->agbno = agbno;
610 		__entry->len = len;
611 	),
612 	TP_printk("dev %d:%d agno %u agbno %u len %u",
613 		  MAJOR(__entry->dev), MINOR(__entry->dev),
614 		  __entry->agno,
615 		  __entry->agbno,
616 		  __entry->len)
617 );
618 #define DEFINE_REPAIR_EXTENT_EVENT(name) \
619 DEFINE_EVENT(xrep_extent_class, name, \
620 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
621 		 xfs_agblock_t agbno, xfs_extlen_t len), \
622 	TP_ARGS(mp, agno, agbno, len))
623 DEFINE_REPAIR_EXTENT_EVENT(xrep_dispose_btree_extent);
624 DEFINE_REPAIR_EXTENT_EVENT(xrep_agfl_insert);
625 
626 DECLARE_EVENT_CLASS(xrep_rmap_class,
627 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
628 		 xfs_agblock_t agbno, xfs_extlen_t len,
629 		 uint64_t owner, uint64_t offset, unsigned int flags),
630 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
631 	TP_STRUCT__entry(
632 		__field(dev_t, dev)
633 		__field(xfs_agnumber_t, agno)
634 		__field(xfs_agblock_t, agbno)
635 		__field(xfs_extlen_t, len)
636 		__field(uint64_t, owner)
637 		__field(uint64_t, offset)
638 		__field(unsigned int, flags)
639 	),
640 	TP_fast_assign(
641 		__entry->dev = mp->m_super->s_dev;
642 		__entry->agno = agno;
643 		__entry->agbno = agbno;
644 		__entry->len = len;
645 		__entry->owner = owner;
646 		__entry->offset = offset;
647 		__entry->flags = flags;
648 	),
649 	TP_printk("dev %d:%d agno %u agbno %u len %u owner %lld offset %llu flags 0x%x",
650 		  MAJOR(__entry->dev), MINOR(__entry->dev),
651 		  __entry->agno,
652 		  __entry->agbno,
653 		  __entry->len,
654 		  __entry->owner,
655 		  __entry->offset,
656 		  __entry->flags)
657 );
658 #define DEFINE_REPAIR_RMAP_EVENT(name) \
659 DEFINE_EVENT(xrep_rmap_class, name, \
660 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
661 		 xfs_agblock_t agbno, xfs_extlen_t len, \
662 		 uint64_t owner, uint64_t offset, unsigned int flags), \
663 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
664 DEFINE_REPAIR_RMAP_EVENT(xrep_alloc_extent_fn);
665 DEFINE_REPAIR_RMAP_EVENT(xrep_ialloc_extent_fn);
666 DEFINE_REPAIR_RMAP_EVENT(xrep_rmap_extent_fn);
667 DEFINE_REPAIR_RMAP_EVENT(xrep_bmap_extent_fn);
668 
669 TRACE_EVENT(xrep_refcount_extent_fn,
670 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
671 		 struct xfs_refcount_irec *irec),
672 	TP_ARGS(mp, agno, irec),
673 	TP_STRUCT__entry(
674 		__field(dev_t, dev)
675 		__field(xfs_agnumber_t, agno)
676 		__field(xfs_agblock_t, startblock)
677 		__field(xfs_extlen_t, blockcount)
678 		__field(xfs_nlink_t, refcount)
679 	),
680 	TP_fast_assign(
681 		__entry->dev = mp->m_super->s_dev;
682 		__entry->agno = agno;
683 		__entry->startblock = irec->rc_startblock;
684 		__entry->blockcount = irec->rc_blockcount;
685 		__entry->refcount = irec->rc_refcount;
686 	),
687 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u",
688 		  MAJOR(__entry->dev), MINOR(__entry->dev),
689 		  __entry->agno,
690 		  __entry->startblock,
691 		  __entry->blockcount,
692 		  __entry->refcount)
693 )
694 
695 TRACE_EVENT(xrep_init_btblock,
696 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
697 		 xfs_btnum_t btnum),
698 	TP_ARGS(mp, agno, agbno, btnum),
699 	TP_STRUCT__entry(
700 		__field(dev_t, dev)
701 		__field(xfs_agnumber_t, agno)
702 		__field(xfs_agblock_t, agbno)
703 		__field(uint32_t, btnum)
704 	),
705 	TP_fast_assign(
706 		__entry->dev = mp->m_super->s_dev;
707 		__entry->agno = agno;
708 		__entry->agbno = agbno;
709 		__entry->btnum = btnum;
710 	),
711 	TP_printk("dev %d:%d agno %u agbno %u btree %s",
712 		  MAJOR(__entry->dev), MINOR(__entry->dev),
713 		  __entry->agno,
714 		  __entry->agbno,
715 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS))
716 )
717 TRACE_EVENT(xrep_findroot_block,
718 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
719 		 uint32_t magic, uint16_t level),
720 	TP_ARGS(mp, agno, agbno, magic, level),
721 	TP_STRUCT__entry(
722 		__field(dev_t, dev)
723 		__field(xfs_agnumber_t, agno)
724 		__field(xfs_agblock_t, agbno)
725 		__field(uint32_t, magic)
726 		__field(uint16_t, level)
727 	),
728 	TP_fast_assign(
729 		__entry->dev = mp->m_super->s_dev;
730 		__entry->agno = agno;
731 		__entry->agbno = agbno;
732 		__entry->magic = magic;
733 		__entry->level = level;
734 	),
735 	TP_printk("dev %d:%d agno %u agbno %u magic 0x%x level %u",
736 		  MAJOR(__entry->dev), MINOR(__entry->dev),
737 		  __entry->agno,
738 		  __entry->agbno,
739 		  __entry->magic,
740 		  __entry->level)
741 )
742 TRACE_EVENT(xrep_calc_ag_resblks,
743 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
744 		 xfs_agino_t icount, xfs_agblock_t aglen, xfs_agblock_t freelen,
745 		 xfs_agblock_t usedlen),
746 	TP_ARGS(mp, agno, icount, aglen, freelen, usedlen),
747 	TP_STRUCT__entry(
748 		__field(dev_t, dev)
749 		__field(xfs_agnumber_t, agno)
750 		__field(xfs_agino_t, icount)
751 		__field(xfs_agblock_t, aglen)
752 		__field(xfs_agblock_t, freelen)
753 		__field(xfs_agblock_t, usedlen)
754 	),
755 	TP_fast_assign(
756 		__entry->dev = mp->m_super->s_dev;
757 		__entry->agno = agno;
758 		__entry->icount = icount;
759 		__entry->aglen = aglen;
760 		__entry->freelen = freelen;
761 		__entry->usedlen = usedlen;
762 	),
763 	TP_printk("dev %d:%d agno %d icount %u aglen %u freelen %u usedlen %u",
764 		  MAJOR(__entry->dev), MINOR(__entry->dev),
765 		  __entry->agno,
766 		  __entry->icount,
767 		  __entry->aglen,
768 		  __entry->freelen,
769 		  __entry->usedlen)
770 )
771 TRACE_EVENT(xrep_calc_ag_resblks_btsize,
772 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
773 		 xfs_agblock_t bnobt_sz, xfs_agblock_t inobt_sz,
774 		 xfs_agblock_t rmapbt_sz, xfs_agblock_t refcbt_sz),
775 	TP_ARGS(mp, agno, bnobt_sz, inobt_sz, rmapbt_sz, refcbt_sz),
776 	TP_STRUCT__entry(
777 		__field(dev_t, dev)
778 		__field(xfs_agnumber_t, agno)
779 		__field(xfs_agblock_t, bnobt_sz)
780 		__field(xfs_agblock_t, inobt_sz)
781 		__field(xfs_agblock_t, rmapbt_sz)
782 		__field(xfs_agblock_t, refcbt_sz)
783 	),
784 	TP_fast_assign(
785 		__entry->dev = mp->m_super->s_dev;
786 		__entry->agno = agno;
787 		__entry->bnobt_sz = bnobt_sz;
788 		__entry->inobt_sz = inobt_sz;
789 		__entry->rmapbt_sz = rmapbt_sz;
790 		__entry->refcbt_sz = refcbt_sz;
791 	),
792 	TP_printk("dev %d:%d agno %d bno %u ino %u rmap %u refcount %u",
793 		  MAJOR(__entry->dev), MINOR(__entry->dev),
794 		  __entry->agno,
795 		  __entry->bnobt_sz,
796 		  __entry->inobt_sz,
797 		  __entry->rmapbt_sz,
798 		  __entry->refcbt_sz)
799 )
800 TRACE_EVENT(xrep_reset_counters,
801 	TP_PROTO(struct xfs_mount *mp),
802 	TP_ARGS(mp),
803 	TP_STRUCT__entry(
804 		__field(dev_t, dev)
805 	),
806 	TP_fast_assign(
807 		__entry->dev = mp->m_super->s_dev;
808 	),
809 	TP_printk("dev %d:%d",
810 		  MAJOR(__entry->dev), MINOR(__entry->dev))
811 )
812 
813 TRACE_EVENT(xrep_ialloc_insert,
814 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
815 		 xfs_agino_t startino, uint16_t holemask, uint8_t count,
816 		 uint8_t freecount, uint64_t freemask),
817 	TP_ARGS(mp, agno, startino, holemask, count, freecount, freemask),
818 	TP_STRUCT__entry(
819 		__field(dev_t, dev)
820 		__field(xfs_agnumber_t, agno)
821 		__field(xfs_agino_t, startino)
822 		__field(uint16_t, holemask)
823 		__field(uint8_t, count)
824 		__field(uint8_t, freecount)
825 		__field(uint64_t, freemask)
826 	),
827 	TP_fast_assign(
828 		__entry->dev = mp->m_super->s_dev;
829 		__entry->agno = agno;
830 		__entry->startino = startino;
831 		__entry->holemask = holemask;
832 		__entry->count = count;
833 		__entry->freecount = freecount;
834 		__entry->freemask = freemask;
835 	),
836 	TP_printk("dev %d:%d agno %d startino %u holemask 0x%x count %u freecount %u freemask 0x%llx",
837 		  MAJOR(__entry->dev), MINOR(__entry->dev),
838 		  __entry->agno,
839 		  __entry->startino,
840 		  __entry->holemask,
841 		  __entry->count,
842 		  __entry->freecount,
843 		  __entry->freemask)
844 )
845 
846 #endif /* IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR) */
847 
848 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
849 
850 #undef TRACE_INCLUDE_PATH
851 #define TRACE_INCLUDE_PATH .
852 #define TRACE_INCLUDE_FILE scrub/trace
853 #include <trace/define_trace.h>
854