xref: /openbmc/linux/fs/xfs/scrub/trace.h (revision a48c7709)
1 /*
2  * Copyright (C) 2017 Oracle.  All Rights Reserved.
3  *
4  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it would be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write the Free Software Foundation,
18  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20 #undef TRACE_SYSTEM
21 #define TRACE_SYSTEM xfs_scrub
22 
23 #if !defined(_TRACE_XFS_SCRUB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
24 #define _TRACE_XFS_SCRUB_TRACE_H
25 
26 #include <linux/tracepoint.h>
27 #include "xfs_bit.h"
28 
29 DECLARE_EVENT_CLASS(xfs_scrub_class,
30 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm,
31 		 int error),
32 	TP_ARGS(ip, sm, error),
33 	TP_STRUCT__entry(
34 		__field(dev_t, dev)
35 		__field(xfs_ino_t, ino)
36 		__field(unsigned int, type)
37 		__field(xfs_agnumber_t, agno)
38 		__field(xfs_ino_t, inum)
39 		__field(unsigned int, gen)
40 		__field(unsigned int, flags)
41 		__field(int, error)
42 	),
43 	TP_fast_assign(
44 		__entry->dev = ip->i_mount->m_super->s_dev;
45 		__entry->ino = ip->i_ino;
46 		__entry->type = sm->sm_type;
47 		__entry->agno = sm->sm_agno;
48 		__entry->inum = sm->sm_ino;
49 		__entry->gen = sm->sm_gen;
50 		__entry->flags = sm->sm_flags;
51 		__entry->error = error;
52 	),
53 	TP_printk("dev %d:%d ino 0x%llx type %u agno %u inum %llu gen %u flags 0x%x error %d",
54 		  MAJOR(__entry->dev), MINOR(__entry->dev),
55 		  __entry->ino,
56 		  __entry->type,
57 		  __entry->agno,
58 		  __entry->inum,
59 		  __entry->gen,
60 		  __entry->flags,
61 		  __entry->error)
62 )
63 #define DEFINE_SCRUB_EVENT(name) \
64 DEFINE_EVENT(xfs_scrub_class, name, \
65 	TP_PROTO(struct xfs_inode *ip, struct xfs_scrub_metadata *sm, \
66 		 int error), \
67 	TP_ARGS(ip, sm, error))
68 
69 DEFINE_SCRUB_EVENT(xfs_scrub_start);
70 DEFINE_SCRUB_EVENT(xfs_scrub_done);
71 DEFINE_SCRUB_EVENT(xfs_scrub_deadlock_retry);
72 
73 TRACE_EVENT(xfs_scrub_op_error,
74 	TP_PROTO(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
75 		 xfs_agblock_t bno, int error, void *ret_ip),
76 	TP_ARGS(sc, agno, bno, error, ret_ip),
77 	TP_STRUCT__entry(
78 		__field(dev_t, dev)
79 		__field(unsigned int, type)
80 		__field(xfs_agnumber_t, agno)
81 		__field(xfs_agblock_t, bno)
82 		__field(int, error)
83 		__field(void *, ret_ip)
84 	),
85 	TP_fast_assign(
86 		__entry->dev = sc->mp->m_super->s_dev;
87 		__entry->type = sc->sm->sm_type;
88 		__entry->agno = agno;
89 		__entry->bno = bno;
90 		__entry->error = error;
91 		__entry->ret_ip = ret_ip;
92 	),
93 	TP_printk("dev %d:%d type %u agno %u agbno %u error %d ret_ip %pS",
94 		  MAJOR(__entry->dev), MINOR(__entry->dev),
95 		  __entry->type,
96 		  __entry->agno,
97 		  __entry->bno,
98 		  __entry->error,
99 		  __entry->ret_ip)
100 );
101 
102 TRACE_EVENT(xfs_scrub_file_op_error,
103 	TP_PROTO(struct xfs_scrub_context *sc, int whichfork,
104 		 xfs_fileoff_t offset, int error, void *ret_ip),
105 	TP_ARGS(sc, whichfork, offset, error, ret_ip),
106 	TP_STRUCT__entry(
107 		__field(dev_t, dev)
108 		__field(xfs_ino_t, ino)
109 		__field(int, whichfork)
110 		__field(unsigned int, type)
111 		__field(xfs_fileoff_t, offset)
112 		__field(int, error)
113 		__field(void *, ret_ip)
114 	),
115 	TP_fast_assign(
116 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
117 		__entry->ino = sc->ip->i_ino;
118 		__entry->whichfork = whichfork;
119 		__entry->type = sc->sm->sm_type;
120 		__entry->offset = offset;
121 		__entry->error = error;
122 		__entry->ret_ip = ret_ip;
123 	),
124 	TP_printk("dev %d:%d ino 0x%llx fork %d type %u offset %llu error %d ret_ip %pS",
125 		  MAJOR(__entry->dev), MINOR(__entry->dev),
126 		  __entry->ino,
127 		  __entry->whichfork,
128 		  __entry->type,
129 		  __entry->offset,
130 		  __entry->error,
131 		  __entry->ret_ip)
132 );
133 
134 DECLARE_EVENT_CLASS(xfs_scrub_block_error_class,
135 	TP_PROTO(struct xfs_scrub_context *sc, xfs_daddr_t daddr, void *ret_ip),
136 	TP_ARGS(sc, daddr, ret_ip),
137 	TP_STRUCT__entry(
138 		__field(dev_t, dev)
139 		__field(unsigned int, type)
140 		__field(xfs_agnumber_t, agno)
141 		__field(xfs_agblock_t, bno)
142 		__field(void *, ret_ip)
143 	),
144 	TP_fast_assign(
145 		xfs_fsblock_t	fsbno;
146 		xfs_agnumber_t	agno;
147 		xfs_agblock_t	bno;
148 
149 		fsbno = XFS_DADDR_TO_FSB(sc->mp, daddr);
150 		agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
151 		bno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
152 
153 		__entry->dev = sc->mp->m_super->s_dev;
154 		__entry->type = sc->sm->sm_type;
155 		__entry->agno = agno;
156 		__entry->bno = bno;
157 		__entry->ret_ip = ret_ip;
158 	),
159 	TP_printk("dev %d:%d type %u agno %u agbno %u ret_ip %pS",
160 		  MAJOR(__entry->dev), MINOR(__entry->dev),
161 		  __entry->type,
162 		  __entry->agno,
163 		  __entry->bno,
164 		  __entry->ret_ip)
165 )
166 
167 #define DEFINE_SCRUB_BLOCK_ERROR_EVENT(name) \
168 DEFINE_EVENT(xfs_scrub_block_error_class, name, \
169 	TP_PROTO(struct xfs_scrub_context *sc, xfs_daddr_t daddr, \
170 		 void *ret_ip), \
171 	TP_ARGS(sc, daddr, ret_ip))
172 
173 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xfs_scrub_block_error);
174 DEFINE_SCRUB_BLOCK_ERROR_EVENT(xfs_scrub_block_preen);
175 
176 DECLARE_EVENT_CLASS(xfs_scrub_ino_error_class,
177 	TP_PROTO(struct xfs_scrub_context *sc, xfs_ino_t ino, void *ret_ip),
178 	TP_ARGS(sc, ino, ret_ip),
179 	TP_STRUCT__entry(
180 		__field(dev_t, dev)
181 		__field(xfs_ino_t, ino)
182 		__field(unsigned int, type)
183 		__field(void *, ret_ip)
184 	),
185 	TP_fast_assign(
186 		__entry->dev = sc->mp->m_super->s_dev;
187 		__entry->ino = ino;
188 		__entry->type = sc->sm->sm_type;
189 		__entry->ret_ip = ret_ip;
190 	),
191 	TP_printk("dev %d:%d ino 0x%llx type %u ret_ip %pS",
192 		  MAJOR(__entry->dev), MINOR(__entry->dev),
193 		  __entry->ino,
194 		  __entry->type,
195 		  __entry->ret_ip)
196 )
197 
198 #define DEFINE_SCRUB_INO_ERROR_EVENT(name) \
199 DEFINE_EVENT(xfs_scrub_ino_error_class, name, \
200 	TP_PROTO(struct xfs_scrub_context *sc, xfs_ino_t ino, \
201 		 void *ret_ip), \
202 	TP_ARGS(sc, ino, ret_ip))
203 
204 DEFINE_SCRUB_INO_ERROR_EVENT(xfs_scrub_ino_error);
205 DEFINE_SCRUB_INO_ERROR_EVENT(xfs_scrub_ino_preen);
206 DEFINE_SCRUB_INO_ERROR_EVENT(xfs_scrub_ino_warning);
207 
208 DECLARE_EVENT_CLASS(xfs_scrub_fblock_error_class,
209 	TP_PROTO(struct xfs_scrub_context *sc, int whichfork,
210 		 xfs_fileoff_t offset, void *ret_ip),
211 	TP_ARGS(sc, whichfork, offset, ret_ip),
212 	TP_STRUCT__entry(
213 		__field(dev_t, dev)
214 		__field(xfs_ino_t, ino)
215 		__field(int, whichfork)
216 		__field(unsigned int, type)
217 		__field(xfs_fileoff_t, offset)
218 		__field(void *, ret_ip)
219 	),
220 	TP_fast_assign(
221 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
222 		__entry->ino = sc->ip->i_ino;
223 		__entry->whichfork = whichfork;
224 		__entry->type = sc->sm->sm_type;
225 		__entry->offset = offset;
226 		__entry->ret_ip = ret_ip;
227 	),
228 	TP_printk("dev %d:%d ino 0x%llx fork %d type %u offset %llu ret_ip %pS",
229 		  MAJOR(__entry->dev), MINOR(__entry->dev),
230 		  __entry->ino,
231 		  __entry->whichfork,
232 		  __entry->type,
233 		  __entry->offset,
234 		  __entry->ret_ip)
235 );
236 
237 #define DEFINE_SCRUB_FBLOCK_ERROR_EVENT(name) \
238 DEFINE_EVENT(xfs_scrub_fblock_error_class, name, \
239 	TP_PROTO(struct xfs_scrub_context *sc, int whichfork, \
240 		 xfs_fileoff_t offset, void *ret_ip), \
241 	TP_ARGS(sc, whichfork, offset, ret_ip))
242 
243 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xfs_scrub_fblock_error);
244 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xfs_scrub_fblock_warning);
245 
246 TRACE_EVENT(xfs_scrub_incomplete,
247 	TP_PROTO(struct xfs_scrub_context *sc, void *ret_ip),
248 	TP_ARGS(sc, ret_ip),
249 	TP_STRUCT__entry(
250 		__field(dev_t, dev)
251 		__field(unsigned int, type)
252 		__field(void *, ret_ip)
253 	),
254 	TP_fast_assign(
255 		__entry->dev = sc->mp->m_super->s_dev;
256 		__entry->type = sc->sm->sm_type;
257 		__entry->ret_ip = ret_ip;
258 	),
259 	TP_printk("dev %d:%d type %u ret_ip %pS",
260 		  MAJOR(__entry->dev), MINOR(__entry->dev),
261 		  __entry->type,
262 		  __entry->ret_ip)
263 );
264 
265 TRACE_EVENT(xfs_scrub_btree_op_error,
266 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
267 		 int level, int error, void *ret_ip),
268 	TP_ARGS(sc, cur, level, error, ret_ip),
269 	TP_STRUCT__entry(
270 		__field(dev_t, dev)
271 		__field(unsigned int, type)
272 		__field(xfs_btnum_t, btnum)
273 		__field(int, level)
274 		__field(xfs_agnumber_t, agno)
275 		__field(xfs_agblock_t, bno)
276 		__field(int, ptr);
277 		__field(int, error)
278 		__field(void *, ret_ip)
279 	),
280 	TP_fast_assign(
281 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
282 
283 		__entry->dev = sc->mp->m_super->s_dev;
284 		__entry->type = sc->sm->sm_type;
285 		__entry->btnum = cur->bc_btnum;
286 		__entry->level = level;
287 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
288 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
289 		__entry->ptr = cur->bc_ptrs[level];
290 		__entry->error = error;
291 		__entry->ret_ip = ret_ip;
292 	),
293 	TP_printk("dev %d:%d type %u btnum %d level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
294 		  MAJOR(__entry->dev), MINOR(__entry->dev),
295 		  __entry->type,
296 		  __entry->btnum,
297 		  __entry->level,
298 		  __entry->ptr,
299 		  __entry->agno,
300 		  __entry->bno,
301 		  __entry->error,
302 		  __entry->ret_ip)
303 );
304 
305 TRACE_EVENT(xfs_scrub_ifork_btree_op_error,
306 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
307 		 int level, int error, void *ret_ip),
308 	TP_ARGS(sc, cur, level, error, ret_ip),
309 	TP_STRUCT__entry(
310 		__field(dev_t, dev)
311 		__field(xfs_ino_t, ino)
312 		__field(int, whichfork)
313 		__field(unsigned int, type)
314 		__field(xfs_btnum_t, btnum)
315 		__field(int, level)
316 		__field(int, ptr)
317 		__field(xfs_agnumber_t, agno)
318 		__field(xfs_agblock_t, bno)
319 		__field(int, error)
320 		__field(void *, ret_ip)
321 	),
322 	TP_fast_assign(
323 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
324 		__entry->dev = sc->mp->m_super->s_dev;
325 		__entry->ino = sc->ip->i_ino;
326 		__entry->whichfork = cur->bc_private.b.whichfork;
327 		__entry->type = sc->sm->sm_type;
328 		__entry->btnum = cur->bc_btnum;
329 		__entry->level = level;
330 		__entry->ptr = cur->bc_ptrs[level];
331 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
332 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
333 		__entry->error = error;
334 		__entry->ret_ip = ret_ip;
335 	),
336 	TP_printk("dev %d:%d ino 0x%llx fork %d type %u btnum %d level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
337 		  MAJOR(__entry->dev), MINOR(__entry->dev),
338 		  __entry->ino,
339 		  __entry->whichfork,
340 		  __entry->type,
341 		  __entry->btnum,
342 		  __entry->level,
343 		  __entry->ptr,
344 		  __entry->agno,
345 		  __entry->bno,
346 		  __entry->error,
347 		  __entry->ret_ip)
348 );
349 
350 TRACE_EVENT(xfs_scrub_btree_error,
351 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
352 		 int level, void *ret_ip),
353 	TP_ARGS(sc, cur, level, ret_ip),
354 	TP_STRUCT__entry(
355 		__field(dev_t, dev)
356 		__field(unsigned int, type)
357 		__field(xfs_btnum_t, btnum)
358 		__field(int, level)
359 		__field(xfs_agnumber_t, agno)
360 		__field(xfs_agblock_t, bno)
361 		__field(int, ptr);
362 		__field(void *, ret_ip)
363 	),
364 	TP_fast_assign(
365 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
366 		__entry->dev = sc->mp->m_super->s_dev;
367 		__entry->type = sc->sm->sm_type;
368 		__entry->btnum = cur->bc_btnum;
369 		__entry->level = level;
370 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
371 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
372 		__entry->ptr = cur->bc_ptrs[level];
373 		__entry->ret_ip = ret_ip;
374 	),
375 	TP_printk("dev %d:%d type %u btnum %d level %d ptr %d agno %u agbno %u ret_ip %pS",
376 		  MAJOR(__entry->dev), MINOR(__entry->dev),
377 		  __entry->type,
378 		  __entry->btnum,
379 		  __entry->level,
380 		  __entry->ptr,
381 		  __entry->agno,
382 		  __entry->bno,
383 		  __entry->ret_ip)
384 );
385 
386 TRACE_EVENT(xfs_scrub_ifork_btree_error,
387 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
388 		 int level, void *ret_ip),
389 	TP_ARGS(sc, cur, level, ret_ip),
390 	TP_STRUCT__entry(
391 		__field(dev_t, dev)
392 		__field(xfs_ino_t, ino)
393 		__field(int, whichfork)
394 		__field(unsigned int, type)
395 		__field(xfs_btnum_t, btnum)
396 		__field(int, level)
397 		__field(xfs_agnumber_t, agno)
398 		__field(xfs_agblock_t, bno)
399 		__field(int, ptr);
400 		__field(void *, ret_ip)
401 	),
402 	TP_fast_assign(
403 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
404 		__entry->dev = sc->mp->m_super->s_dev;
405 		__entry->ino = sc->ip->i_ino;
406 		__entry->whichfork = cur->bc_private.b.whichfork;
407 		__entry->type = sc->sm->sm_type;
408 		__entry->btnum = cur->bc_btnum;
409 		__entry->level = level;
410 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
411 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
412 		__entry->ptr = cur->bc_ptrs[level];
413 		__entry->ret_ip = ret_ip;
414 	),
415 	TP_printk("dev %d:%d ino 0x%llx fork %d type %u btnum %d level %d ptr %d agno %u agbno %u ret_ip %pS",
416 		  MAJOR(__entry->dev), MINOR(__entry->dev),
417 		  __entry->ino,
418 		  __entry->whichfork,
419 		  __entry->type,
420 		  __entry->btnum,
421 		  __entry->level,
422 		  __entry->ptr,
423 		  __entry->agno,
424 		  __entry->bno,
425 		  __entry->ret_ip)
426 );
427 
428 DECLARE_EVENT_CLASS(xfs_scrub_sbtree_class,
429 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
430 		 int level),
431 	TP_ARGS(sc, cur, level),
432 	TP_STRUCT__entry(
433 		__field(dev_t, dev)
434 		__field(int, type)
435 		__field(xfs_btnum_t, btnum)
436 		__field(xfs_agnumber_t, agno)
437 		__field(xfs_agblock_t, bno)
438 		__field(int, level)
439 		__field(int, nlevels)
440 		__field(int, ptr)
441 	),
442 	TP_fast_assign(
443 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
444 
445 		__entry->dev = sc->mp->m_super->s_dev;
446 		__entry->type = sc->sm->sm_type;
447 		__entry->btnum = cur->bc_btnum;
448 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
449 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
450 		__entry->level = level;
451 		__entry->nlevels = cur->bc_nlevels;
452 		__entry->ptr = cur->bc_ptrs[level];
453 	),
454 	TP_printk("dev %d:%d type %u btnum %d agno %u agbno %u level %d nlevels %d ptr %d",
455 		  MAJOR(__entry->dev), MINOR(__entry->dev),
456 		  __entry->type,
457 		  __entry->btnum,
458 		  __entry->agno,
459 		  __entry->bno,
460 		  __entry->level,
461 		  __entry->nlevels,
462 		  __entry->ptr)
463 )
464 #define DEFINE_SCRUB_SBTREE_EVENT(name) \
465 DEFINE_EVENT(xfs_scrub_sbtree_class, name, \
466 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur, \
467 		 int level), \
468 	TP_ARGS(sc, cur, level))
469 
470 DEFINE_SCRUB_SBTREE_EVENT(xfs_scrub_btree_rec);
471 DEFINE_SCRUB_SBTREE_EVENT(xfs_scrub_btree_key);
472 
473 TRACE_EVENT(xfs_scrub_xref_error,
474 	TP_PROTO(struct xfs_scrub_context *sc, int error, void *ret_ip),
475 	TP_ARGS(sc, error, ret_ip),
476 	TP_STRUCT__entry(
477 		__field(dev_t, dev)
478 		__field(int, type)
479 		__field(int, error)
480 		__field(void *, ret_ip)
481 	),
482 	TP_fast_assign(
483 		__entry->dev = sc->mp->m_super->s_dev;
484 		__entry->type = sc->sm->sm_type;
485 		__entry->error = error;
486 		__entry->ret_ip = ret_ip;
487 	),
488 	TP_printk("dev %d:%d type %u xref error %d ret_ip %pF",
489 		  MAJOR(__entry->dev), MINOR(__entry->dev),
490 		  __entry->type,
491 		  __entry->error,
492 		  __entry->ret_ip)
493 );
494 
495 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
496 
497 #undef TRACE_INCLUDE_PATH
498 #define TRACE_INCLUDE_PATH .
499 #define TRACE_INCLUDE_FILE scrub/trace
500 #include <trace/define_trace.h>
501