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