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