xref: /openbmc/linux/fs/xfs/scrub/trace.h (revision ddc141e5)
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, xfs_daddr_t daddr,
178 		 void *ret_ip),
179 	TP_ARGS(sc, ino, daddr, ret_ip),
180 	TP_STRUCT__entry(
181 		__field(dev_t, dev)
182 		__field(xfs_ino_t, ino)
183 		__field(unsigned int, type)
184 		__field(xfs_agnumber_t, agno)
185 		__field(xfs_agblock_t, bno)
186 		__field(void *, ret_ip)
187 	),
188 	TP_fast_assign(
189 		xfs_fsblock_t	fsbno;
190 		xfs_agnumber_t	agno;
191 		xfs_agblock_t	bno;
192 
193 		if (daddr) {
194 			fsbno = XFS_DADDR_TO_FSB(sc->mp, daddr);
195 			agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
196 			bno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
197 		} else {
198 			agno = XFS_INO_TO_AGNO(sc->mp, ino);
199 			bno = XFS_AGINO_TO_AGBNO(sc->mp,
200 					XFS_INO_TO_AGINO(sc->mp, ino));
201 		}
202 
203 		__entry->dev = sc->mp->m_super->s_dev;
204 		__entry->ino = ino;
205 		__entry->type = sc->sm->sm_type;
206 		__entry->agno = agno;
207 		__entry->bno = bno;
208 		__entry->ret_ip = ret_ip;
209 	),
210 	TP_printk("dev %d:%d ino 0x%llx type %u agno %u agbno %u ret_ip %pS",
211 		  MAJOR(__entry->dev), MINOR(__entry->dev),
212 		  __entry->ino,
213 		  __entry->type,
214 		  __entry->agno,
215 		  __entry->bno,
216 		  __entry->ret_ip)
217 )
218 
219 #define DEFINE_SCRUB_INO_ERROR_EVENT(name) \
220 DEFINE_EVENT(xfs_scrub_ino_error_class, name, \
221 	TP_PROTO(struct xfs_scrub_context *sc, xfs_ino_t ino, \
222 		 xfs_daddr_t daddr, void *ret_ip), \
223 	TP_ARGS(sc, ino, daddr, ret_ip))
224 
225 DEFINE_SCRUB_INO_ERROR_EVENT(xfs_scrub_ino_error);
226 DEFINE_SCRUB_INO_ERROR_EVENT(xfs_scrub_ino_preen);
227 DEFINE_SCRUB_INO_ERROR_EVENT(xfs_scrub_ino_warning);
228 
229 DECLARE_EVENT_CLASS(xfs_scrub_fblock_error_class,
230 	TP_PROTO(struct xfs_scrub_context *sc, int whichfork,
231 		 xfs_fileoff_t offset, void *ret_ip),
232 	TP_ARGS(sc, whichfork, offset, ret_ip),
233 	TP_STRUCT__entry(
234 		__field(dev_t, dev)
235 		__field(xfs_ino_t, ino)
236 		__field(int, whichfork)
237 		__field(unsigned int, type)
238 		__field(xfs_fileoff_t, offset)
239 		__field(void *, ret_ip)
240 	),
241 	TP_fast_assign(
242 		__entry->dev = sc->ip->i_mount->m_super->s_dev;
243 		__entry->ino = sc->ip->i_ino;
244 		__entry->whichfork = whichfork;
245 		__entry->type = sc->sm->sm_type;
246 		__entry->offset = offset;
247 		__entry->ret_ip = ret_ip;
248 	),
249 	TP_printk("dev %d:%d ino 0x%llx fork %d type %u offset %llu ret_ip %pS",
250 		  MAJOR(__entry->dev), MINOR(__entry->dev),
251 		  __entry->ino,
252 		  __entry->whichfork,
253 		  __entry->type,
254 		  __entry->offset,
255 		  __entry->ret_ip)
256 );
257 
258 #define DEFINE_SCRUB_FBLOCK_ERROR_EVENT(name) \
259 DEFINE_EVENT(xfs_scrub_fblock_error_class, name, \
260 	TP_PROTO(struct xfs_scrub_context *sc, int whichfork, \
261 		 xfs_fileoff_t offset, void *ret_ip), \
262 	TP_ARGS(sc, whichfork, offset, ret_ip))
263 
264 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xfs_scrub_fblock_error);
265 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xfs_scrub_fblock_warning);
266 
267 TRACE_EVENT(xfs_scrub_incomplete,
268 	TP_PROTO(struct xfs_scrub_context *sc, void *ret_ip),
269 	TP_ARGS(sc, ret_ip),
270 	TP_STRUCT__entry(
271 		__field(dev_t, dev)
272 		__field(unsigned int, type)
273 		__field(void *, ret_ip)
274 	),
275 	TP_fast_assign(
276 		__entry->dev = sc->mp->m_super->s_dev;
277 		__entry->type = sc->sm->sm_type;
278 		__entry->ret_ip = ret_ip;
279 	),
280 	TP_printk("dev %d:%d type %u ret_ip %pS",
281 		  MAJOR(__entry->dev), MINOR(__entry->dev),
282 		  __entry->type,
283 		  __entry->ret_ip)
284 );
285 
286 TRACE_EVENT(xfs_scrub_btree_op_error,
287 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
288 		 int level, int error, void *ret_ip),
289 	TP_ARGS(sc, cur, level, error, ret_ip),
290 	TP_STRUCT__entry(
291 		__field(dev_t, dev)
292 		__field(unsigned int, type)
293 		__field(xfs_btnum_t, btnum)
294 		__field(int, level)
295 		__field(xfs_agnumber_t, agno)
296 		__field(xfs_agblock_t, bno)
297 		__field(int, ptr);
298 		__field(int, error)
299 		__field(void *, ret_ip)
300 	),
301 	TP_fast_assign(
302 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
303 
304 		__entry->dev = sc->mp->m_super->s_dev;
305 		__entry->type = sc->sm->sm_type;
306 		__entry->btnum = cur->bc_btnum;
307 		__entry->level = level;
308 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
309 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
310 		__entry->ptr = cur->bc_ptrs[level];
311 		__entry->error = error;
312 		__entry->ret_ip = ret_ip;
313 	),
314 	TP_printk("dev %d:%d type %u btnum %d level %d ptr %d agno %u agbno %u error %d ret_ip %pS",
315 		  MAJOR(__entry->dev), MINOR(__entry->dev),
316 		  __entry->type,
317 		  __entry->btnum,
318 		  __entry->level,
319 		  __entry->ptr,
320 		  __entry->agno,
321 		  __entry->bno,
322 		  __entry->error,
323 		  __entry->ret_ip)
324 );
325 
326 TRACE_EVENT(xfs_scrub_ifork_btree_op_error,
327 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
328 		 int level, int error, void *ret_ip),
329 	TP_ARGS(sc, cur, level, error, ret_ip),
330 	TP_STRUCT__entry(
331 		__field(dev_t, dev)
332 		__field(xfs_ino_t, ino)
333 		__field(int, whichfork)
334 		__field(unsigned int, type)
335 		__field(xfs_btnum_t, btnum)
336 		__field(int, level)
337 		__field(int, ptr)
338 		__field(xfs_agnumber_t, agno)
339 		__field(xfs_agblock_t, bno)
340 		__field(int, error)
341 		__field(void *, ret_ip)
342 	),
343 	TP_fast_assign(
344 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
345 		__entry->dev = sc->mp->m_super->s_dev;
346 		__entry->ino = sc->ip->i_ino;
347 		__entry->whichfork = cur->bc_private.b.whichfork;
348 		__entry->type = sc->sm->sm_type;
349 		__entry->btnum = cur->bc_btnum;
350 		__entry->level = level;
351 		__entry->ptr = cur->bc_ptrs[level];
352 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
353 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
354 		__entry->error = error;
355 		__entry->ret_ip = ret_ip;
356 	),
357 	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",
358 		  MAJOR(__entry->dev), MINOR(__entry->dev),
359 		  __entry->ino,
360 		  __entry->whichfork,
361 		  __entry->type,
362 		  __entry->btnum,
363 		  __entry->level,
364 		  __entry->ptr,
365 		  __entry->agno,
366 		  __entry->bno,
367 		  __entry->error,
368 		  __entry->ret_ip)
369 );
370 
371 TRACE_EVENT(xfs_scrub_btree_error,
372 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
373 		 int level, void *ret_ip),
374 	TP_ARGS(sc, cur, level, ret_ip),
375 	TP_STRUCT__entry(
376 		__field(dev_t, dev)
377 		__field(unsigned int, type)
378 		__field(xfs_btnum_t, btnum)
379 		__field(int, level)
380 		__field(xfs_agnumber_t, agno)
381 		__field(xfs_agblock_t, bno)
382 		__field(int, ptr);
383 		__field(void *, ret_ip)
384 	),
385 	TP_fast_assign(
386 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
387 		__entry->dev = sc->mp->m_super->s_dev;
388 		__entry->type = sc->sm->sm_type;
389 		__entry->btnum = cur->bc_btnum;
390 		__entry->level = level;
391 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
392 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
393 		__entry->ptr = cur->bc_ptrs[level];
394 		__entry->ret_ip = ret_ip;
395 	),
396 	TP_printk("dev %d:%d type %u btnum %d level %d ptr %d agno %u agbno %u ret_ip %pS",
397 		  MAJOR(__entry->dev), MINOR(__entry->dev),
398 		  __entry->type,
399 		  __entry->btnum,
400 		  __entry->level,
401 		  __entry->ptr,
402 		  __entry->agno,
403 		  __entry->bno,
404 		  __entry->ret_ip)
405 );
406 
407 TRACE_EVENT(xfs_scrub_ifork_btree_error,
408 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
409 		 int level, void *ret_ip),
410 	TP_ARGS(sc, cur, level, ret_ip),
411 	TP_STRUCT__entry(
412 		__field(dev_t, dev)
413 		__field(xfs_ino_t, ino)
414 		__field(int, whichfork)
415 		__field(unsigned int, type)
416 		__field(xfs_btnum_t, btnum)
417 		__field(int, level)
418 		__field(xfs_agnumber_t, agno)
419 		__field(xfs_agblock_t, bno)
420 		__field(int, ptr);
421 		__field(void *, ret_ip)
422 	),
423 	TP_fast_assign(
424 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
425 		__entry->dev = sc->mp->m_super->s_dev;
426 		__entry->ino = sc->ip->i_ino;
427 		__entry->whichfork = cur->bc_private.b.whichfork;
428 		__entry->type = sc->sm->sm_type;
429 		__entry->btnum = cur->bc_btnum;
430 		__entry->level = level;
431 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
432 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
433 		__entry->ptr = cur->bc_ptrs[level];
434 		__entry->ret_ip = ret_ip;
435 	),
436 	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",
437 		  MAJOR(__entry->dev), MINOR(__entry->dev),
438 		  __entry->ino,
439 		  __entry->whichfork,
440 		  __entry->type,
441 		  __entry->btnum,
442 		  __entry->level,
443 		  __entry->ptr,
444 		  __entry->agno,
445 		  __entry->bno,
446 		  __entry->ret_ip)
447 );
448 
449 DECLARE_EVENT_CLASS(xfs_scrub_sbtree_class,
450 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
451 		 int level),
452 	TP_ARGS(sc, cur, level),
453 	TP_STRUCT__entry(
454 		__field(dev_t, dev)
455 		__field(int, type)
456 		__field(xfs_btnum_t, btnum)
457 		__field(xfs_agnumber_t, agno)
458 		__field(xfs_agblock_t, bno)
459 		__field(int, level)
460 		__field(int, nlevels)
461 		__field(int, ptr)
462 	),
463 	TP_fast_assign(
464 		xfs_fsblock_t fsbno = xfs_scrub_btree_cur_fsbno(cur, level);
465 
466 		__entry->dev = sc->mp->m_super->s_dev;
467 		__entry->type = sc->sm->sm_type;
468 		__entry->btnum = cur->bc_btnum;
469 		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);
470 		__entry->bno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsbno);
471 		__entry->level = level;
472 		__entry->nlevels = cur->bc_nlevels;
473 		__entry->ptr = cur->bc_ptrs[level];
474 	),
475 	TP_printk("dev %d:%d type %u btnum %d agno %u agbno %u level %d nlevels %d ptr %d",
476 		  MAJOR(__entry->dev), MINOR(__entry->dev),
477 		  __entry->type,
478 		  __entry->btnum,
479 		  __entry->agno,
480 		  __entry->bno,
481 		  __entry->level,
482 		  __entry->nlevels,
483 		  __entry->ptr)
484 )
485 #define DEFINE_SCRUB_SBTREE_EVENT(name) \
486 DEFINE_EVENT(xfs_scrub_sbtree_class, name, \
487 	TP_PROTO(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur, \
488 		 int level), \
489 	TP_ARGS(sc, cur, level))
490 
491 DEFINE_SCRUB_SBTREE_EVENT(xfs_scrub_btree_rec);
492 DEFINE_SCRUB_SBTREE_EVENT(xfs_scrub_btree_key);
493 
494 TRACE_EVENT(xfs_scrub_xref_error,
495 	TP_PROTO(struct xfs_scrub_context *sc, int error, void *ret_ip),
496 	TP_ARGS(sc, error, ret_ip),
497 	TP_STRUCT__entry(
498 		__field(dev_t, dev)
499 		__field(int, type)
500 		__field(int, error)
501 		__field(void *, ret_ip)
502 	),
503 	TP_fast_assign(
504 		__entry->dev = sc->mp->m_super->s_dev;
505 		__entry->type = sc->sm->sm_type;
506 		__entry->error = error;
507 		__entry->ret_ip = ret_ip;
508 	),
509 	TP_printk("dev %d:%d type %u xref error %d ret_ip %pF",
510 		  MAJOR(__entry->dev), MINOR(__entry->dev),
511 		  __entry->type,
512 		  __entry->error,
513 		  __entry->ret_ip)
514 );
515 
516 #endif /* _TRACE_XFS_SCRUB_TRACE_H */
517 
518 #undef TRACE_INCLUDE_PATH
519 #define TRACE_INCLUDE_PATH .
520 #define TRACE_INCLUDE_FILE scrub/trace
521 #include <trace/define_trace.h>
522