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