xref: /openbmc/linux/fs/xfs/xfs_trace.h (revision 47010c04)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2009, Christoph Hellwig
4  * All Rights Reserved.
5  *
6  * NOTE: none of these tracepoints shall be considered a stable kernel ABI
7  * as they can change at any time.
8  *
9  * Current conventions for printing numbers measuring specific units:
10  *
11  * agno: allocation group number
12  *
13  * agino: per-AG inode number
14  * ino: filesystem inode number
15  *
16  * agbno: per-AG block number in fs blocks
17  * startblock: physical block number for file mappings.  This is either a
18  *             segmented fsblock for data device mappings, or a rfsblock
19  *             for realtime device mappings
20  * fsbcount: number of blocks in an extent, in fs blocks
21  *
22  * daddr: physical block number in 512b blocks
23  * bbcount: number of blocks in a physical extent, in 512b blocks
24  *
25  * owner: reverse-mapping owner, usually inodes
26  *
27  * fileoff: file offset, in fs blocks
28  * pos: file offset, in bytes
29  * bytecount: number of bytes
30  *
31  * disize: ondisk file size, in bytes
32  * isize: incore file size, in bytes
33  *
34  * forkoff: inode fork offset, in bytes
35  *
36  * ireccount: number of inode records
37  *
38  * Numbers describing space allocations (blocks, extents, inodes) should be
39  * formatted in hexadecimal.
40  */
41 #undef TRACE_SYSTEM
42 #define TRACE_SYSTEM xfs
43 
44 #if !defined(_TRACE_XFS_H) || defined(TRACE_HEADER_MULTI_READ)
45 #define _TRACE_XFS_H
46 
47 #include <linux/tracepoint.h>
48 
49 struct xfs_agf;
50 struct xfs_alloc_arg;
51 struct xfs_attr_list_context;
52 struct xfs_buf_log_item;
53 struct xfs_da_args;
54 struct xfs_da_node_entry;
55 struct xfs_dquot;
56 struct xfs_log_item;
57 struct xlog;
58 struct xlog_ticket;
59 struct xlog_recover;
60 struct xlog_recover_item;
61 struct xlog_rec_header;
62 struct xlog_in_core;
63 struct xfs_buf_log_format;
64 struct xfs_inode_log_format;
65 struct xfs_bmbt_irec;
66 struct xfs_btree_cur;
67 struct xfs_refcount_irec;
68 struct xfs_fsmap;
69 struct xfs_rmap_irec;
70 struct xfs_icreate_log;
71 struct xfs_owner_info;
72 struct xfs_trans_res;
73 struct xfs_inobt_rec_incore;
74 union xfs_btree_ptr;
75 struct xfs_dqtrx;
76 struct xfs_icwalk;
77 
78 #define XFS_ATTR_FILTER_FLAGS \
79 	{ XFS_ATTR_ROOT,	"ROOT" }, \
80 	{ XFS_ATTR_SECURE,	"SECURE" }, \
81 	{ XFS_ATTR_INCOMPLETE,	"INCOMPLETE" }
82 
83 DECLARE_EVENT_CLASS(xfs_attr_list_class,
84 	TP_PROTO(struct xfs_attr_list_context *ctx),
85 	TP_ARGS(ctx),
86 	TP_STRUCT__entry(
87 		__field(dev_t, dev)
88 		__field(xfs_ino_t, ino)
89 		__field(u32, hashval)
90 		__field(u32, blkno)
91 		__field(u32, offset)
92 		__field(void *, buffer)
93 		__field(int, bufsize)
94 		__field(int, count)
95 		__field(int, firstu)
96 		__field(int, dupcnt)
97 		__field(unsigned int, attr_filter)
98 	),
99 	TP_fast_assign(
100 		__entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
101 		__entry->ino = ctx->dp->i_ino;
102 		__entry->hashval = ctx->cursor.hashval;
103 		__entry->blkno = ctx->cursor.blkno;
104 		__entry->offset = ctx->cursor.offset;
105 		__entry->buffer = ctx->buffer;
106 		__entry->bufsize = ctx->bufsize;
107 		__entry->count = ctx->count;
108 		__entry->firstu = ctx->firstu;
109 		__entry->attr_filter = ctx->attr_filter;
110 	),
111 	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
112 		  "buffer %p size %u count %u firstu %u filter %s",
113 		  MAJOR(__entry->dev), MINOR(__entry->dev),
114 		   __entry->ino,
115 		   __entry->hashval,
116 		   __entry->blkno,
117 		   __entry->offset,
118 		   __entry->dupcnt,
119 		   __entry->buffer,
120 		   __entry->bufsize,
121 		   __entry->count,
122 		   __entry->firstu,
123 		   __print_flags(__entry->attr_filter, "|",
124 				 XFS_ATTR_FILTER_FLAGS)
125 	)
126 )
127 
128 #define DEFINE_ATTR_LIST_EVENT(name) \
129 DEFINE_EVENT(xfs_attr_list_class, name, \
130 	TP_PROTO(struct xfs_attr_list_context *ctx), \
131 	TP_ARGS(ctx))
132 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf);
133 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf_all);
134 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf);
135 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf_end);
136 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_full);
137 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_add);
138 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_wrong_blk);
139 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_notfound);
140 DEFINE_ATTR_LIST_EVENT(xfs_attr_leaf_list);
141 DEFINE_ATTR_LIST_EVENT(xfs_attr_node_list);
142 
143 TRACE_EVENT(xlog_intent_recovery_failed,
144 	TP_PROTO(struct xfs_mount *mp, int error, void *function),
145 	TP_ARGS(mp, error, function),
146 	TP_STRUCT__entry(
147 		__field(dev_t, dev)
148 		__field(int, error)
149 		__field(void *, function)
150 	),
151 	TP_fast_assign(
152 		__entry->dev = mp->m_super->s_dev;
153 		__entry->error = error;
154 		__entry->function = function;
155 	),
156 	TP_printk("dev %d:%d error %d function %pS",
157 		  MAJOR(__entry->dev), MINOR(__entry->dev),
158 		  __entry->error, __entry->function)
159 );
160 
161 DECLARE_EVENT_CLASS(xfs_perag_class,
162 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int refcount,
163 		 unsigned long caller_ip),
164 	TP_ARGS(mp, agno, refcount, caller_ip),
165 	TP_STRUCT__entry(
166 		__field(dev_t, dev)
167 		__field(xfs_agnumber_t, agno)
168 		__field(int, refcount)
169 		__field(unsigned long, caller_ip)
170 	),
171 	TP_fast_assign(
172 		__entry->dev = mp->m_super->s_dev;
173 		__entry->agno = agno;
174 		__entry->refcount = refcount;
175 		__entry->caller_ip = caller_ip;
176 	),
177 	TP_printk("dev %d:%d agno 0x%x refcount %d caller %pS",
178 		  MAJOR(__entry->dev), MINOR(__entry->dev),
179 		  __entry->agno,
180 		  __entry->refcount,
181 		  (char *)__entry->caller_ip)
182 );
183 
184 #define DEFINE_PERAG_REF_EVENT(name)	\
185 DEFINE_EVENT(xfs_perag_class, name,	\
186 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int refcount,	\
187 		 unsigned long caller_ip),					\
188 	TP_ARGS(mp, agno, refcount, caller_ip))
189 DEFINE_PERAG_REF_EVENT(xfs_perag_get);
190 DEFINE_PERAG_REF_EVENT(xfs_perag_get_tag);
191 DEFINE_PERAG_REF_EVENT(xfs_perag_put);
192 DEFINE_PERAG_REF_EVENT(xfs_perag_set_inode_tag);
193 DEFINE_PERAG_REF_EVENT(xfs_perag_clear_inode_tag);
194 
195 TRACE_EVENT(xfs_inodegc_worker,
196 	TP_PROTO(struct xfs_mount *mp, unsigned int shrinker_hits),
197 	TP_ARGS(mp, shrinker_hits),
198 	TP_STRUCT__entry(
199 		__field(dev_t, dev)
200 		__field(unsigned int, shrinker_hits)
201 	),
202 	TP_fast_assign(
203 		__entry->dev = mp->m_super->s_dev;
204 		__entry->shrinker_hits = shrinker_hits;
205 	),
206 	TP_printk("dev %d:%d shrinker_hits %u",
207 		  MAJOR(__entry->dev), MINOR(__entry->dev),
208 		  __entry->shrinker_hits)
209 );
210 
211 DECLARE_EVENT_CLASS(xfs_fs_class,
212 	TP_PROTO(struct xfs_mount *mp, void *caller_ip),
213 	TP_ARGS(mp, caller_ip),
214 	TP_STRUCT__entry(
215 		__field(dev_t, dev)
216 		__field(unsigned long long, mflags)
217 		__field(unsigned long, opstate)
218 		__field(unsigned long, sbflags)
219 		__field(void *, caller_ip)
220 	),
221 	TP_fast_assign(
222 		if (mp) {
223 			__entry->dev = mp->m_super->s_dev;
224 			__entry->mflags = mp->m_features;
225 			__entry->opstate = mp->m_opstate;
226 			__entry->sbflags = mp->m_super->s_flags;
227 		}
228 		__entry->caller_ip = caller_ip;
229 	),
230 	TP_printk("dev %d:%d m_features 0x%llx opstate (%s) s_flags 0x%lx caller %pS",
231 		  MAJOR(__entry->dev), MINOR(__entry->dev),
232 		  __entry->mflags,
233 		  __print_flags(__entry->opstate, "|", XFS_OPSTATE_STRINGS),
234 		  __entry->sbflags,
235 		  __entry->caller_ip)
236 );
237 
238 #define DEFINE_FS_EVENT(name)	\
239 DEFINE_EVENT(xfs_fs_class, name,					\
240 	TP_PROTO(struct xfs_mount *mp, void *caller_ip), \
241 	TP_ARGS(mp, caller_ip))
242 DEFINE_FS_EVENT(xfs_inodegc_flush);
243 DEFINE_FS_EVENT(xfs_inodegc_start);
244 DEFINE_FS_EVENT(xfs_inodegc_stop);
245 DEFINE_FS_EVENT(xfs_inodegc_queue);
246 DEFINE_FS_EVENT(xfs_inodegc_throttle);
247 DEFINE_FS_EVENT(xfs_fs_sync_fs);
248 DEFINE_FS_EVENT(xfs_blockgc_start);
249 DEFINE_FS_EVENT(xfs_blockgc_stop);
250 DEFINE_FS_EVENT(xfs_blockgc_worker);
251 DEFINE_FS_EVENT(xfs_blockgc_flush_all);
252 
253 TRACE_EVENT(xfs_inodegc_shrinker_scan,
254 	TP_PROTO(struct xfs_mount *mp, struct shrink_control *sc,
255 		 void *caller_ip),
256 	TP_ARGS(mp, sc, caller_ip),
257 	TP_STRUCT__entry(
258 		__field(dev_t, dev)
259 		__field(unsigned long, nr_to_scan)
260 		__field(void *, caller_ip)
261 	),
262 	TP_fast_assign(
263 		__entry->dev = mp->m_super->s_dev;
264 		__entry->nr_to_scan = sc->nr_to_scan;
265 		__entry->caller_ip = caller_ip;
266 	),
267 	TP_printk("dev %d:%d nr_to_scan %lu caller %pS",
268 		  MAJOR(__entry->dev), MINOR(__entry->dev),
269 		  __entry->nr_to_scan,
270 		  __entry->caller_ip)
271 );
272 
273 DECLARE_EVENT_CLASS(xfs_ag_class,
274 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno),
275 	TP_ARGS(mp, agno),
276 	TP_STRUCT__entry(
277 		__field(dev_t, dev)
278 		__field(xfs_agnumber_t, agno)
279 	),
280 	TP_fast_assign(
281 		__entry->dev = mp->m_super->s_dev;
282 		__entry->agno = agno;
283 	),
284 	TP_printk("dev %d:%d agno 0x%x",
285 		  MAJOR(__entry->dev), MINOR(__entry->dev),
286 		  __entry->agno)
287 );
288 #define DEFINE_AG_EVENT(name)	\
289 DEFINE_EVENT(xfs_ag_class, name,	\
290 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno),	\
291 	TP_ARGS(mp, agno))
292 
293 DEFINE_AG_EVENT(xfs_read_agf);
294 DEFINE_AG_EVENT(xfs_alloc_read_agf);
295 DEFINE_AG_EVENT(xfs_read_agi);
296 DEFINE_AG_EVENT(xfs_ialloc_read_agi);
297 
298 TRACE_EVENT(xfs_attr_list_node_descend,
299 	TP_PROTO(struct xfs_attr_list_context *ctx,
300 		 struct xfs_da_node_entry *btree),
301 	TP_ARGS(ctx, btree),
302 	TP_STRUCT__entry(
303 		__field(dev_t, dev)
304 		__field(xfs_ino_t, ino)
305 		__field(u32, hashval)
306 		__field(u32, blkno)
307 		__field(u32, offset)
308 		__field(void *, buffer)
309 		__field(int, bufsize)
310 		__field(int, count)
311 		__field(int, firstu)
312 		__field(int, dupcnt)
313 		__field(unsigned int, attr_filter)
314 		__field(u32, bt_hashval)
315 		__field(u32, bt_before)
316 	),
317 	TP_fast_assign(
318 		__entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
319 		__entry->ino = ctx->dp->i_ino;
320 		__entry->hashval = ctx->cursor.hashval;
321 		__entry->blkno = ctx->cursor.blkno;
322 		__entry->offset = ctx->cursor.offset;
323 		__entry->buffer = ctx->buffer;
324 		__entry->bufsize = ctx->bufsize;
325 		__entry->count = ctx->count;
326 		__entry->firstu = ctx->firstu;
327 		__entry->attr_filter = ctx->attr_filter;
328 		__entry->bt_hashval = be32_to_cpu(btree->hashval);
329 		__entry->bt_before = be32_to_cpu(btree->before);
330 	),
331 	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
332 		  "buffer %p size %u count %u firstu %u filter %s "
333 		  "node hashval %u, node before %u",
334 		  MAJOR(__entry->dev), MINOR(__entry->dev),
335 		   __entry->ino,
336 		   __entry->hashval,
337 		   __entry->blkno,
338 		   __entry->offset,
339 		   __entry->dupcnt,
340 		   __entry->buffer,
341 		   __entry->bufsize,
342 		   __entry->count,
343 		   __entry->firstu,
344 		   __print_flags(__entry->attr_filter, "|",
345 				 XFS_ATTR_FILTER_FLAGS),
346 		   __entry->bt_hashval,
347 		   __entry->bt_before)
348 );
349 
350 DECLARE_EVENT_CLASS(xfs_bmap_class,
351 	TP_PROTO(struct xfs_inode *ip, struct xfs_iext_cursor *cur, int state,
352 		 unsigned long caller_ip),
353 	TP_ARGS(ip, cur, state, caller_ip),
354 	TP_STRUCT__entry(
355 		__field(dev_t, dev)
356 		__field(xfs_ino_t, ino)
357 		__field(void *, leaf)
358 		__field(int, pos)
359 		__field(xfs_fileoff_t, startoff)
360 		__field(xfs_fsblock_t, startblock)
361 		__field(xfs_filblks_t, blockcount)
362 		__field(xfs_exntst_t, state)
363 		__field(int, bmap_state)
364 		__field(unsigned long, caller_ip)
365 	),
366 	TP_fast_assign(
367 		struct xfs_ifork	*ifp;
368 		struct xfs_bmbt_irec	r;
369 
370 		ifp = xfs_iext_state_to_fork(ip, state);
371 		xfs_iext_get_extent(ifp, cur, &r);
372 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
373 		__entry->ino = ip->i_ino;
374 		__entry->leaf = cur->leaf;
375 		__entry->pos = cur->pos;
376 		__entry->startoff = r.br_startoff;
377 		__entry->startblock = r.br_startblock;
378 		__entry->blockcount = r.br_blockcount;
379 		__entry->state = r.br_state;
380 		__entry->bmap_state = state;
381 		__entry->caller_ip = caller_ip;
382 	),
383 	TP_printk("dev %d:%d ino 0x%llx state %s cur %p/%d "
384 		  "fileoff 0x%llx startblock 0x%llx fsbcount 0x%llx flag %d caller %pS",
385 		  MAJOR(__entry->dev), MINOR(__entry->dev),
386 		  __entry->ino,
387 		  __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS),
388 		  __entry->leaf,
389 		  __entry->pos,
390 		  __entry->startoff,
391 		  (int64_t)__entry->startblock,
392 		  __entry->blockcount,
393 		  __entry->state,
394 		  (char *)__entry->caller_ip)
395 )
396 
397 #define DEFINE_BMAP_EVENT(name) \
398 DEFINE_EVENT(xfs_bmap_class, name, \
399 	TP_PROTO(struct xfs_inode *ip, struct xfs_iext_cursor *cur, int state, \
400 		 unsigned long caller_ip), \
401 	TP_ARGS(ip, cur, state, caller_ip))
402 DEFINE_BMAP_EVENT(xfs_iext_insert);
403 DEFINE_BMAP_EVENT(xfs_iext_remove);
404 DEFINE_BMAP_EVENT(xfs_bmap_pre_update);
405 DEFINE_BMAP_EVENT(xfs_bmap_post_update);
406 DEFINE_BMAP_EVENT(xfs_read_extent);
407 DEFINE_BMAP_EVENT(xfs_write_extent);
408 
409 DECLARE_EVENT_CLASS(xfs_buf_class,
410 	TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip),
411 	TP_ARGS(bp, caller_ip),
412 	TP_STRUCT__entry(
413 		__field(dev_t, dev)
414 		__field(xfs_daddr_t, bno)
415 		__field(int, nblks)
416 		__field(int, hold)
417 		__field(int, pincount)
418 		__field(unsigned, lockval)
419 		__field(unsigned, flags)
420 		__field(unsigned long, caller_ip)
421 	),
422 	TP_fast_assign(
423 		__entry->dev = bp->b_target->bt_dev;
424 		__entry->bno = xfs_buf_daddr(bp);
425 		__entry->nblks = bp->b_length;
426 		__entry->hold = atomic_read(&bp->b_hold);
427 		__entry->pincount = atomic_read(&bp->b_pin_count);
428 		__entry->lockval = bp->b_sema.count;
429 		__entry->flags = bp->b_flags;
430 		__entry->caller_ip = caller_ip;
431 	),
432 	TP_printk("dev %d:%d daddr 0x%llx bbcount 0x%x hold %d pincount %d "
433 		  "lock %d flags %s caller %pS",
434 		  MAJOR(__entry->dev), MINOR(__entry->dev),
435 		  (unsigned long long)__entry->bno,
436 		  __entry->nblks,
437 		  __entry->hold,
438 		  __entry->pincount,
439 		  __entry->lockval,
440 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
441 		  (void *)__entry->caller_ip)
442 )
443 
444 #define DEFINE_BUF_EVENT(name) \
445 DEFINE_EVENT(xfs_buf_class, name, \
446 	TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip), \
447 	TP_ARGS(bp, caller_ip))
448 DEFINE_BUF_EVENT(xfs_buf_init);
449 DEFINE_BUF_EVENT(xfs_buf_free);
450 DEFINE_BUF_EVENT(xfs_buf_hold);
451 DEFINE_BUF_EVENT(xfs_buf_rele);
452 DEFINE_BUF_EVENT(xfs_buf_iodone);
453 DEFINE_BUF_EVENT(xfs_buf_submit);
454 DEFINE_BUF_EVENT(xfs_buf_lock);
455 DEFINE_BUF_EVENT(xfs_buf_lock_done);
456 DEFINE_BUF_EVENT(xfs_buf_trylock_fail);
457 DEFINE_BUF_EVENT(xfs_buf_trylock);
458 DEFINE_BUF_EVENT(xfs_buf_unlock);
459 DEFINE_BUF_EVENT(xfs_buf_iowait);
460 DEFINE_BUF_EVENT(xfs_buf_iowait_done);
461 DEFINE_BUF_EVENT(xfs_buf_delwri_queue);
462 DEFINE_BUF_EVENT(xfs_buf_delwri_queued);
463 DEFINE_BUF_EVENT(xfs_buf_delwri_split);
464 DEFINE_BUF_EVENT(xfs_buf_delwri_pushbuf);
465 DEFINE_BUF_EVENT(xfs_buf_get_uncached);
466 DEFINE_BUF_EVENT(xfs_buf_item_relse);
467 DEFINE_BUF_EVENT(xfs_buf_iodone_async);
468 DEFINE_BUF_EVENT(xfs_buf_error_relse);
469 DEFINE_BUF_EVENT(xfs_buf_drain_buftarg);
470 DEFINE_BUF_EVENT(xfs_trans_read_buf_shut);
471 
472 /* not really buffer traces, but the buf provides useful information */
473 DEFINE_BUF_EVENT(xfs_btree_corrupt);
474 DEFINE_BUF_EVENT(xfs_reset_dqcounts);
475 
476 /* pass flags explicitly */
477 DECLARE_EVENT_CLASS(xfs_buf_flags_class,
478 	TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip),
479 	TP_ARGS(bp, flags, caller_ip),
480 	TP_STRUCT__entry(
481 		__field(dev_t, dev)
482 		__field(xfs_daddr_t, bno)
483 		__field(unsigned int, length)
484 		__field(int, hold)
485 		__field(int, pincount)
486 		__field(unsigned, lockval)
487 		__field(unsigned, flags)
488 		__field(unsigned long, caller_ip)
489 	),
490 	TP_fast_assign(
491 		__entry->dev = bp->b_target->bt_dev;
492 		__entry->bno = xfs_buf_daddr(bp);
493 		__entry->length = bp->b_length;
494 		__entry->flags = flags;
495 		__entry->hold = atomic_read(&bp->b_hold);
496 		__entry->pincount = atomic_read(&bp->b_pin_count);
497 		__entry->lockval = bp->b_sema.count;
498 		__entry->caller_ip = caller_ip;
499 	),
500 	TP_printk("dev %d:%d daddr 0x%llx bbcount 0x%x hold %d pincount %d "
501 		  "lock %d flags %s caller %pS",
502 		  MAJOR(__entry->dev), MINOR(__entry->dev),
503 		  (unsigned long long)__entry->bno,
504 		  __entry->length,
505 		  __entry->hold,
506 		  __entry->pincount,
507 		  __entry->lockval,
508 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
509 		  (void *)__entry->caller_ip)
510 )
511 
512 #define DEFINE_BUF_FLAGS_EVENT(name) \
513 DEFINE_EVENT(xfs_buf_flags_class, name, \
514 	TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip), \
515 	TP_ARGS(bp, flags, caller_ip))
516 DEFINE_BUF_FLAGS_EVENT(xfs_buf_find);
517 DEFINE_BUF_FLAGS_EVENT(xfs_buf_get);
518 DEFINE_BUF_FLAGS_EVENT(xfs_buf_read);
519 
520 TRACE_EVENT(xfs_buf_ioerror,
521 	TP_PROTO(struct xfs_buf *bp, int error, xfs_failaddr_t caller_ip),
522 	TP_ARGS(bp, error, caller_ip),
523 	TP_STRUCT__entry(
524 		__field(dev_t, dev)
525 		__field(xfs_daddr_t, bno)
526 		__field(unsigned int, length)
527 		__field(unsigned, flags)
528 		__field(int, hold)
529 		__field(int, pincount)
530 		__field(unsigned, lockval)
531 		__field(int, error)
532 		__field(xfs_failaddr_t, caller_ip)
533 	),
534 	TP_fast_assign(
535 		__entry->dev = bp->b_target->bt_dev;
536 		__entry->bno = xfs_buf_daddr(bp);
537 		__entry->length = bp->b_length;
538 		__entry->hold = atomic_read(&bp->b_hold);
539 		__entry->pincount = atomic_read(&bp->b_pin_count);
540 		__entry->lockval = bp->b_sema.count;
541 		__entry->error = error;
542 		__entry->flags = bp->b_flags;
543 		__entry->caller_ip = caller_ip;
544 	),
545 	TP_printk("dev %d:%d daddr 0x%llx bbcount 0x%x hold %d pincount %d "
546 		  "lock %d error %d flags %s caller %pS",
547 		  MAJOR(__entry->dev), MINOR(__entry->dev),
548 		  (unsigned long long)__entry->bno,
549 		  __entry->length,
550 		  __entry->hold,
551 		  __entry->pincount,
552 		  __entry->lockval,
553 		  __entry->error,
554 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
555 		  (void *)__entry->caller_ip)
556 );
557 
558 DECLARE_EVENT_CLASS(xfs_buf_item_class,
559 	TP_PROTO(struct xfs_buf_log_item *bip),
560 	TP_ARGS(bip),
561 	TP_STRUCT__entry(
562 		__field(dev_t, dev)
563 		__field(xfs_daddr_t, buf_bno)
564 		__field(unsigned int, buf_len)
565 		__field(int, buf_hold)
566 		__field(int, buf_pincount)
567 		__field(int, buf_lockval)
568 		__field(unsigned, buf_flags)
569 		__field(unsigned, bli_recur)
570 		__field(int, bli_refcount)
571 		__field(unsigned, bli_flags)
572 		__field(unsigned long, li_flags)
573 	),
574 	TP_fast_assign(
575 		__entry->dev = bip->bli_buf->b_target->bt_dev;
576 		__entry->bli_flags = bip->bli_flags;
577 		__entry->bli_recur = bip->bli_recur;
578 		__entry->bli_refcount = atomic_read(&bip->bli_refcount);
579 		__entry->buf_bno = xfs_buf_daddr(bip->bli_buf);
580 		__entry->buf_len = bip->bli_buf->b_length;
581 		__entry->buf_flags = bip->bli_buf->b_flags;
582 		__entry->buf_hold = atomic_read(&bip->bli_buf->b_hold);
583 		__entry->buf_pincount = atomic_read(&bip->bli_buf->b_pin_count);
584 		__entry->buf_lockval = bip->bli_buf->b_sema.count;
585 		__entry->li_flags = bip->bli_item.li_flags;
586 	),
587 	TP_printk("dev %d:%d daddr 0x%llx bbcount 0x%x hold %d pincount %d "
588 		  "lock %d flags %s recur %d refcount %d bliflags %s "
589 		  "liflags %s",
590 		  MAJOR(__entry->dev), MINOR(__entry->dev),
591 		  (unsigned long long)__entry->buf_bno,
592 		  __entry->buf_len,
593 		  __entry->buf_hold,
594 		  __entry->buf_pincount,
595 		  __entry->buf_lockval,
596 		  __print_flags(__entry->buf_flags, "|", XFS_BUF_FLAGS),
597 		  __entry->bli_recur,
598 		  __entry->bli_refcount,
599 		  __print_flags(__entry->bli_flags, "|", XFS_BLI_FLAGS),
600 		  __print_flags(__entry->li_flags, "|", XFS_LI_FLAGS))
601 )
602 
603 #define DEFINE_BUF_ITEM_EVENT(name) \
604 DEFINE_EVENT(xfs_buf_item_class, name, \
605 	TP_PROTO(struct xfs_buf_log_item *bip), \
606 	TP_ARGS(bip))
607 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size);
608 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_ordered);
609 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale);
610 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format);
611 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale);
612 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_ordered);
613 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
614 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin);
615 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale);
616 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_release);
617 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed);
618 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push);
619 DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf);
620 DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf_recur);
621 DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb);
622 DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb_recur);
623 DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf);
624 DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf_recur);
625 DEFINE_BUF_ITEM_EVENT(xfs_trans_log_buf);
626 DEFINE_BUF_ITEM_EVENT(xfs_trans_brelse);
627 DEFINE_BUF_ITEM_EVENT(xfs_trans_bjoin);
628 DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold);
629 DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release);
630 DEFINE_BUF_ITEM_EVENT(xfs_trans_binval);
631 
632 DECLARE_EVENT_CLASS(xfs_filestream_class,
633 	TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino, xfs_agnumber_t agno),
634 	TP_ARGS(mp, ino, agno),
635 	TP_STRUCT__entry(
636 		__field(dev_t, dev)
637 		__field(xfs_ino_t, ino)
638 		__field(xfs_agnumber_t, agno)
639 		__field(int, streams)
640 	),
641 	TP_fast_assign(
642 		__entry->dev = mp->m_super->s_dev;
643 		__entry->ino = ino;
644 		__entry->agno = agno;
645 		__entry->streams = xfs_filestream_peek_ag(mp, agno);
646 	),
647 	TP_printk("dev %d:%d ino 0x%llx agno 0x%x streams %d",
648 		  MAJOR(__entry->dev), MINOR(__entry->dev),
649 		  __entry->ino,
650 		  __entry->agno,
651 		  __entry->streams)
652 )
653 #define DEFINE_FILESTREAM_EVENT(name) \
654 DEFINE_EVENT(xfs_filestream_class, name, \
655 	TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino, xfs_agnumber_t agno), \
656 	TP_ARGS(mp, ino, agno))
657 DEFINE_FILESTREAM_EVENT(xfs_filestream_free);
658 DEFINE_FILESTREAM_EVENT(xfs_filestream_lookup);
659 DEFINE_FILESTREAM_EVENT(xfs_filestream_scan);
660 
661 TRACE_EVENT(xfs_filestream_pick,
662 	TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno,
663 		 xfs_extlen_t free, int nscan),
664 	TP_ARGS(ip, agno, free, nscan),
665 	TP_STRUCT__entry(
666 		__field(dev_t, dev)
667 		__field(xfs_ino_t, ino)
668 		__field(xfs_agnumber_t, agno)
669 		__field(int, streams)
670 		__field(xfs_extlen_t, free)
671 		__field(int, nscan)
672 	),
673 	TP_fast_assign(
674 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
675 		__entry->ino = ip->i_ino;
676 		__entry->agno = agno;
677 		__entry->streams = xfs_filestream_peek_ag(ip->i_mount, agno);
678 		__entry->free = free;
679 		__entry->nscan = nscan;
680 	),
681 	TP_printk("dev %d:%d ino 0x%llx agno 0x%x streams %d free %d nscan %d",
682 		  MAJOR(__entry->dev), MINOR(__entry->dev),
683 		  __entry->ino,
684 		  __entry->agno,
685 		  __entry->streams,
686 		  __entry->free,
687 		  __entry->nscan)
688 );
689 
690 DECLARE_EVENT_CLASS(xfs_lock_class,
691 	TP_PROTO(struct xfs_inode *ip, unsigned lock_flags,
692 		 unsigned long caller_ip),
693 	TP_ARGS(ip,  lock_flags, caller_ip),
694 	TP_STRUCT__entry(
695 		__field(dev_t, dev)
696 		__field(xfs_ino_t, ino)
697 		__field(int, lock_flags)
698 		__field(unsigned long, caller_ip)
699 	),
700 	TP_fast_assign(
701 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
702 		__entry->ino = ip->i_ino;
703 		__entry->lock_flags = lock_flags;
704 		__entry->caller_ip = caller_ip;
705 	),
706 	TP_printk("dev %d:%d ino 0x%llx flags %s caller %pS",
707 		  MAJOR(__entry->dev), MINOR(__entry->dev),
708 		  __entry->ino,
709 		  __print_flags(__entry->lock_flags, "|", XFS_LOCK_FLAGS),
710 		  (void *)__entry->caller_ip)
711 )
712 
713 #define DEFINE_LOCK_EVENT(name) \
714 DEFINE_EVENT(xfs_lock_class, name, \
715 	TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, \
716 		 unsigned long caller_ip), \
717 	TP_ARGS(ip,  lock_flags, caller_ip))
718 DEFINE_LOCK_EVENT(xfs_ilock);
719 DEFINE_LOCK_EVENT(xfs_ilock_nowait);
720 DEFINE_LOCK_EVENT(xfs_ilock_demote);
721 DEFINE_LOCK_EVENT(xfs_iunlock);
722 
723 DECLARE_EVENT_CLASS(xfs_inode_class,
724 	TP_PROTO(struct xfs_inode *ip),
725 	TP_ARGS(ip),
726 	TP_STRUCT__entry(
727 		__field(dev_t, dev)
728 		__field(xfs_ino_t, ino)
729 		__field(unsigned long, iflags)
730 	),
731 	TP_fast_assign(
732 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
733 		__entry->ino = ip->i_ino;
734 		__entry->iflags = ip->i_flags;
735 	),
736 	TP_printk("dev %d:%d ino 0x%llx iflags 0x%lx",
737 		  MAJOR(__entry->dev), MINOR(__entry->dev),
738 		  __entry->ino,
739 		  __entry->iflags)
740 )
741 
742 #define DEFINE_INODE_EVENT(name) \
743 DEFINE_EVENT(xfs_inode_class, name, \
744 	TP_PROTO(struct xfs_inode *ip), \
745 	TP_ARGS(ip))
746 DEFINE_INODE_EVENT(xfs_iget_skip);
747 DEFINE_INODE_EVENT(xfs_iget_recycle);
748 DEFINE_INODE_EVENT(xfs_iget_recycle_fail);
749 DEFINE_INODE_EVENT(xfs_iget_hit);
750 DEFINE_INODE_EVENT(xfs_iget_miss);
751 
752 DEFINE_INODE_EVENT(xfs_getattr);
753 DEFINE_INODE_EVENT(xfs_setattr);
754 DEFINE_INODE_EVENT(xfs_readlink);
755 DEFINE_INODE_EVENT(xfs_inactive_symlink);
756 DEFINE_INODE_EVENT(xfs_alloc_file_space);
757 DEFINE_INODE_EVENT(xfs_free_file_space);
758 DEFINE_INODE_EVENT(xfs_zero_file_space);
759 DEFINE_INODE_EVENT(xfs_collapse_file_space);
760 DEFINE_INODE_EVENT(xfs_insert_file_space);
761 DEFINE_INODE_EVENT(xfs_readdir);
762 #ifdef CONFIG_XFS_POSIX_ACL
763 DEFINE_INODE_EVENT(xfs_get_acl);
764 #endif
765 DEFINE_INODE_EVENT(xfs_vm_bmap);
766 DEFINE_INODE_EVENT(xfs_file_ioctl);
767 DEFINE_INODE_EVENT(xfs_file_compat_ioctl);
768 DEFINE_INODE_EVENT(xfs_ioctl_setattr);
769 DEFINE_INODE_EVENT(xfs_dir_fsync);
770 DEFINE_INODE_EVENT(xfs_file_fsync);
771 DEFINE_INODE_EVENT(xfs_destroy_inode);
772 DEFINE_INODE_EVENT(xfs_update_time);
773 
774 DEFINE_INODE_EVENT(xfs_dquot_dqalloc);
775 DEFINE_INODE_EVENT(xfs_dquot_dqdetach);
776 
777 DEFINE_INODE_EVENT(xfs_inode_set_eofblocks_tag);
778 DEFINE_INODE_EVENT(xfs_inode_clear_eofblocks_tag);
779 DEFINE_INODE_EVENT(xfs_inode_free_eofblocks_invalid);
780 DEFINE_INODE_EVENT(xfs_inode_set_cowblocks_tag);
781 DEFINE_INODE_EVENT(xfs_inode_clear_cowblocks_tag);
782 DEFINE_INODE_EVENT(xfs_inode_free_cowblocks_invalid);
783 DEFINE_INODE_EVENT(xfs_inode_set_reclaimable);
784 DEFINE_INODE_EVENT(xfs_inode_reclaiming);
785 DEFINE_INODE_EVENT(xfs_inode_set_need_inactive);
786 DEFINE_INODE_EVENT(xfs_inode_inactivating);
787 
788 /*
789  * ftrace's __print_symbolic requires that all enum values be wrapped in the
790  * TRACE_DEFINE_ENUM macro so that the enum value can be encoded in the ftrace
791  * ring buffer.  Somehow this was only worth mentioning in the ftrace sample
792  * code.
793  */
794 TRACE_DEFINE_ENUM(PE_SIZE_PTE);
795 TRACE_DEFINE_ENUM(PE_SIZE_PMD);
796 TRACE_DEFINE_ENUM(PE_SIZE_PUD);
797 
798 TRACE_EVENT(xfs_filemap_fault,
799 	TP_PROTO(struct xfs_inode *ip, enum page_entry_size pe_size,
800 		 bool write_fault),
801 	TP_ARGS(ip, pe_size, write_fault),
802 	TP_STRUCT__entry(
803 		__field(dev_t, dev)
804 		__field(xfs_ino_t, ino)
805 		__field(enum page_entry_size, pe_size)
806 		__field(bool, write_fault)
807 	),
808 	TP_fast_assign(
809 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
810 		__entry->ino = ip->i_ino;
811 		__entry->pe_size = pe_size;
812 		__entry->write_fault = write_fault;
813 	),
814 	TP_printk("dev %d:%d ino 0x%llx %s write_fault %d",
815 		  MAJOR(__entry->dev), MINOR(__entry->dev),
816 		  __entry->ino,
817 		  __print_symbolic(__entry->pe_size,
818 			{ PE_SIZE_PTE,	"PTE" },
819 			{ PE_SIZE_PMD,	"PMD" },
820 			{ PE_SIZE_PUD,	"PUD" }),
821 		  __entry->write_fault)
822 )
823 
824 DECLARE_EVENT_CLASS(xfs_iref_class,
825 	TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip),
826 	TP_ARGS(ip, caller_ip),
827 	TP_STRUCT__entry(
828 		__field(dev_t, dev)
829 		__field(xfs_ino_t, ino)
830 		__field(int, count)
831 		__field(int, pincount)
832 		__field(unsigned long, caller_ip)
833 	),
834 	TP_fast_assign(
835 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
836 		__entry->ino = ip->i_ino;
837 		__entry->count = atomic_read(&VFS_I(ip)->i_count);
838 		__entry->pincount = atomic_read(&ip->i_pincount);
839 		__entry->caller_ip = caller_ip;
840 	),
841 	TP_printk("dev %d:%d ino 0x%llx count %d pincount %d caller %pS",
842 		  MAJOR(__entry->dev), MINOR(__entry->dev),
843 		  __entry->ino,
844 		  __entry->count,
845 		  __entry->pincount,
846 		  (char *)__entry->caller_ip)
847 )
848 
849 TRACE_EVENT(xfs_iomap_prealloc_size,
850 	TP_PROTO(struct xfs_inode *ip, xfs_fsblock_t blocks, int shift,
851 		 unsigned int writeio_blocks),
852 	TP_ARGS(ip, blocks, shift, writeio_blocks),
853 	TP_STRUCT__entry(
854 		__field(dev_t, dev)
855 		__field(xfs_ino_t, ino)
856 		__field(xfs_fsblock_t, blocks)
857 		__field(int, shift)
858 		__field(unsigned int, writeio_blocks)
859 	),
860 	TP_fast_assign(
861 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
862 		__entry->ino = ip->i_ino;
863 		__entry->blocks = blocks;
864 		__entry->shift = shift;
865 		__entry->writeio_blocks = writeio_blocks;
866 	),
867 	TP_printk("dev %d:%d ino 0x%llx prealloc blocks %llu shift %d "
868 		  "m_allocsize_blocks %u",
869 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino,
870 		  __entry->blocks, __entry->shift, __entry->writeio_blocks)
871 )
872 
873 TRACE_EVENT(xfs_irec_merge_pre,
874 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
875 		 uint16_t holemask, xfs_agino_t nagino, uint16_t nholemask),
876 	TP_ARGS(mp, agno, agino, holemask, nagino, nholemask),
877 	TP_STRUCT__entry(
878 		__field(dev_t, dev)
879 		__field(xfs_agnumber_t, agno)
880 		__field(xfs_agino_t, agino)
881 		__field(uint16_t, holemask)
882 		__field(xfs_agino_t, nagino)
883 		__field(uint16_t, nholemask)
884 	),
885 	TP_fast_assign(
886 		__entry->dev = mp->m_super->s_dev;
887 		__entry->agno = agno;
888 		__entry->agino = agino;
889 		__entry->holemask = holemask;
890 		__entry->nagino = nagino;
891 		__entry->nholemask = holemask;
892 	),
893 	TP_printk("dev %d:%d agno 0x%x agino 0x%x holemask 0x%x new_agino 0x%x new_holemask 0x%x",
894 		  MAJOR(__entry->dev), MINOR(__entry->dev),
895 		  __entry->agno,
896 		  __entry->agino,
897 		  __entry->holemask,
898 		  __entry->nagino,
899 		  __entry->nholemask)
900 )
901 
902 TRACE_EVENT(xfs_irec_merge_post,
903 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
904 		 uint16_t holemask),
905 	TP_ARGS(mp, agno, agino, holemask),
906 	TP_STRUCT__entry(
907 		__field(dev_t, dev)
908 		__field(xfs_agnumber_t, agno)
909 		__field(xfs_agino_t, agino)
910 		__field(uint16_t, holemask)
911 	),
912 	TP_fast_assign(
913 		__entry->dev = mp->m_super->s_dev;
914 		__entry->agno = agno;
915 		__entry->agino = agino;
916 		__entry->holemask = holemask;
917 	),
918 	TP_printk("dev %d:%d agno 0x%x agino 0x%x holemask 0x%x",
919 		  MAJOR(__entry->dev),
920 		  MINOR(__entry->dev),
921 		  __entry->agno,
922 		  __entry->agino,
923 		  __entry->holemask)
924 )
925 
926 #define DEFINE_IREF_EVENT(name) \
927 DEFINE_EVENT(xfs_iref_class, name, \
928 	TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \
929 	TP_ARGS(ip, caller_ip))
930 DEFINE_IREF_EVENT(xfs_irele);
931 DEFINE_IREF_EVENT(xfs_inode_pin);
932 DEFINE_IREF_EVENT(xfs_inode_unpin);
933 DEFINE_IREF_EVENT(xfs_inode_unpin_nowait);
934 
935 DECLARE_EVENT_CLASS(xfs_namespace_class,
936 	TP_PROTO(struct xfs_inode *dp, const struct xfs_name *name),
937 	TP_ARGS(dp, name),
938 	TP_STRUCT__entry(
939 		__field(dev_t, dev)
940 		__field(xfs_ino_t, dp_ino)
941 		__field(int, namelen)
942 		__dynamic_array(char, name, name->len)
943 	),
944 	TP_fast_assign(
945 		__entry->dev = VFS_I(dp)->i_sb->s_dev;
946 		__entry->dp_ino = dp->i_ino;
947 		__entry->namelen = name->len;
948 		memcpy(__get_str(name), name->name, name->len);
949 	),
950 	TP_printk("dev %d:%d dp ino 0x%llx name %.*s",
951 		  MAJOR(__entry->dev), MINOR(__entry->dev),
952 		  __entry->dp_ino,
953 		  __entry->namelen,
954 		  __get_str(name))
955 )
956 
957 #define DEFINE_NAMESPACE_EVENT(name) \
958 DEFINE_EVENT(xfs_namespace_class, name, \
959 	TP_PROTO(struct xfs_inode *dp, const struct xfs_name *name), \
960 	TP_ARGS(dp, name))
961 DEFINE_NAMESPACE_EVENT(xfs_remove);
962 DEFINE_NAMESPACE_EVENT(xfs_link);
963 DEFINE_NAMESPACE_EVENT(xfs_lookup);
964 DEFINE_NAMESPACE_EVENT(xfs_create);
965 DEFINE_NAMESPACE_EVENT(xfs_symlink);
966 
967 TRACE_EVENT(xfs_rename,
968 	TP_PROTO(struct xfs_inode *src_dp, struct xfs_inode *target_dp,
969 		 struct xfs_name *src_name, struct xfs_name *target_name),
970 	TP_ARGS(src_dp, target_dp, src_name, target_name),
971 	TP_STRUCT__entry(
972 		__field(dev_t, dev)
973 		__field(xfs_ino_t, src_dp_ino)
974 		__field(xfs_ino_t, target_dp_ino)
975 		__field(int, src_namelen)
976 		__field(int, target_namelen)
977 		__dynamic_array(char, src_name, src_name->len)
978 		__dynamic_array(char, target_name, target_name->len)
979 	),
980 	TP_fast_assign(
981 		__entry->dev = VFS_I(src_dp)->i_sb->s_dev;
982 		__entry->src_dp_ino = src_dp->i_ino;
983 		__entry->target_dp_ino = target_dp->i_ino;
984 		__entry->src_namelen = src_name->len;
985 		__entry->target_namelen = target_name->len;
986 		memcpy(__get_str(src_name), src_name->name, src_name->len);
987 		memcpy(__get_str(target_name), target_name->name,
988 			target_name->len);
989 	),
990 	TP_printk("dev %d:%d src dp ino 0x%llx target dp ino 0x%llx"
991 		  " src name %.*s target name %.*s",
992 		  MAJOR(__entry->dev), MINOR(__entry->dev),
993 		  __entry->src_dp_ino,
994 		  __entry->target_dp_ino,
995 		  __entry->src_namelen,
996 		  __get_str(src_name),
997 		  __entry->target_namelen,
998 		  __get_str(target_name))
999 )
1000 
1001 DECLARE_EVENT_CLASS(xfs_dquot_class,
1002 	TP_PROTO(struct xfs_dquot *dqp),
1003 	TP_ARGS(dqp),
1004 	TP_STRUCT__entry(
1005 		__field(dev_t, dev)
1006 		__field(u32, id)
1007 		__field(xfs_dqtype_t, type)
1008 		__field(unsigned, flags)
1009 		__field(unsigned, nrefs)
1010 		__field(unsigned long long, res_bcount)
1011 		__field(unsigned long long, res_rtbcount)
1012 		__field(unsigned long long, res_icount)
1013 
1014 		__field(unsigned long long, bcount)
1015 		__field(unsigned long long, rtbcount)
1016 		__field(unsigned long long, icount)
1017 
1018 		__field(unsigned long long, blk_hardlimit)
1019 		__field(unsigned long long, blk_softlimit)
1020 		__field(unsigned long long, rtb_hardlimit)
1021 		__field(unsigned long long, rtb_softlimit)
1022 		__field(unsigned long long, ino_hardlimit)
1023 		__field(unsigned long long, ino_softlimit)
1024 	),
1025 	TP_fast_assign(
1026 		__entry->dev = dqp->q_mount->m_super->s_dev;
1027 		__entry->id = dqp->q_id;
1028 		__entry->type = dqp->q_type;
1029 		__entry->flags = dqp->q_flags;
1030 		__entry->nrefs = dqp->q_nrefs;
1031 
1032 		__entry->res_bcount = dqp->q_blk.reserved;
1033 		__entry->res_rtbcount = dqp->q_rtb.reserved;
1034 		__entry->res_icount = dqp->q_ino.reserved;
1035 
1036 		__entry->bcount = dqp->q_blk.count;
1037 		__entry->rtbcount = dqp->q_rtb.count;
1038 		__entry->icount = dqp->q_ino.count;
1039 
1040 		__entry->blk_hardlimit = dqp->q_blk.hardlimit;
1041 		__entry->blk_softlimit = dqp->q_blk.softlimit;
1042 		__entry->rtb_hardlimit = dqp->q_rtb.hardlimit;
1043 		__entry->rtb_softlimit = dqp->q_rtb.softlimit;
1044 		__entry->ino_hardlimit = dqp->q_ino.hardlimit;
1045 		__entry->ino_softlimit = dqp->q_ino.softlimit;
1046 	),
1047 	TP_printk("dev %d:%d id 0x%x type %s flags %s nrefs %u "
1048 		  "res_bc 0x%llx res_rtbc 0x%llx res_ic 0x%llx "
1049 		  "bcnt 0x%llx bhardlimit 0x%llx bsoftlimit 0x%llx "
1050 		  "rtbcnt 0x%llx rtbhardlimit 0x%llx rtbsoftlimit 0x%llx "
1051 		  "icnt 0x%llx ihardlimit 0x%llx isoftlimit 0x%llx]",
1052 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1053 		  __entry->id,
1054 		  __print_flags(__entry->type, "|", XFS_DQTYPE_STRINGS),
1055 		  __print_flags(__entry->flags, "|", XFS_DQFLAG_STRINGS),
1056 		  __entry->nrefs,
1057 		  __entry->res_bcount,
1058 		  __entry->res_rtbcount,
1059 		  __entry->res_icount,
1060 		  __entry->bcount,
1061 		  __entry->blk_hardlimit,
1062 		  __entry->blk_softlimit,
1063 		  __entry->rtbcount,
1064 		  __entry->rtb_hardlimit,
1065 		  __entry->rtb_softlimit,
1066 		  __entry->icount,
1067 		  __entry->ino_hardlimit,
1068 		  __entry->ino_softlimit)
1069 )
1070 
1071 #define DEFINE_DQUOT_EVENT(name) \
1072 DEFINE_EVENT(xfs_dquot_class, name, \
1073 	TP_PROTO(struct xfs_dquot *dqp), \
1074 	TP_ARGS(dqp))
1075 DEFINE_DQUOT_EVENT(xfs_dqadjust);
1076 DEFINE_DQUOT_EVENT(xfs_dqreclaim_want);
1077 DEFINE_DQUOT_EVENT(xfs_dqreclaim_dirty);
1078 DEFINE_DQUOT_EVENT(xfs_dqreclaim_busy);
1079 DEFINE_DQUOT_EVENT(xfs_dqreclaim_done);
1080 DEFINE_DQUOT_EVENT(xfs_dqattach_found);
1081 DEFINE_DQUOT_EVENT(xfs_dqattach_get);
1082 DEFINE_DQUOT_EVENT(xfs_dqalloc);
1083 DEFINE_DQUOT_EVENT(xfs_dqtobp_read);
1084 DEFINE_DQUOT_EVENT(xfs_dqread);
1085 DEFINE_DQUOT_EVENT(xfs_dqread_fail);
1086 DEFINE_DQUOT_EVENT(xfs_dqget_hit);
1087 DEFINE_DQUOT_EVENT(xfs_dqget_miss);
1088 DEFINE_DQUOT_EVENT(xfs_dqget_freeing);
1089 DEFINE_DQUOT_EVENT(xfs_dqget_dup);
1090 DEFINE_DQUOT_EVENT(xfs_dqput);
1091 DEFINE_DQUOT_EVENT(xfs_dqput_free);
1092 DEFINE_DQUOT_EVENT(xfs_dqrele);
1093 DEFINE_DQUOT_EVENT(xfs_dqflush);
1094 DEFINE_DQUOT_EVENT(xfs_dqflush_force);
1095 DEFINE_DQUOT_EVENT(xfs_dqflush_done);
1096 DEFINE_DQUOT_EVENT(xfs_trans_apply_dquot_deltas_before);
1097 DEFINE_DQUOT_EVENT(xfs_trans_apply_dquot_deltas_after);
1098 
1099 #define XFS_QMOPT_FLAGS \
1100 	{ XFS_QMOPT_UQUOTA,		"UQUOTA" }, \
1101 	{ XFS_QMOPT_PQUOTA,		"PQUOTA" }, \
1102 	{ XFS_QMOPT_FORCE_RES,		"FORCE_RES" }, \
1103 	{ XFS_QMOPT_SBVERSION,		"SBVERSION" }, \
1104 	{ XFS_QMOPT_GQUOTA,		"GQUOTA" }, \
1105 	{ XFS_QMOPT_INHERIT,		"INHERIT" }, \
1106 	{ XFS_QMOPT_RES_REGBLKS,	"RES_REGBLKS" }, \
1107 	{ XFS_QMOPT_RES_RTBLKS,		"RES_RTBLKS" }, \
1108 	{ XFS_QMOPT_BCOUNT,		"BCOUNT" }, \
1109 	{ XFS_QMOPT_ICOUNT,		"ICOUNT" }, \
1110 	{ XFS_QMOPT_RTBCOUNT,		"RTBCOUNT" }, \
1111 	{ XFS_QMOPT_DELBCOUNT,		"DELBCOUNT" }, \
1112 	{ XFS_QMOPT_DELRTBCOUNT,	"DELRTBCOUNT" }, \
1113 	{ XFS_QMOPT_RES_INOS,		"RES_INOS" }
1114 
1115 TRACE_EVENT(xfs_trans_mod_dquot,
1116 	TP_PROTO(struct xfs_trans *tp, struct xfs_dquot *dqp,
1117 		 unsigned int field, int64_t delta),
1118 	TP_ARGS(tp, dqp, field, delta),
1119 	TP_STRUCT__entry(
1120 		__field(dev_t, dev)
1121 		__field(xfs_dqtype_t, type)
1122 		__field(unsigned int, flags)
1123 		__field(unsigned int, dqid)
1124 		__field(unsigned int, field)
1125 		__field(int64_t, delta)
1126 	),
1127 	TP_fast_assign(
1128 		__entry->dev = tp->t_mountp->m_super->s_dev;
1129 		__entry->type = dqp->q_type;
1130 		__entry->flags = dqp->q_flags;
1131 		__entry->dqid = dqp->q_id;
1132 		__entry->field = field;
1133 		__entry->delta = delta;
1134 	),
1135 	TP_printk("dev %d:%d dquot id 0x%x type %s flags %s field %s delta %lld",
1136 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1137 		  __entry->dqid,
1138 		  __print_flags(__entry->type, "|", XFS_DQTYPE_STRINGS),
1139 		  __print_flags(__entry->flags, "|", XFS_DQFLAG_STRINGS),
1140 		  __print_flags(__entry->field, "|", XFS_QMOPT_FLAGS),
1141 		  __entry->delta)
1142 );
1143 
1144 DECLARE_EVENT_CLASS(xfs_dqtrx_class,
1145 	TP_PROTO(struct xfs_dqtrx *qtrx),
1146 	TP_ARGS(qtrx),
1147 	TP_STRUCT__entry(
1148 		__field(dev_t, dev)
1149 		__field(xfs_dqtype_t, type)
1150 		__field(unsigned int, flags)
1151 		__field(u32, dqid)
1152 
1153 		__field(uint64_t, blk_res)
1154 		__field(int64_t,  bcount_delta)
1155 		__field(int64_t,  delbcnt_delta)
1156 
1157 		__field(uint64_t, rtblk_res)
1158 		__field(uint64_t, rtblk_res_used)
1159 		__field(int64_t,  rtbcount_delta)
1160 		__field(int64_t,  delrtb_delta)
1161 
1162 		__field(uint64_t, ino_res)
1163 		__field(uint64_t, ino_res_used)
1164 		__field(int64_t,  icount_delta)
1165 	),
1166 	TP_fast_assign(
1167 		__entry->dev = qtrx->qt_dquot->q_mount->m_super->s_dev;
1168 		__entry->type = qtrx->qt_dquot->q_type;
1169 		__entry->flags = qtrx->qt_dquot->q_flags;
1170 		__entry->dqid = qtrx->qt_dquot->q_id;
1171 
1172 		__entry->blk_res = qtrx->qt_blk_res;
1173 		__entry->bcount_delta = qtrx->qt_bcount_delta;
1174 		__entry->delbcnt_delta = qtrx->qt_delbcnt_delta;
1175 
1176 		__entry->rtblk_res = qtrx->qt_rtblk_res;
1177 		__entry->rtblk_res_used = qtrx->qt_rtblk_res_used;
1178 		__entry->rtbcount_delta = qtrx->qt_rtbcount_delta;
1179 		__entry->delrtb_delta = qtrx->qt_delrtb_delta;
1180 
1181 		__entry->ino_res = qtrx->qt_ino_res;
1182 		__entry->ino_res_used = qtrx->qt_ino_res_used;
1183 		__entry->icount_delta = qtrx->qt_icount_delta;
1184 	),
1185 	TP_printk("dev %d:%d dquot id 0x%x type %s flags %s"
1186 		  "blk_res %llu bcount_delta %lld delbcnt_delta %lld "
1187 		  "rtblk_res %llu rtblk_res_used %llu rtbcount_delta %lld delrtb_delta %lld "
1188 		  "ino_res %llu ino_res_used %llu icount_delta %lld",
1189 		MAJOR(__entry->dev), MINOR(__entry->dev),
1190 		__entry->dqid,
1191 		  __print_flags(__entry->type, "|", XFS_DQTYPE_STRINGS),
1192 		  __print_flags(__entry->flags, "|", XFS_DQFLAG_STRINGS),
1193 
1194 		__entry->blk_res,
1195 		__entry->bcount_delta,
1196 		__entry->delbcnt_delta,
1197 
1198 		__entry->rtblk_res,
1199 		__entry->rtblk_res_used,
1200 		__entry->rtbcount_delta,
1201 		__entry->delrtb_delta,
1202 
1203 		__entry->ino_res,
1204 		__entry->ino_res_used,
1205 		__entry->icount_delta)
1206 )
1207 
1208 #define DEFINE_DQTRX_EVENT(name) \
1209 DEFINE_EVENT(xfs_dqtrx_class, name, \
1210 	TP_PROTO(struct xfs_dqtrx *qtrx), \
1211 	TP_ARGS(qtrx))
1212 DEFINE_DQTRX_EVENT(xfs_trans_apply_dquot_deltas);
1213 DEFINE_DQTRX_EVENT(xfs_trans_mod_dquot_before);
1214 DEFINE_DQTRX_EVENT(xfs_trans_mod_dquot_after);
1215 
1216 DECLARE_EVENT_CLASS(xfs_loggrant_class,
1217 	TP_PROTO(struct xlog *log, struct xlog_ticket *tic),
1218 	TP_ARGS(log, tic),
1219 	TP_STRUCT__entry(
1220 		__field(dev_t, dev)
1221 		__field(char, ocnt)
1222 		__field(char, cnt)
1223 		__field(int, curr_res)
1224 		__field(int, unit_res)
1225 		__field(unsigned int, flags)
1226 		__field(int, reserveq)
1227 		__field(int, writeq)
1228 		__field(int, grant_reserve_cycle)
1229 		__field(int, grant_reserve_bytes)
1230 		__field(int, grant_write_cycle)
1231 		__field(int, grant_write_bytes)
1232 		__field(int, curr_cycle)
1233 		__field(int, curr_block)
1234 		__field(xfs_lsn_t, tail_lsn)
1235 	),
1236 	TP_fast_assign(
1237 		__entry->dev = log->l_mp->m_super->s_dev;
1238 		__entry->ocnt = tic->t_ocnt;
1239 		__entry->cnt = tic->t_cnt;
1240 		__entry->curr_res = tic->t_curr_res;
1241 		__entry->unit_res = tic->t_unit_res;
1242 		__entry->flags = tic->t_flags;
1243 		__entry->reserveq = list_empty(&log->l_reserve_head.waiters);
1244 		__entry->writeq = list_empty(&log->l_write_head.waiters);
1245 		xlog_crack_grant_head(&log->l_reserve_head.grant,
1246 				&__entry->grant_reserve_cycle,
1247 				&__entry->grant_reserve_bytes);
1248 		xlog_crack_grant_head(&log->l_write_head.grant,
1249 				&__entry->grant_write_cycle,
1250 				&__entry->grant_write_bytes);
1251 		__entry->curr_cycle = log->l_curr_cycle;
1252 		__entry->curr_block = log->l_curr_block;
1253 		__entry->tail_lsn = atomic64_read(&log->l_tail_lsn);
1254 	),
1255 	TP_printk("dev %d:%d t_ocnt %u t_cnt %u t_curr_res %u "
1256 		  "t_unit_res %u t_flags %s reserveq %s "
1257 		  "writeq %s grant_reserve_cycle %d "
1258 		  "grant_reserve_bytes %d grant_write_cycle %d "
1259 		  "grant_write_bytes %d curr_cycle %d curr_block %d "
1260 		  "tail_cycle %d tail_block %d",
1261 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1262 		  __entry->ocnt,
1263 		  __entry->cnt,
1264 		  __entry->curr_res,
1265 		  __entry->unit_res,
1266 		  __print_flags(__entry->flags, "|", XLOG_TIC_FLAGS),
1267 		  __entry->reserveq ? "empty" : "active",
1268 		  __entry->writeq ? "empty" : "active",
1269 		  __entry->grant_reserve_cycle,
1270 		  __entry->grant_reserve_bytes,
1271 		  __entry->grant_write_cycle,
1272 		  __entry->grant_write_bytes,
1273 		  __entry->curr_cycle,
1274 		  __entry->curr_block,
1275 		  CYCLE_LSN(__entry->tail_lsn),
1276 		  BLOCK_LSN(__entry->tail_lsn)
1277 	)
1278 )
1279 
1280 #define DEFINE_LOGGRANT_EVENT(name) \
1281 DEFINE_EVENT(xfs_loggrant_class, name, \
1282 	TP_PROTO(struct xlog *log, struct xlog_ticket *tic), \
1283 	TP_ARGS(log, tic))
1284 DEFINE_LOGGRANT_EVENT(xfs_log_umount_write);
1285 DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep);
1286 DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake);
1287 DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake_up);
1288 DEFINE_LOGGRANT_EVENT(xfs_log_reserve);
1289 DEFINE_LOGGRANT_EVENT(xfs_log_reserve_exit);
1290 DEFINE_LOGGRANT_EVENT(xfs_log_regrant);
1291 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_exit);
1292 DEFINE_LOGGRANT_EVENT(xfs_log_ticket_regrant);
1293 DEFINE_LOGGRANT_EVENT(xfs_log_ticket_regrant_exit);
1294 DEFINE_LOGGRANT_EVENT(xfs_log_ticket_regrant_sub);
1295 DEFINE_LOGGRANT_EVENT(xfs_log_ticket_ungrant);
1296 DEFINE_LOGGRANT_EVENT(xfs_log_ticket_ungrant_sub);
1297 DEFINE_LOGGRANT_EVENT(xfs_log_ticket_ungrant_exit);
1298 DEFINE_LOGGRANT_EVENT(xfs_log_cil_wait);
1299 
1300 DECLARE_EVENT_CLASS(xfs_log_item_class,
1301 	TP_PROTO(struct xfs_log_item *lip),
1302 	TP_ARGS(lip),
1303 	TP_STRUCT__entry(
1304 		__field(dev_t, dev)
1305 		__field(void *, lip)
1306 		__field(uint, type)
1307 		__field(unsigned long, flags)
1308 		__field(xfs_lsn_t, lsn)
1309 	),
1310 	TP_fast_assign(
1311 		__entry->dev = lip->li_log->l_mp->m_super->s_dev;
1312 		__entry->lip = lip;
1313 		__entry->type = lip->li_type;
1314 		__entry->flags = lip->li_flags;
1315 		__entry->lsn = lip->li_lsn;
1316 	),
1317 	TP_printk("dev %d:%d lip %p lsn %d/%d type %s flags %s",
1318 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1319 		  __entry->lip,
1320 		  CYCLE_LSN(__entry->lsn), BLOCK_LSN(__entry->lsn),
1321 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
1322 		  __print_flags(__entry->flags, "|", XFS_LI_FLAGS))
1323 )
1324 
1325 TRACE_EVENT(xfs_log_force,
1326 	TP_PROTO(struct xfs_mount *mp, xfs_lsn_t lsn, unsigned long caller_ip),
1327 	TP_ARGS(mp, lsn, caller_ip),
1328 	TP_STRUCT__entry(
1329 		__field(dev_t, dev)
1330 		__field(xfs_lsn_t, lsn)
1331 		__field(unsigned long, caller_ip)
1332 	),
1333 	TP_fast_assign(
1334 		__entry->dev = mp->m_super->s_dev;
1335 		__entry->lsn = lsn;
1336 		__entry->caller_ip = caller_ip;
1337 	),
1338 	TP_printk("dev %d:%d lsn 0x%llx caller %pS",
1339 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1340 		  __entry->lsn, (void *)__entry->caller_ip)
1341 )
1342 
1343 #define DEFINE_LOG_ITEM_EVENT(name) \
1344 DEFINE_EVENT(xfs_log_item_class, name, \
1345 	TP_PROTO(struct xfs_log_item *lip), \
1346 	TP_ARGS(lip))
1347 DEFINE_LOG_ITEM_EVENT(xfs_ail_push);
1348 DEFINE_LOG_ITEM_EVENT(xfs_ail_pinned);
1349 DEFINE_LOG_ITEM_EVENT(xfs_ail_locked);
1350 DEFINE_LOG_ITEM_EVENT(xfs_ail_flushing);
1351 
1352 DECLARE_EVENT_CLASS(xfs_ail_class,
1353 	TP_PROTO(struct xfs_log_item *lip, xfs_lsn_t old_lsn, xfs_lsn_t new_lsn),
1354 	TP_ARGS(lip, old_lsn, new_lsn),
1355 	TP_STRUCT__entry(
1356 		__field(dev_t, dev)
1357 		__field(void *, lip)
1358 		__field(uint, type)
1359 		__field(unsigned long, flags)
1360 		__field(xfs_lsn_t, old_lsn)
1361 		__field(xfs_lsn_t, new_lsn)
1362 	),
1363 	TP_fast_assign(
1364 		__entry->dev = lip->li_log->l_mp->m_super->s_dev;
1365 		__entry->lip = lip;
1366 		__entry->type = lip->li_type;
1367 		__entry->flags = lip->li_flags;
1368 		__entry->old_lsn = old_lsn;
1369 		__entry->new_lsn = new_lsn;
1370 	),
1371 	TP_printk("dev %d:%d lip %p old lsn %d/%d new lsn %d/%d type %s flags %s",
1372 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1373 		  __entry->lip,
1374 		  CYCLE_LSN(__entry->old_lsn), BLOCK_LSN(__entry->old_lsn),
1375 		  CYCLE_LSN(__entry->new_lsn), BLOCK_LSN(__entry->new_lsn),
1376 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
1377 		  __print_flags(__entry->flags, "|", XFS_LI_FLAGS))
1378 )
1379 
1380 #define DEFINE_AIL_EVENT(name) \
1381 DEFINE_EVENT(xfs_ail_class, name, \
1382 	TP_PROTO(struct xfs_log_item *lip, xfs_lsn_t old_lsn, xfs_lsn_t new_lsn), \
1383 	TP_ARGS(lip, old_lsn, new_lsn))
1384 DEFINE_AIL_EVENT(xfs_ail_insert);
1385 DEFINE_AIL_EVENT(xfs_ail_move);
1386 DEFINE_AIL_EVENT(xfs_ail_delete);
1387 
1388 TRACE_EVENT(xfs_log_assign_tail_lsn,
1389 	TP_PROTO(struct xlog *log, xfs_lsn_t new_lsn),
1390 	TP_ARGS(log, new_lsn),
1391 	TP_STRUCT__entry(
1392 		__field(dev_t, dev)
1393 		__field(xfs_lsn_t, new_lsn)
1394 		__field(xfs_lsn_t, old_lsn)
1395 		__field(xfs_lsn_t, last_sync_lsn)
1396 	),
1397 	TP_fast_assign(
1398 		__entry->dev = log->l_mp->m_super->s_dev;
1399 		__entry->new_lsn = new_lsn;
1400 		__entry->old_lsn = atomic64_read(&log->l_tail_lsn);
1401 		__entry->last_sync_lsn = atomic64_read(&log->l_last_sync_lsn);
1402 	),
1403 	TP_printk("dev %d:%d new tail lsn %d/%d, old lsn %d/%d, last sync %d/%d",
1404 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1405 		  CYCLE_LSN(__entry->new_lsn), BLOCK_LSN(__entry->new_lsn),
1406 		  CYCLE_LSN(__entry->old_lsn), BLOCK_LSN(__entry->old_lsn),
1407 		  CYCLE_LSN(__entry->last_sync_lsn), BLOCK_LSN(__entry->last_sync_lsn))
1408 )
1409 
1410 DECLARE_EVENT_CLASS(xfs_file_class,
1411 	TP_PROTO(struct kiocb *iocb, struct iov_iter *iter),
1412 	TP_ARGS(iocb, iter),
1413 	TP_STRUCT__entry(
1414 		__field(dev_t, dev)
1415 		__field(xfs_ino_t, ino)
1416 		__field(xfs_fsize_t, size)
1417 		__field(loff_t, offset)
1418 		__field(size_t, count)
1419 	),
1420 	TP_fast_assign(
1421 		__entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev;
1422 		__entry->ino = XFS_I(file_inode(iocb->ki_filp))->i_ino;
1423 		__entry->size = XFS_I(file_inode(iocb->ki_filp))->i_disk_size;
1424 		__entry->offset = iocb->ki_pos;
1425 		__entry->count = iov_iter_count(iter);
1426 	),
1427 	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx pos 0x%llx bytecount 0x%zx",
1428 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1429 		  __entry->ino,
1430 		  __entry->size,
1431 		  __entry->offset,
1432 		  __entry->count)
1433 )
1434 
1435 #define DEFINE_RW_EVENT(name)		\
1436 DEFINE_EVENT(xfs_file_class, name,	\
1437 	TP_PROTO(struct kiocb *iocb, struct iov_iter *iter),		\
1438 	TP_ARGS(iocb, iter))
1439 DEFINE_RW_EVENT(xfs_file_buffered_read);
1440 DEFINE_RW_EVENT(xfs_file_direct_read);
1441 DEFINE_RW_EVENT(xfs_file_dax_read);
1442 DEFINE_RW_EVENT(xfs_file_buffered_write);
1443 DEFINE_RW_EVENT(xfs_file_direct_write);
1444 DEFINE_RW_EVENT(xfs_file_dax_write);
1445 DEFINE_RW_EVENT(xfs_reflink_bounce_dio_write);
1446 
1447 
1448 DECLARE_EVENT_CLASS(xfs_imap_class,
1449 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,
1450 		 int whichfork, struct xfs_bmbt_irec *irec),
1451 	TP_ARGS(ip, offset, count, whichfork, irec),
1452 	TP_STRUCT__entry(
1453 		__field(dev_t, dev)
1454 		__field(xfs_ino_t, ino)
1455 		__field(loff_t, size)
1456 		__field(loff_t, offset)
1457 		__field(size_t, count)
1458 		__field(int, whichfork)
1459 		__field(xfs_fileoff_t, startoff)
1460 		__field(xfs_fsblock_t, startblock)
1461 		__field(xfs_filblks_t, blockcount)
1462 	),
1463 	TP_fast_assign(
1464 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1465 		__entry->ino = ip->i_ino;
1466 		__entry->size = ip->i_disk_size;
1467 		__entry->offset = offset;
1468 		__entry->count = count;
1469 		__entry->whichfork = whichfork;
1470 		__entry->startoff = irec ? irec->br_startoff : 0;
1471 		__entry->startblock = irec ? irec->br_startblock : 0;
1472 		__entry->blockcount = irec ? irec->br_blockcount : 0;
1473 	),
1474 	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx pos 0x%llx bytecount 0x%zx "
1475 		  "fork %s startoff 0x%llx startblock 0x%llx fsbcount 0x%llx",
1476 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1477 		  __entry->ino,
1478 		  __entry->size,
1479 		  __entry->offset,
1480 		  __entry->count,
1481 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
1482 		  __entry->startoff,
1483 		  (int64_t)__entry->startblock,
1484 		  __entry->blockcount)
1485 )
1486 
1487 #define DEFINE_IMAP_EVENT(name)	\
1488 DEFINE_EVENT(xfs_imap_class, name,	\
1489 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,	\
1490 		 int whichfork, struct xfs_bmbt_irec *irec),		\
1491 	TP_ARGS(ip, offset, count, whichfork, irec))
1492 DEFINE_IMAP_EVENT(xfs_map_blocks_found);
1493 DEFINE_IMAP_EVENT(xfs_map_blocks_alloc);
1494 DEFINE_IMAP_EVENT(xfs_iomap_alloc);
1495 DEFINE_IMAP_EVENT(xfs_iomap_found);
1496 
1497 DECLARE_EVENT_CLASS(xfs_simple_io_class,
1498 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),
1499 	TP_ARGS(ip, offset, count),
1500 	TP_STRUCT__entry(
1501 		__field(dev_t, dev)
1502 		__field(xfs_ino_t, ino)
1503 		__field(loff_t, isize)
1504 		__field(loff_t, disize)
1505 		__field(loff_t, offset)
1506 		__field(size_t, count)
1507 	),
1508 	TP_fast_assign(
1509 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1510 		__entry->ino = ip->i_ino;
1511 		__entry->isize = VFS_I(ip)->i_size;
1512 		__entry->disize = ip->i_disk_size;
1513 		__entry->offset = offset;
1514 		__entry->count = count;
1515 	),
1516 	TP_printk("dev %d:%d ino 0x%llx isize 0x%llx disize 0x%llx "
1517 		  "pos 0x%llx bytecount 0x%zx",
1518 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1519 		  __entry->ino,
1520 		  __entry->isize,
1521 		  __entry->disize,
1522 		  __entry->offset,
1523 		  __entry->count)
1524 );
1525 
1526 #define DEFINE_SIMPLE_IO_EVENT(name)	\
1527 DEFINE_EVENT(xfs_simple_io_class, name,	\
1528 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),	\
1529 	TP_ARGS(ip, offset, count))
1530 DEFINE_SIMPLE_IO_EVENT(xfs_delalloc_enospc);
1531 DEFINE_SIMPLE_IO_EVENT(xfs_unwritten_convert);
1532 DEFINE_SIMPLE_IO_EVENT(xfs_setfilesize);
1533 DEFINE_SIMPLE_IO_EVENT(xfs_zero_eof);
1534 DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write);
1535 DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_unwritten);
1536 DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_append);
1537 
1538 DECLARE_EVENT_CLASS(xfs_itrunc_class,
1539 	TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size),
1540 	TP_ARGS(ip, new_size),
1541 	TP_STRUCT__entry(
1542 		__field(dev_t, dev)
1543 		__field(xfs_ino_t, ino)
1544 		__field(xfs_fsize_t, size)
1545 		__field(xfs_fsize_t, new_size)
1546 	),
1547 	TP_fast_assign(
1548 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1549 		__entry->ino = ip->i_ino;
1550 		__entry->size = ip->i_disk_size;
1551 		__entry->new_size = new_size;
1552 	),
1553 	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx new_size 0x%llx",
1554 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1555 		  __entry->ino,
1556 		  __entry->size,
1557 		  __entry->new_size)
1558 )
1559 
1560 #define DEFINE_ITRUNC_EVENT(name) \
1561 DEFINE_EVENT(xfs_itrunc_class, name, \
1562 	TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), \
1563 	TP_ARGS(ip, new_size))
1564 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_start);
1565 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_end);
1566 
1567 TRACE_EVENT(xfs_pagecache_inval,
1568 	TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),
1569 	TP_ARGS(ip, start, finish),
1570 	TP_STRUCT__entry(
1571 		__field(dev_t, dev)
1572 		__field(xfs_ino_t, ino)
1573 		__field(xfs_fsize_t, size)
1574 		__field(xfs_off_t, start)
1575 		__field(xfs_off_t, finish)
1576 	),
1577 	TP_fast_assign(
1578 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1579 		__entry->ino = ip->i_ino;
1580 		__entry->size = ip->i_disk_size;
1581 		__entry->start = start;
1582 		__entry->finish = finish;
1583 	),
1584 	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx start 0x%llx finish 0x%llx",
1585 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1586 		  __entry->ino,
1587 		  __entry->size,
1588 		  __entry->start,
1589 		  __entry->finish)
1590 );
1591 
1592 TRACE_EVENT(xfs_bunmap,
1593 	TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t fileoff, xfs_filblks_t len,
1594 		 int flags, unsigned long caller_ip),
1595 	TP_ARGS(ip, fileoff, len, flags, caller_ip),
1596 	TP_STRUCT__entry(
1597 		__field(dev_t, dev)
1598 		__field(xfs_ino_t, ino)
1599 		__field(xfs_fsize_t, size)
1600 		__field(xfs_fileoff_t, fileoff)
1601 		__field(xfs_filblks_t, len)
1602 		__field(unsigned long, caller_ip)
1603 		__field(int, flags)
1604 	),
1605 	TP_fast_assign(
1606 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1607 		__entry->ino = ip->i_ino;
1608 		__entry->size = ip->i_disk_size;
1609 		__entry->fileoff = fileoff;
1610 		__entry->len = len;
1611 		__entry->caller_ip = caller_ip;
1612 		__entry->flags = flags;
1613 	),
1614 	TP_printk("dev %d:%d ino 0x%llx disize 0x%llx fileoff 0x%llx fsbcount 0x%llx"
1615 		  "flags %s caller %pS",
1616 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1617 		  __entry->ino,
1618 		  __entry->size,
1619 		  __entry->fileoff,
1620 		  __entry->len,
1621 		  __print_flags(__entry->flags, "|", XFS_BMAPI_FLAGS),
1622 		  (void *)__entry->caller_ip)
1623 
1624 );
1625 
1626 DECLARE_EVENT_CLASS(xfs_extent_busy_class,
1627 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1628 		 xfs_agblock_t agbno, xfs_extlen_t len),
1629 	TP_ARGS(mp, agno, agbno, len),
1630 	TP_STRUCT__entry(
1631 		__field(dev_t, dev)
1632 		__field(xfs_agnumber_t, agno)
1633 		__field(xfs_agblock_t, agbno)
1634 		__field(xfs_extlen_t, len)
1635 	),
1636 	TP_fast_assign(
1637 		__entry->dev = mp->m_super->s_dev;
1638 		__entry->agno = agno;
1639 		__entry->agbno = agbno;
1640 		__entry->len = len;
1641 	),
1642 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
1643 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1644 		  __entry->agno,
1645 		  __entry->agbno,
1646 		  __entry->len)
1647 );
1648 #define DEFINE_BUSY_EVENT(name) \
1649 DEFINE_EVENT(xfs_extent_busy_class, name, \
1650 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1651 		 xfs_agblock_t agbno, xfs_extlen_t len), \
1652 	TP_ARGS(mp, agno, agbno, len))
1653 DEFINE_BUSY_EVENT(xfs_extent_busy);
1654 DEFINE_BUSY_EVENT(xfs_extent_busy_enomem);
1655 DEFINE_BUSY_EVENT(xfs_extent_busy_force);
1656 DEFINE_BUSY_EVENT(xfs_extent_busy_reuse);
1657 DEFINE_BUSY_EVENT(xfs_extent_busy_clear);
1658 
1659 TRACE_EVENT(xfs_extent_busy_trim,
1660 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1661 		 xfs_agblock_t agbno, xfs_extlen_t len,
1662 		 xfs_agblock_t tbno, xfs_extlen_t tlen),
1663 	TP_ARGS(mp, agno, agbno, len, tbno, tlen),
1664 	TP_STRUCT__entry(
1665 		__field(dev_t, dev)
1666 		__field(xfs_agnumber_t, agno)
1667 		__field(xfs_agblock_t, agbno)
1668 		__field(xfs_extlen_t, len)
1669 		__field(xfs_agblock_t, tbno)
1670 		__field(xfs_extlen_t, tlen)
1671 	),
1672 	TP_fast_assign(
1673 		__entry->dev = mp->m_super->s_dev;
1674 		__entry->agno = agno;
1675 		__entry->agbno = agbno;
1676 		__entry->len = len;
1677 		__entry->tbno = tbno;
1678 		__entry->tlen = tlen;
1679 	),
1680 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x found_agbno 0x%x found_fsbcount 0x%x",
1681 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1682 		  __entry->agno,
1683 		  __entry->agbno,
1684 		  __entry->len,
1685 		  __entry->tbno,
1686 		  __entry->tlen)
1687 );
1688 
1689 DECLARE_EVENT_CLASS(xfs_agf_class,
1690 	TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags,
1691 		 unsigned long caller_ip),
1692 	TP_ARGS(mp, agf, flags, caller_ip),
1693 	TP_STRUCT__entry(
1694 		__field(dev_t, dev)
1695 		__field(xfs_agnumber_t, agno)
1696 		__field(int, flags)
1697 		__field(__u32, length)
1698 		__field(__u32, bno_root)
1699 		__field(__u32, cnt_root)
1700 		__field(__u32, bno_level)
1701 		__field(__u32, cnt_level)
1702 		__field(__u32, flfirst)
1703 		__field(__u32, fllast)
1704 		__field(__u32, flcount)
1705 		__field(__u32, freeblks)
1706 		__field(__u32, longest)
1707 		__field(unsigned long, caller_ip)
1708 	),
1709 	TP_fast_assign(
1710 		__entry->dev = mp->m_super->s_dev;
1711 		__entry->agno = be32_to_cpu(agf->agf_seqno),
1712 		__entry->flags = flags;
1713 		__entry->length = be32_to_cpu(agf->agf_length),
1714 		__entry->bno_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
1715 		__entry->cnt_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
1716 		__entry->bno_level =
1717 				be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
1718 		__entry->cnt_level =
1719 				be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
1720 		__entry->flfirst = be32_to_cpu(agf->agf_flfirst),
1721 		__entry->fllast = be32_to_cpu(agf->agf_fllast),
1722 		__entry->flcount = be32_to_cpu(agf->agf_flcount),
1723 		__entry->freeblks = be32_to_cpu(agf->agf_freeblks),
1724 		__entry->longest = be32_to_cpu(agf->agf_longest);
1725 		__entry->caller_ip = caller_ip;
1726 	),
1727 	TP_printk("dev %d:%d agno 0x%x flags %s length %u roots b %u c %u "
1728 		  "levels b %u c %u flfirst %u fllast %u flcount %u "
1729 		  "freeblks %u longest %u caller %pS",
1730 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1731 		  __entry->agno,
1732 		  __print_flags(__entry->flags, "|", XFS_AGF_FLAGS),
1733 		  __entry->length,
1734 		  __entry->bno_root,
1735 		  __entry->cnt_root,
1736 		  __entry->bno_level,
1737 		  __entry->cnt_level,
1738 		  __entry->flfirst,
1739 		  __entry->fllast,
1740 		  __entry->flcount,
1741 		  __entry->freeblks,
1742 		  __entry->longest,
1743 		  (void *)__entry->caller_ip)
1744 );
1745 #define DEFINE_AGF_EVENT(name) \
1746 DEFINE_EVENT(xfs_agf_class, name, \
1747 	TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags, \
1748 		 unsigned long caller_ip), \
1749 	TP_ARGS(mp, agf, flags, caller_ip))
1750 DEFINE_AGF_EVENT(xfs_agf);
1751 DEFINE_AGF_EVENT(xfs_agfl_reset);
1752 
1753 TRACE_EVENT(xfs_free_extent,
1754 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
1755 		 xfs_extlen_t len, enum xfs_ag_resv_type resv, int haveleft,
1756 		 int haveright),
1757 	TP_ARGS(mp, agno, agbno, len, resv, haveleft, haveright),
1758 	TP_STRUCT__entry(
1759 		__field(dev_t, dev)
1760 		__field(xfs_agnumber_t, agno)
1761 		__field(xfs_agblock_t, agbno)
1762 		__field(xfs_extlen_t, len)
1763 		__field(int, resv)
1764 		__field(int, haveleft)
1765 		__field(int, haveright)
1766 	),
1767 	TP_fast_assign(
1768 		__entry->dev = mp->m_super->s_dev;
1769 		__entry->agno = agno;
1770 		__entry->agbno = agbno;
1771 		__entry->len = len;
1772 		__entry->resv = resv;
1773 		__entry->haveleft = haveleft;
1774 		__entry->haveright = haveright;
1775 	),
1776 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x resv %d %s",
1777 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1778 		  __entry->agno,
1779 		  __entry->agbno,
1780 		  __entry->len,
1781 		  __entry->resv,
1782 		  __entry->haveleft ?
1783 			(__entry->haveright ? "both" : "left") :
1784 			(__entry->haveright ? "right" : "none"))
1785 
1786 );
1787 
1788 DECLARE_EVENT_CLASS(xfs_alloc_class,
1789 	TP_PROTO(struct xfs_alloc_arg *args),
1790 	TP_ARGS(args),
1791 	TP_STRUCT__entry(
1792 		__field(dev_t, dev)
1793 		__field(xfs_agnumber_t, agno)
1794 		__field(xfs_agblock_t, agbno)
1795 		__field(xfs_extlen_t, minlen)
1796 		__field(xfs_extlen_t, maxlen)
1797 		__field(xfs_extlen_t, mod)
1798 		__field(xfs_extlen_t, prod)
1799 		__field(xfs_extlen_t, minleft)
1800 		__field(xfs_extlen_t, total)
1801 		__field(xfs_extlen_t, alignment)
1802 		__field(xfs_extlen_t, minalignslop)
1803 		__field(xfs_extlen_t, len)
1804 		__field(short, type)
1805 		__field(short, otype)
1806 		__field(char, wasdel)
1807 		__field(char, wasfromfl)
1808 		__field(int, resv)
1809 		__field(int, datatype)
1810 		__field(xfs_fsblock_t, firstblock)
1811 	),
1812 	TP_fast_assign(
1813 		__entry->dev = args->mp->m_super->s_dev;
1814 		__entry->agno = args->agno;
1815 		__entry->agbno = args->agbno;
1816 		__entry->minlen = args->minlen;
1817 		__entry->maxlen = args->maxlen;
1818 		__entry->mod = args->mod;
1819 		__entry->prod = args->prod;
1820 		__entry->minleft = args->minleft;
1821 		__entry->total = args->total;
1822 		__entry->alignment = args->alignment;
1823 		__entry->minalignslop = args->minalignslop;
1824 		__entry->len = args->len;
1825 		__entry->type = args->type;
1826 		__entry->otype = args->otype;
1827 		__entry->wasdel = args->wasdel;
1828 		__entry->wasfromfl = args->wasfromfl;
1829 		__entry->resv = args->resv;
1830 		__entry->datatype = args->datatype;
1831 		__entry->firstblock = args->tp->t_firstblock;
1832 	),
1833 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x minlen %u maxlen %u mod %u "
1834 		  "prod %u minleft %u total %u alignment %u minalignslop %u "
1835 		  "len %u type %s otype %s wasdel %d wasfromfl %d resv %d "
1836 		  "datatype 0x%x firstblock 0x%llx",
1837 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1838 		  __entry->agno,
1839 		  __entry->agbno,
1840 		  __entry->minlen,
1841 		  __entry->maxlen,
1842 		  __entry->mod,
1843 		  __entry->prod,
1844 		  __entry->minleft,
1845 		  __entry->total,
1846 		  __entry->alignment,
1847 		  __entry->minalignslop,
1848 		  __entry->len,
1849 		  __print_symbolic(__entry->type, XFS_ALLOC_TYPES),
1850 		  __print_symbolic(__entry->otype, XFS_ALLOC_TYPES),
1851 		  __entry->wasdel,
1852 		  __entry->wasfromfl,
1853 		  __entry->resv,
1854 		  __entry->datatype,
1855 		  (unsigned long long)__entry->firstblock)
1856 )
1857 
1858 #define DEFINE_ALLOC_EVENT(name) \
1859 DEFINE_EVENT(xfs_alloc_class, name, \
1860 	TP_PROTO(struct xfs_alloc_arg *args), \
1861 	TP_ARGS(args))
1862 DEFINE_ALLOC_EVENT(xfs_alloc_exact_done);
1863 DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound);
1864 DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
1865 DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
1866 DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
1867 DEFINE_ALLOC_EVENT(xfs_alloc_cur);
1868 DEFINE_ALLOC_EVENT(xfs_alloc_cur_right);
1869 DEFINE_ALLOC_EVENT(xfs_alloc_cur_left);
1870 DEFINE_ALLOC_EVENT(xfs_alloc_cur_lookup);
1871 DEFINE_ALLOC_EVENT(xfs_alloc_cur_lookup_done);
1872 DEFINE_ALLOC_EVENT(xfs_alloc_near_error);
1873 DEFINE_ALLOC_EVENT(xfs_alloc_near_noentry);
1874 DEFINE_ALLOC_EVENT(xfs_alloc_near_busy);
1875 DEFINE_ALLOC_EVENT(xfs_alloc_size_neither);
1876 DEFINE_ALLOC_EVENT(xfs_alloc_size_noentry);
1877 DEFINE_ALLOC_EVENT(xfs_alloc_size_nominleft);
1878 DEFINE_ALLOC_EVENT(xfs_alloc_size_done);
1879 DEFINE_ALLOC_EVENT(xfs_alloc_size_error);
1880 DEFINE_ALLOC_EVENT(xfs_alloc_size_busy);
1881 DEFINE_ALLOC_EVENT(xfs_alloc_small_freelist);
1882 DEFINE_ALLOC_EVENT(xfs_alloc_small_notenough);
1883 DEFINE_ALLOC_EVENT(xfs_alloc_small_done);
1884 DEFINE_ALLOC_EVENT(xfs_alloc_small_error);
1885 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_badargs);
1886 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_nofix);
1887 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp);
1888 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed);
1889 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed);
1890 
1891 TRACE_EVENT(xfs_alloc_cur_check,
1892 	TP_PROTO(struct xfs_mount *mp, xfs_btnum_t btnum, xfs_agblock_t bno,
1893 		 xfs_extlen_t len, xfs_extlen_t diff, bool new),
1894 	TP_ARGS(mp, btnum, bno, len, diff, new),
1895 	TP_STRUCT__entry(
1896 		__field(dev_t, dev)
1897 		__field(xfs_btnum_t, btnum)
1898 		__field(xfs_agblock_t, bno)
1899 		__field(xfs_extlen_t, len)
1900 		__field(xfs_extlen_t, diff)
1901 		__field(bool, new)
1902 	),
1903 	TP_fast_assign(
1904 		__entry->dev = mp->m_super->s_dev;
1905 		__entry->btnum = btnum;
1906 		__entry->bno = bno;
1907 		__entry->len = len;
1908 		__entry->diff = diff;
1909 		__entry->new = new;
1910 	),
1911 	TP_printk("dev %d:%d btree %s agbno 0x%x fsbcount 0x%x diff 0x%x new %d",
1912 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1913 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
1914 		  __entry->bno, __entry->len, __entry->diff, __entry->new)
1915 )
1916 
1917 DECLARE_EVENT_CLASS(xfs_da_class,
1918 	TP_PROTO(struct xfs_da_args *args),
1919 	TP_ARGS(args),
1920 	TP_STRUCT__entry(
1921 		__field(dev_t, dev)
1922 		__field(xfs_ino_t, ino)
1923 		__dynamic_array(char, name, args->namelen)
1924 		__field(int, namelen)
1925 		__field(xfs_dahash_t, hashval)
1926 		__field(xfs_ino_t, inumber)
1927 		__field(int, op_flags)
1928 	),
1929 	TP_fast_assign(
1930 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1931 		__entry->ino = args->dp->i_ino;
1932 		if (args->namelen)
1933 			memcpy(__get_str(name), args->name, args->namelen);
1934 		__entry->namelen = args->namelen;
1935 		__entry->hashval = args->hashval;
1936 		__entry->inumber = args->inumber;
1937 		__entry->op_flags = args->op_flags;
1938 	),
1939 	TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d hashval 0x%x "
1940 		  "inumber 0x%llx op_flags %s",
1941 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1942 		  __entry->ino,
1943 		  __entry->namelen,
1944 		  __entry->namelen ? __get_str(name) : NULL,
1945 		  __entry->namelen,
1946 		  __entry->hashval,
1947 		  __entry->inumber,
1948 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS))
1949 )
1950 
1951 #define DEFINE_DIR2_EVENT(name) \
1952 DEFINE_EVENT(xfs_da_class, name, \
1953 	TP_PROTO(struct xfs_da_args *args), \
1954 	TP_ARGS(args))
1955 DEFINE_DIR2_EVENT(xfs_dir2_sf_addname);
1956 DEFINE_DIR2_EVENT(xfs_dir2_sf_create);
1957 DEFINE_DIR2_EVENT(xfs_dir2_sf_lookup);
1958 DEFINE_DIR2_EVENT(xfs_dir2_sf_replace);
1959 DEFINE_DIR2_EVENT(xfs_dir2_sf_removename);
1960 DEFINE_DIR2_EVENT(xfs_dir2_sf_toino4);
1961 DEFINE_DIR2_EVENT(xfs_dir2_sf_toino8);
1962 DEFINE_DIR2_EVENT(xfs_dir2_sf_to_block);
1963 DEFINE_DIR2_EVENT(xfs_dir2_block_addname);
1964 DEFINE_DIR2_EVENT(xfs_dir2_block_lookup);
1965 DEFINE_DIR2_EVENT(xfs_dir2_block_replace);
1966 DEFINE_DIR2_EVENT(xfs_dir2_block_removename);
1967 DEFINE_DIR2_EVENT(xfs_dir2_block_to_sf);
1968 DEFINE_DIR2_EVENT(xfs_dir2_block_to_leaf);
1969 DEFINE_DIR2_EVENT(xfs_dir2_leaf_addname);
1970 DEFINE_DIR2_EVENT(xfs_dir2_leaf_lookup);
1971 DEFINE_DIR2_EVENT(xfs_dir2_leaf_replace);
1972 DEFINE_DIR2_EVENT(xfs_dir2_leaf_removename);
1973 DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_block);
1974 DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_node);
1975 DEFINE_DIR2_EVENT(xfs_dir2_node_addname);
1976 DEFINE_DIR2_EVENT(xfs_dir2_node_lookup);
1977 DEFINE_DIR2_EVENT(xfs_dir2_node_replace);
1978 DEFINE_DIR2_EVENT(xfs_dir2_node_removename);
1979 DEFINE_DIR2_EVENT(xfs_dir2_node_to_leaf);
1980 
1981 DECLARE_EVENT_CLASS(xfs_attr_class,
1982 	TP_PROTO(struct xfs_da_args *args),
1983 	TP_ARGS(args),
1984 	TP_STRUCT__entry(
1985 		__field(dev_t, dev)
1986 		__field(xfs_ino_t, ino)
1987 		__dynamic_array(char, name, args->namelen)
1988 		__field(int, namelen)
1989 		__field(int, valuelen)
1990 		__field(xfs_dahash_t, hashval)
1991 		__field(unsigned int, attr_filter)
1992 		__field(unsigned int, attr_flags)
1993 		__field(int, op_flags)
1994 	),
1995 	TP_fast_assign(
1996 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1997 		__entry->ino = args->dp->i_ino;
1998 		if (args->namelen)
1999 			memcpy(__get_str(name), args->name, args->namelen);
2000 		__entry->namelen = args->namelen;
2001 		__entry->valuelen = args->valuelen;
2002 		__entry->hashval = args->hashval;
2003 		__entry->attr_filter = args->attr_filter;
2004 		__entry->attr_flags = args->attr_flags;
2005 		__entry->op_flags = args->op_flags;
2006 	),
2007 	TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d "
2008 		  "hashval 0x%x filter %s flags %s op_flags %s",
2009 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2010 		  __entry->ino,
2011 		  __entry->namelen,
2012 		  __entry->namelen ? __get_str(name) : NULL,
2013 		  __entry->namelen,
2014 		  __entry->valuelen,
2015 		  __entry->hashval,
2016 		  __print_flags(__entry->attr_filter, "|",
2017 				XFS_ATTR_FILTER_FLAGS),
2018 		   __print_flags(__entry->attr_flags, "|",
2019 				{ XATTR_CREATE,		"CREATE" },
2020 				{ XATTR_REPLACE,	"REPLACE" }),
2021 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS))
2022 )
2023 
2024 #define DEFINE_ATTR_EVENT(name) \
2025 DEFINE_EVENT(xfs_attr_class, name, \
2026 	TP_PROTO(struct xfs_da_args *args), \
2027 	TP_ARGS(args))
2028 DEFINE_ATTR_EVENT(xfs_attr_sf_add);
2029 DEFINE_ATTR_EVENT(xfs_attr_sf_addname);
2030 DEFINE_ATTR_EVENT(xfs_attr_sf_create);
2031 DEFINE_ATTR_EVENT(xfs_attr_sf_lookup);
2032 DEFINE_ATTR_EVENT(xfs_attr_sf_remove);
2033 DEFINE_ATTR_EVENT(xfs_attr_sf_to_leaf);
2034 
2035 DEFINE_ATTR_EVENT(xfs_attr_leaf_add);
2036 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old);
2037 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new);
2038 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_work);
2039 DEFINE_ATTR_EVENT(xfs_attr_leaf_create);
2040 DEFINE_ATTR_EVENT(xfs_attr_leaf_compact);
2041 DEFINE_ATTR_EVENT(xfs_attr_leaf_get);
2042 DEFINE_ATTR_EVENT(xfs_attr_leaf_lookup);
2043 DEFINE_ATTR_EVENT(xfs_attr_leaf_replace);
2044 DEFINE_ATTR_EVENT(xfs_attr_leaf_remove);
2045 DEFINE_ATTR_EVENT(xfs_attr_leaf_removename);
2046 DEFINE_ATTR_EVENT(xfs_attr_leaf_split);
2047 DEFINE_ATTR_EVENT(xfs_attr_leaf_split_before);
2048 DEFINE_ATTR_EVENT(xfs_attr_leaf_split_after);
2049 DEFINE_ATTR_EVENT(xfs_attr_leaf_clearflag);
2050 DEFINE_ATTR_EVENT(xfs_attr_leaf_setflag);
2051 DEFINE_ATTR_EVENT(xfs_attr_leaf_flipflags);
2052 DEFINE_ATTR_EVENT(xfs_attr_leaf_to_sf);
2053 DEFINE_ATTR_EVENT(xfs_attr_leaf_to_node);
2054 DEFINE_ATTR_EVENT(xfs_attr_leaf_rebalance);
2055 DEFINE_ATTR_EVENT(xfs_attr_leaf_unbalance);
2056 DEFINE_ATTR_EVENT(xfs_attr_leaf_toosmall);
2057 
2058 DEFINE_ATTR_EVENT(xfs_attr_node_addname);
2059 DEFINE_ATTR_EVENT(xfs_attr_node_get);
2060 DEFINE_ATTR_EVENT(xfs_attr_node_replace);
2061 DEFINE_ATTR_EVENT(xfs_attr_node_removename);
2062 
2063 DEFINE_ATTR_EVENT(xfs_attr_fillstate);
2064 DEFINE_ATTR_EVENT(xfs_attr_refillstate);
2065 
2066 DEFINE_ATTR_EVENT(xfs_attr_rmtval_get);
2067 DEFINE_ATTR_EVENT(xfs_attr_rmtval_set);
2068 
2069 #define DEFINE_DA_EVENT(name) \
2070 DEFINE_EVENT(xfs_da_class, name, \
2071 	TP_PROTO(struct xfs_da_args *args), \
2072 	TP_ARGS(args))
2073 DEFINE_DA_EVENT(xfs_da_split);
2074 DEFINE_DA_EVENT(xfs_da_join);
2075 DEFINE_DA_EVENT(xfs_da_link_before);
2076 DEFINE_DA_EVENT(xfs_da_link_after);
2077 DEFINE_DA_EVENT(xfs_da_unlink_back);
2078 DEFINE_DA_EVENT(xfs_da_unlink_forward);
2079 DEFINE_DA_EVENT(xfs_da_root_split);
2080 DEFINE_DA_EVENT(xfs_da_root_join);
2081 DEFINE_DA_EVENT(xfs_da_node_add);
2082 DEFINE_DA_EVENT(xfs_da_node_create);
2083 DEFINE_DA_EVENT(xfs_da_node_split);
2084 DEFINE_DA_EVENT(xfs_da_node_remove);
2085 DEFINE_DA_EVENT(xfs_da_node_rebalance);
2086 DEFINE_DA_EVENT(xfs_da_node_unbalance);
2087 DEFINE_DA_EVENT(xfs_da_node_toosmall);
2088 DEFINE_DA_EVENT(xfs_da_swap_lastblock);
2089 DEFINE_DA_EVENT(xfs_da_grow_inode);
2090 DEFINE_DA_EVENT(xfs_da_shrink_inode);
2091 DEFINE_DA_EVENT(xfs_da_fixhashpath);
2092 DEFINE_DA_EVENT(xfs_da_path_shift);
2093 
2094 DECLARE_EVENT_CLASS(xfs_dir2_space_class,
2095 	TP_PROTO(struct xfs_da_args *args, int idx),
2096 	TP_ARGS(args, idx),
2097 	TP_STRUCT__entry(
2098 		__field(dev_t, dev)
2099 		__field(xfs_ino_t, ino)
2100 		__field(int, op_flags)
2101 		__field(int, idx)
2102 	),
2103 	TP_fast_assign(
2104 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
2105 		__entry->ino = args->dp->i_ino;
2106 		__entry->op_flags = args->op_flags;
2107 		__entry->idx = idx;
2108 	),
2109 	TP_printk("dev %d:%d ino 0x%llx op_flags %s index %d",
2110 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2111 		  __entry->ino,
2112 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
2113 		  __entry->idx)
2114 )
2115 
2116 #define DEFINE_DIR2_SPACE_EVENT(name) \
2117 DEFINE_EVENT(xfs_dir2_space_class, name, \
2118 	TP_PROTO(struct xfs_da_args *args, int idx), \
2119 	TP_ARGS(args, idx))
2120 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_add);
2121 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_remove);
2122 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_grow_inode);
2123 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_shrink_inode);
2124 
2125 TRACE_EVENT(xfs_dir2_leafn_moveents,
2126 	TP_PROTO(struct xfs_da_args *args, int src_idx, int dst_idx, int count),
2127 	TP_ARGS(args, src_idx, dst_idx, count),
2128 	TP_STRUCT__entry(
2129 		__field(dev_t, dev)
2130 		__field(xfs_ino_t, ino)
2131 		__field(int, op_flags)
2132 		__field(int, src_idx)
2133 		__field(int, dst_idx)
2134 		__field(int, count)
2135 	),
2136 	TP_fast_assign(
2137 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
2138 		__entry->ino = args->dp->i_ino;
2139 		__entry->op_flags = args->op_flags;
2140 		__entry->src_idx = src_idx;
2141 		__entry->dst_idx = dst_idx;
2142 		__entry->count = count;
2143 	),
2144 	TP_printk("dev %d:%d ino 0x%llx op_flags %s "
2145 		  "src_idx %d dst_idx %d count %d",
2146 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2147 		  __entry->ino,
2148 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
2149 		  __entry->src_idx,
2150 		  __entry->dst_idx,
2151 		  __entry->count)
2152 );
2153 
2154 #define XFS_SWAPEXT_INODES \
2155 	{ 0,	"target" }, \
2156 	{ 1,	"temp" }
2157 
2158 TRACE_DEFINE_ENUM(XFS_DINODE_FMT_DEV);
2159 TRACE_DEFINE_ENUM(XFS_DINODE_FMT_LOCAL);
2160 TRACE_DEFINE_ENUM(XFS_DINODE_FMT_EXTENTS);
2161 TRACE_DEFINE_ENUM(XFS_DINODE_FMT_BTREE);
2162 TRACE_DEFINE_ENUM(XFS_DINODE_FMT_UUID);
2163 
2164 DECLARE_EVENT_CLASS(xfs_swap_extent_class,
2165 	TP_PROTO(struct xfs_inode *ip, int which),
2166 	TP_ARGS(ip, which),
2167 	TP_STRUCT__entry(
2168 		__field(dev_t, dev)
2169 		__field(int, which)
2170 		__field(xfs_ino_t, ino)
2171 		__field(int, format)
2172 		__field(int, nex)
2173 		__field(int, broot_size)
2174 		__field(int, fork_off)
2175 	),
2176 	TP_fast_assign(
2177 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
2178 		__entry->which = which;
2179 		__entry->ino = ip->i_ino;
2180 		__entry->format = ip->i_df.if_format;
2181 		__entry->nex = ip->i_df.if_nextents;
2182 		__entry->broot_size = ip->i_df.if_broot_bytes;
2183 		__entry->fork_off = XFS_IFORK_BOFF(ip);
2184 	),
2185 	TP_printk("dev %d:%d ino 0x%llx (%s), %s format, num_extents %d, "
2186 		  "broot size %d, forkoff 0x%x",
2187 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2188 		  __entry->ino,
2189 		  __print_symbolic(__entry->which, XFS_SWAPEXT_INODES),
2190 		  __print_symbolic(__entry->format, XFS_INODE_FORMAT_STR),
2191 		  __entry->nex,
2192 		  __entry->broot_size,
2193 		  __entry->fork_off)
2194 )
2195 
2196 #define DEFINE_SWAPEXT_EVENT(name) \
2197 DEFINE_EVENT(xfs_swap_extent_class, name, \
2198 	TP_PROTO(struct xfs_inode *ip, int which), \
2199 	TP_ARGS(ip, which))
2200 
2201 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_before);
2202 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_after);
2203 
2204 TRACE_EVENT(xfs_log_recover,
2205 	TP_PROTO(struct xlog *log, xfs_daddr_t headblk, xfs_daddr_t tailblk),
2206 	TP_ARGS(log, headblk, tailblk),
2207 	TP_STRUCT__entry(
2208 		__field(dev_t, dev)
2209 		__field(xfs_daddr_t, headblk)
2210 		__field(xfs_daddr_t, tailblk)
2211 	),
2212 	TP_fast_assign(
2213 		__entry->dev = log->l_mp->m_super->s_dev;
2214 		__entry->headblk = headblk;
2215 		__entry->tailblk = tailblk;
2216 	),
2217 	TP_printk("dev %d:%d headblk 0x%llx tailblk 0x%llx",
2218 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->headblk,
2219 		  __entry->tailblk)
2220 )
2221 
2222 TRACE_EVENT(xfs_log_recover_record,
2223 	TP_PROTO(struct xlog *log, struct xlog_rec_header *rhead, int pass),
2224 	TP_ARGS(log, rhead, pass),
2225 	TP_STRUCT__entry(
2226 		__field(dev_t, dev)
2227 		__field(xfs_lsn_t, lsn)
2228 		__field(int, len)
2229 		__field(int, num_logops)
2230 		__field(int, pass)
2231 	),
2232 	TP_fast_assign(
2233 		__entry->dev = log->l_mp->m_super->s_dev;
2234 		__entry->lsn = be64_to_cpu(rhead->h_lsn);
2235 		__entry->len = be32_to_cpu(rhead->h_len);
2236 		__entry->num_logops = be32_to_cpu(rhead->h_num_logops);
2237 		__entry->pass = pass;
2238 	),
2239 	TP_printk("dev %d:%d lsn 0x%llx len 0x%x num_logops 0x%x pass %d",
2240 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2241 		  __entry->lsn, __entry->len, __entry->num_logops,
2242 		   __entry->pass)
2243 )
2244 
2245 DECLARE_EVENT_CLASS(xfs_log_recover_item_class,
2246 	TP_PROTO(struct xlog *log, struct xlog_recover *trans,
2247 		struct xlog_recover_item *item, int pass),
2248 	TP_ARGS(log, trans, item, pass),
2249 	TP_STRUCT__entry(
2250 		__field(dev_t, dev)
2251 		__field(unsigned long, item)
2252 		__field(xlog_tid_t, tid)
2253 		__field(xfs_lsn_t, lsn)
2254 		__field(int, type)
2255 		__field(int, pass)
2256 		__field(int, count)
2257 		__field(int, total)
2258 	),
2259 	TP_fast_assign(
2260 		__entry->dev = log->l_mp->m_super->s_dev;
2261 		__entry->item = (unsigned long)item;
2262 		__entry->tid = trans->r_log_tid;
2263 		__entry->lsn = trans->r_lsn;
2264 		__entry->type = ITEM_TYPE(item);
2265 		__entry->pass = pass;
2266 		__entry->count = item->ri_cnt;
2267 		__entry->total = item->ri_total;
2268 	),
2269 	TP_printk("dev %d:%d tid 0x%x lsn 0x%llx, pass %d, item %p, "
2270 		  "item type %s item region count/total %d/%d",
2271 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2272 		  __entry->tid,
2273 		  __entry->lsn,
2274 		  __entry->pass,
2275 		  (void *)__entry->item,
2276 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
2277 		  __entry->count,
2278 		  __entry->total)
2279 )
2280 
2281 #define DEFINE_LOG_RECOVER_ITEM(name) \
2282 DEFINE_EVENT(xfs_log_recover_item_class, name, \
2283 	TP_PROTO(struct xlog *log, struct xlog_recover *trans, \
2284 		struct xlog_recover_item *item, int pass), \
2285 	TP_ARGS(log, trans, item, pass))
2286 
2287 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add);
2288 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add_cont);
2289 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_head);
2290 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_tail);
2291 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_recover);
2292 
2293 DECLARE_EVENT_CLASS(xfs_log_recover_buf_item_class,
2294 	TP_PROTO(struct xlog *log, struct xfs_buf_log_format *buf_f),
2295 	TP_ARGS(log, buf_f),
2296 	TP_STRUCT__entry(
2297 		__field(dev_t, dev)
2298 		__field(int64_t, blkno)
2299 		__field(unsigned short, len)
2300 		__field(unsigned short, flags)
2301 		__field(unsigned short, size)
2302 		__field(unsigned int, map_size)
2303 	),
2304 	TP_fast_assign(
2305 		__entry->dev = log->l_mp->m_super->s_dev;
2306 		__entry->blkno = buf_f->blf_blkno;
2307 		__entry->len = buf_f->blf_len;
2308 		__entry->flags = buf_f->blf_flags;
2309 		__entry->size = buf_f->blf_size;
2310 		__entry->map_size = buf_f->blf_map_size;
2311 	),
2312 	TP_printk("dev %d:%d daddr 0x%llx, bbcount 0x%x, flags 0x%x, size %d, "
2313 			"map_size %d",
2314 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2315 		  __entry->blkno,
2316 		  __entry->len,
2317 		  __entry->flags,
2318 		  __entry->size,
2319 		  __entry->map_size)
2320 )
2321 
2322 #define DEFINE_LOG_RECOVER_BUF_ITEM(name) \
2323 DEFINE_EVENT(xfs_log_recover_buf_item_class, name, \
2324 	TP_PROTO(struct xlog *log, struct xfs_buf_log_format *buf_f), \
2325 	TP_ARGS(log, buf_f))
2326 
2327 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_not_cancel);
2328 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel);
2329 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_add);
2330 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_ref_inc);
2331 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_recover);
2332 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_skip);
2333 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_inode_buf);
2334 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_reg_buf);
2335 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_dquot_buf);
2336 
2337 DECLARE_EVENT_CLASS(xfs_log_recover_ino_item_class,
2338 	TP_PROTO(struct xlog *log, struct xfs_inode_log_format *in_f),
2339 	TP_ARGS(log, in_f),
2340 	TP_STRUCT__entry(
2341 		__field(dev_t, dev)
2342 		__field(xfs_ino_t, ino)
2343 		__field(unsigned short, size)
2344 		__field(int, fields)
2345 		__field(unsigned short, asize)
2346 		__field(unsigned short, dsize)
2347 		__field(int64_t, blkno)
2348 		__field(int, len)
2349 		__field(int, boffset)
2350 	),
2351 	TP_fast_assign(
2352 		__entry->dev = log->l_mp->m_super->s_dev;
2353 		__entry->ino = in_f->ilf_ino;
2354 		__entry->size = in_f->ilf_size;
2355 		__entry->fields = in_f->ilf_fields;
2356 		__entry->asize = in_f->ilf_asize;
2357 		__entry->dsize = in_f->ilf_dsize;
2358 		__entry->blkno = in_f->ilf_blkno;
2359 		__entry->len = in_f->ilf_len;
2360 		__entry->boffset = in_f->ilf_boffset;
2361 	),
2362 	TP_printk("dev %d:%d ino 0x%llx, size %u, fields 0x%x, asize %d, "
2363 			"dsize %d, daddr 0x%llx, bbcount 0x%x, boffset %d",
2364 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2365 		  __entry->ino,
2366 		  __entry->size,
2367 		  __entry->fields,
2368 		  __entry->asize,
2369 		  __entry->dsize,
2370 		  __entry->blkno,
2371 		  __entry->len,
2372 		  __entry->boffset)
2373 )
2374 #define DEFINE_LOG_RECOVER_INO_ITEM(name) \
2375 DEFINE_EVENT(xfs_log_recover_ino_item_class, name, \
2376 	TP_PROTO(struct xlog *log, struct xfs_inode_log_format *in_f), \
2377 	TP_ARGS(log, in_f))
2378 
2379 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_recover);
2380 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_cancel);
2381 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_skip);
2382 
2383 DECLARE_EVENT_CLASS(xfs_log_recover_icreate_item_class,
2384 	TP_PROTO(struct xlog *log, struct xfs_icreate_log *in_f),
2385 	TP_ARGS(log, in_f),
2386 	TP_STRUCT__entry(
2387 		__field(dev_t, dev)
2388 		__field(xfs_agnumber_t, agno)
2389 		__field(xfs_agblock_t, agbno)
2390 		__field(unsigned int, count)
2391 		__field(unsigned int, isize)
2392 		__field(xfs_agblock_t, length)
2393 		__field(unsigned int, gen)
2394 	),
2395 	TP_fast_assign(
2396 		__entry->dev = log->l_mp->m_super->s_dev;
2397 		__entry->agno = be32_to_cpu(in_f->icl_ag);
2398 		__entry->agbno = be32_to_cpu(in_f->icl_agbno);
2399 		__entry->count = be32_to_cpu(in_f->icl_count);
2400 		__entry->isize = be32_to_cpu(in_f->icl_isize);
2401 		__entry->length = be32_to_cpu(in_f->icl_length);
2402 		__entry->gen = be32_to_cpu(in_f->icl_gen);
2403 	),
2404 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x ireccount %u isize %u gen 0x%x",
2405 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2406 		  __entry->agno,
2407 		  __entry->agbno,
2408 		  __entry->length,
2409 		  __entry->count,
2410 		  __entry->isize,
2411 		  __entry->gen)
2412 )
2413 #define DEFINE_LOG_RECOVER_ICREATE_ITEM(name) \
2414 DEFINE_EVENT(xfs_log_recover_icreate_item_class, name, \
2415 	TP_PROTO(struct xlog *log, struct xfs_icreate_log *in_f), \
2416 	TP_ARGS(log, in_f))
2417 
2418 DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_cancel);
2419 DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_recover);
2420 
2421 DECLARE_EVENT_CLASS(xfs_discard_class,
2422 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2423 		 xfs_agblock_t agbno, xfs_extlen_t len),
2424 	TP_ARGS(mp, agno, agbno, len),
2425 	TP_STRUCT__entry(
2426 		__field(dev_t, dev)
2427 		__field(xfs_agnumber_t, agno)
2428 		__field(xfs_agblock_t, agbno)
2429 		__field(xfs_extlen_t, len)
2430 	),
2431 	TP_fast_assign(
2432 		__entry->dev = mp->m_super->s_dev;
2433 		__entry->agno = agno;
2434 		__entry->agbno = agbno;
2435 		__entry->len = len;
2436 	),
2437 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
2438 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2439 		  __entry->agno,
2440 		  __entry->agbno,
2441 		  __entry->len)
2442 )
2443 
2444 #define DEFINE_DISCARD_EVENT(name) \
2445 DEFINE_EVENT(xfs_discard_class, name, \
2446 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2447 		 xfs_agblock_t agbno, xfs_extlen_t len), \
2448 	TP_ARGS(mp, agno, agbno, len))
2449 DEFINE_DISCARD_EVENT(xfs_discard_extent);
2450 DEFINE_DISCARD_EVENT(xfs_discard_toosmall);
2451 DEFINE_DISCARD_EVENT(xfs_discard_exclude);
2452 DEFINE_DISCARD_EVENT(xfs_discard_busy);
2453 
2454 /* btree cursor events */
2455 TRACE_DEFINE_ENUM(XFS_BTNUM_BNOi);
2456 TRACE_DEFINE_ENUM(XFS_BTNUM_CNTi);
2457 TRACE_DEFINE_ENUM(XFS_BTNUM_BMAPi);
2458 TRACE_DEFINE_ENUM(XFS_BTNUM_INOi);
2459 TRACE_DEFINE_ENUM(XFS_BTNUM_FINOi);
2460 TRACE_DEFINE_ENUM(XFS_BTNUM_RMAPi);
2461 TRACE_DEFINE_ENUM(XFS_BTNUM_REFCi);
2462 
2463 DECLARE_EVENT_CLASS(xfs_btree_cur_class,
2464 	TP_PROTO(struct xfs_btree_cur *cur, int level, struct xfs_buf *bp),
2465 	TP_ARGS(cur, level, bp),
2466 	TP_STRUCT__entry(
2467 		__field(dev_t, dev)
2468 		__field(xfs_btnum_t, btnum)
2469 		__field(int, level)
2470 		__field(int, nlevels)
2471 		__field(int, ptr)
2472 		__field(xfs_daddr_t, daddr)
2473 	),
2474 	TP_fast_assign(
2475 		__entry->dev = cur->bc_mp->m_super->s_dev;
2476 		__entry->btnum = cur->bc_btnum;
2477 		__entry->level = level;
2478 		__entry->nlevels = cur->bc_nlevels;
2479 		__entry->ptr = cur->bc_levels[level].ptr;
2480 		__entry->daddr = bp ? xfs_buf_daddr(bp) : -1;
2481 	),
2482 	TP_printk("dev %d:%d btree %s level %d/%d ptr %d daddr 0x%llx",
2483 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2484 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
2485 		  __entry->level,
2486 		  __entry->nlevels,
2487 		  __entry->ptr,
2488 		  (unsigned long long)__entry->daddr)
2489 )
2490 
2491 #define DEFINE_BTREE_CUR_EVENT(name) \
2492 DEFINE_EVENT(xfs_btree_cur_class, name, \
2493 	TP_PROTO(struct xfs_btree_cur *cur, int level, struct xfs_buf *bp), \
2494 	TP_ARGS(cur, level, bp))
2495 DEFINE_BTREE_CUR_EVENT(xfs_btree_updkeys);
2496 DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range);
2497 
2498 /* deferred ops */
2499 struct xfs_defer_pending;
2500 
2501 DECLARE_EVENT_CLASS(xfs_defer_class,
2502 	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
2503 	TP_ARGS(tp, caller_ip),
2504 	TP_STRUCT__entry(
2505 		__field(dev_t, dev)
2506 		__field(struct xfs_trans *, tp)
2507 		__field(char, committed)
2508 		__field(unsigned long, caller_ip)
2509 	),
2510 	TP_fast_assign(
2511 		__entry->dev = tp->t_mountp->m_super->s_dev;
2512 		__entry->tp = tp;
2513 		__entry->caller_ip = caller_ip;
2514 	),
2515 	TP_printk("dev %d:%d tp %p caller %pS",
2516 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2517 		  __entry->tp,
2518 		  (char *)__entry->caller_ip)
2519 )
2520 #define DEFINE_DEFER_EVENT(name) \
2521 DEFINE_EVENT(xfs_defer_class, name, \
2522 	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip), \
2523 	TP_ARGS(tp, caller_ip))
2524 
2525 DECLARE_EVENT_CLASS(xfs_defer_error_class,
2526 	TP_PROTO(struct xfs_trans *tp, int error),
2527 	TP_ARGS(tp, error),
2528 	TP_STRUCT__entry(
2529 		__field(dev_t, dev)
2530 		__field(struct xfs_trans *, tp)
2531 		__field(char, committed)
2532 		__field(int, error)
2533 	),
2534 	TP_fast_assign(
2535 		__entry->dev = tp->t_mountp->m_super->s_dev;
2536 		__entry->tp = tp;
2537 		__entry->error = error;
2538 	),
2539 	TP_printk("dev %d:%d tp %p err %d",
2540 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2541 		  __entry->tp,
2542 		  __entry->error)
2543 )
2544 #define DEFINE_DEFER_ERROR_EVENT(name) \
2545 DEFINE_EVENT(xfs_defer_error_class, name, \
2546 	TP_PROTO(struct xfs_trans *tp, int error), \
2547 	TP_ARGS(tp, error))
2548 
2549 DECLARE_EVENT_CLASS(xfs_defer_pending_class,
2550 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp),
2551 	TP_ARGS(mp, dfp),
2552 	TP_STRUCT__entry(
2553 		__field(dev_t, dev)
2554 		__field(int, type)
2555 		__field(void *, intent)
2556 		__field(char, committed)
2557 		__field(int, nr)
2558 	),
2559 	TP_fast_assign(
2560 		__entry->dev = mp ? mp->m_super->s_dev : 0;
2561 		__entry->type = dfp->dfp_type;
2562 		__entry->intent = dfp->dfp_intent;
2563 		__entry->committed = dfp->dfp_done != NULL;
2564 		__entry->nr = dfp->dfp_count;
2565 	),
2566 	TP_printk("dev %d:%d optype %d intent %p committed %d nr %d",
2567 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2568 		  __entry->type,
2569 		  __entry->intent,
2570 		  __entry->committed,
2571 		  __entry->nr)
2572 )
2573 #define DEFINE_DEFER_PENDING_EVENT(name) \
2574 DEFINE_EVENT(xfs_defer_pending_class, name, \
2575 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp), \
2576 	TP_ARGS(mp, dfp))
2577 
2578 DECLARE_EVENT_CLASS(xfs_phys_extent_deferred_class,
2579 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2580 		 int type, xfs_agblock_t agbno, xfs_extlen_t len),
2581 	TP_ARGS(mp, agno, type, agbno, len),
2582 	TP_STRUCT__entry(
2583 		__field(dev_t, dev)
2584 		__field(xfs_agnumber_t, agno)
2585 		__field(int, type)
2586 		__field(xfs_agblock_t, agbno)
2587 		__field(xfs_extlen_t, len)
2588 	),
2589 	TP_fast_assign(
2590 		__entry->dev = mp->m_super->s_dev;
2591 		__entry->agno = agno;
2592 		__entry->type = type;
2593 		__entry->agbno = agbno;
2594 		__entry->len = len;
2595 	),
2596 	TP_printk("dev %d:%d op %d agno 0x%x agbno 0x%x fsbcount 0x%x",
2597 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2598 		  __entry->type,
2599 		  __entry->agno,
2600 		  __entry->agbno,
2601 		  __entry->len)
2602 );
2603 #define DEFINE_PHYS_EXTENT_DEFERRED_EVENT(name) \
2604 DEFINE_EVENT(xfs_phys_extent_deferred_class, name, \
2605 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2606 		 int type, \
2607 		 xfs_agblock_t bno, \
2608 		 xfs_extlen_t len), \
2609 	TP_ARGS(mp, agno, type, bno, len))
2610 
2611 DECLARE_EVENT_CLASS(xfs_map_extent_deferred_class,
2612 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2613 		 int op,
2614 		 xfs_agblock_t agbno,
2615 		 xfs_ino_t ino,
2616 		 int whichfork,
2617 		 xfs_fileoff_t offset,
2618 		 xfs_filblks_t len,
2619 		 xfs_exntst_t state),
2620 	TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state),
2621 	TP_STRUCT__entry(
2622 		__field(dev_t, dev)
2623 		__field(xfs_agnumber_t, agno)
2624 		__field(xfs_ino_t, ino)
2625 		__field(xfs_agblock_t, agbno)
2626 		__field(int, whichfork)
2627 		__field(xfs_fileoff_t, l_loff)
2628 		__field(xfs_filblks_t, l_len)
2629 		__field(xfs_exntst_t, l_state)
2630 		__field(int, op)
2631 	),
2632 	TP_fast_assign(
2633 		__entry->dev = mp->m_super->s_dev;
2634 		__entry->agno = agno;
2635 		__entry->ino = ino;
2636 		__entry->agbno = agbno;
2637 		__entry->whichfork = whichfork;
2638 		__entry->l_loff = offset;
2639 		__entry->l_len = len;
2640 		__entry->l_state = state;
2641 		__entry->op = op;
2642 	),
2643 	TP_printk("dev %d:%d op %d agno 0x%x agbno 0x%x owner 0x%llx %s fileoff 0x%llx fsbcount 0x%llx state %d",
2644 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2645 		  __entry->op,
2646 		  __entry->agno,
2647 		  __entry->agbno,
2648 		  __entry->ino,
2649 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
2650 		  __entry->l_loff,
2651 		  __entry->l_len,
2652 		  __entry->l_state)
2653 );
2654 #define DEFINE_MAP_EXTENT_DEFERRED_EVENT(name) \
2655 DEFINE_EVENT(xfs_map_extent_deferred_class, name, \
2656 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2657 		 int op, \
2658 		 xfs_agblock_t agbno, \
2659 		 xfs_ino_t ino, \
2660 		 int whichfork, \
2661 		 xfs_fileoff_t offset, \
2662 		 xfs_filblks_t len, \
2663 		 xfs_exntst_t state), \
2664 	TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state))
2665 
2666 DEFINE_DEFER_EVENT(xfs_defer_cancel);
2667 DEFINE_DEFER_EVENT(xfs_defer_trans_roll);
2668 DEFINE_DEFER_EVENT(xfs_defer_trans_abort);
2669 DEFINE_DEFER_EVENT(xfs_defer_finish);
2670 DEFINE_DEFER_EVENT(xfs_defer_finish_done);
2671 
2672 DEFINE_DEFER_ERROR_EVENT(xfs_defer_trans_roll_error);
2673 DEFINE_DEFER_ERROR_EVENT(xfs_defer_finish_error);
2674 
2675 DEFINE_DEFER_PENDING_EVENT(xfs_defer_create_intent);
2676 DEFINE_DEFER_PENDING_EVENT(xfs_defer_cancel_list);
2677 DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_finish);
2678 DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_abort);
2679 DEFINE_DEFER_PENDING_EVENT(xfs_defer_relog_intent);
2680 
2681 #define DEFINE_BMAP_FREE_DEFERRED_EVENT DEFINE_PHYS_EXTENT_DEFERRED_EVENT
2682 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_bmap_free_defer);
2683 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_bmap_free_deferred);
2684 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_agfl_free_defer);
2685 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_agfl_free_deferred);
2686 
2687 /* rmap tracepoints */
2688 DECLARE_EVENT_CLASS(xfs_rmap_class,
2689 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2690 		 xfs_agblock_t agbno, xfs_extlen_t len, bool unwritten,
2691 		 const struct xfs_owner_info *oinfo),
2692 	TP_ARGS(mp, agno, agbno, len, unwritten, oinfo),
2693 	TP_STRUCT__entry(
2694 		__field(dev_t, dev)
2695 		__field(xfs_agnumber_t, agno)
2696 		__field(xfs_agblock_t, agbno)
2697 		__field(xfs_extlen_t, len)
2698 		__field(uint64_t, owner)
2699 		__field(uint64_t, offset)
2700 		__field(unsigned long, flags)
2701 	),
2702 	TP_fast_assign(
2703 		__entry->dev = mp->m_super->s_dev;
2704 		__entry->agno = agno;
2705 		__entry->agbno = agbno;
2706 		__entry->len = len;
2707 		__entry->owner = oinfo->oi_owner;
2708 		__entry->offset = oinfo->oi_offset;
2709 		__entry->flags = oinfo->oi_flags;
2710 		if (unwritten)
2711 			__entry->flags |= XFS_RMAP_UNWRITTEN;
2712 	),
2713 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%lx",
2714 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2715 		  __entry->agno,
2716 		  __entry->agbno,
2717 		  __entry->len,
2718 		  __entry->owner,
2719 		  __entry->offset,
2720 		  __entry->flags)
2721 );
2722 #define DEFINE_RMAP_EVENT(name) \
2723 DEFINE_EVENT(xfs_rmap_class, name, \
2724 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2725 		 xfs_agblock_t agbno, xfs_extlen_t len, bool unwritten, \
2726 		 const struct xfs_owner_info *oinfo), \
2727 	TP_ARGS(mp, agno, agbno, len, unwritten, oinfo))
2728 
2729 /* simple AG-based error/%ip tracepoint class */
2730 DECLARE_EVENT_CLASS(xfs_ag_error_class,
2731 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error,
2732 		 unsigned long caller_ip),
2733 	TP_ARGS(mp, agno, error, caller_ip),
2734 	TP_STRUCT__entry(
2735 		__field(dev_t, dev)
2736 		__field(xfs_agnumber_t, agno)
2737 		__field(int, error)
2738 		__field(unsigned long, caller_ip)
2739 	),
2740 	TP_fast_assign(
2741 		__entry->dev = mp->m_super->s_dev;
2742 		__entry->agno = agno;
2743 		__entry->error = error;
2744 		__entry->caller_ip = caller_ip;
2745 	),
2746 	TP_printk("dev %d:%d agno 0x%x error %d caller %pS",
2747 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2748 		  __entry->agno,
2749 		  __entry->error,
2750 		  (char *)__entry->caller_ip)
2751 );
2752 
2753 #define DEFINE_AG_ERROR_EVENT(name) \
2754 DEFINE_EVENT(xfs_ag_error_class, name, \
2755 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error, \
2756 		 unsigned long caller_ip), \
2757 	TP_ARGS(mp, agno, error, caller_ip))
2758 
2759 DEFINE_RMAP_EVENT(xfs_rmap_unmap);
2760 DEFINE_RMAP_EVENT(xfs_rmap_unmap_done);
2761 DEFINE_AG_ERROR_EVENT(xfs_rmap_unmap_error);
2762 DEFINE_RMAP_EVENT(xfs_rmap_map);
2763 DEFINE_RMAP_EVENT(xfs_rmap_map_done);
2764 DEFINE_AG_ERROR_EVENT(xfs_rmap_map_error);
2765 DEFINE_RMAP_EVENT(xfs_rmap_convert);
2766 DEFINE_RMAP_EVENT(xfs_rmap_convert_done);
2767 DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_error);
2768 DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_state);
2769 
2770 DECLARE_EVENT_CLASS(xfs_rmapbt_class,
2771 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2772 		 xfs_agblock_t agbno, xfs_extlen_t len,
2773 		 uint64_t owner, uint64_t offset, unsigned int flags),
2774 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
2775 	TP_STRUCT__entry(
2776 		__field(dev_t, dev)
2777 		__field(xfs_agnumber_t, agno)
2778 		__field(xfs_agblock_t, agbno)
2779 		__field(xfs_extlen_t, len)
2780 		__field(uint64_t, owner)
2781 		__field(uint64_t, offset)
2782 		__field(unsigned int, flags)
2783 	),
2784 	TP_fast_assign(
2785 		__entry->dev = mp->m_super->s_dev;
2786 		__entry->agno = agno;
2787 		__entry->agbno = agbno;
2788 		__entry->len = len;
2789 		__entry->owner = owner;
2790 		__entry->offset = offset;
2791 		__entry->flags = flags;
2792 	),
2793 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x owner 0x%llx fileoff 0x%llx flags 0x%x",
2794 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2795 		  __entry->agno,
2796 		  __entry->agbno,
2797 		  __entry->len,
2798 		  __entry->owner,
2799 		  __entry->offset,
2800 		  __entry->flags)
2801 );
2802 #define DEFINE_RMAPBT_EVENT(name) \
2803 DEFINE_EVENT(xfs_rmapbt_class, name, \
2804 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2805 		 xfs_agblock_t agbno, xfs_extlen_t len, \
2806 		 uint64_t owner, uint64_t offset, unsigned int flags), \
2807 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
2808 
2809 #define DEFINE_RMAP_DEFERRED_EVENT DEFINE_MAP_EXTENT_DEFERRED_EVENT
2810 DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_defer);
2811 DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_deferred);
2812 
2813 DEFINE_BUSY_EVENT(xfs_rmapbt_alloc_block);
2814 DEFINE_BUSY_EVENT(xfs_rmapbt_free_block);
2815 DEFINE_RMAPBT_EVENT(xfs_rmap_update);
2816 DEFINE_RMAPBT_EVENT(xfs_rmap_insert);
2817 DEFINE_RMAPBT_EVENT(xfs_rmap_delete);
2818 DEFINE_AG_ERROR_EVENT(xfs_rmap_insert_error);
2819 DEFINE_AG_ERROR_EVENT(xfs_rmap_delete_error);
2820 DEFINE_AG_ERROR_EVENT(xfs_rmap_update_error);
2821 
2822 DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_candidate);
2823 DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_query);
2824 DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_candidate);
2825 DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range);
2826 DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_result);
2827 DEFINE_RMAPBT_EVENT(xfs_rmap_find_right_neighbor_result);
2828 DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_result);
2829 
2830 /* deferred bmbt updates */
2831 #define DEFINE_BMAP_DEFERRED_EVENT	DEFINE_RMAP_DEFERRED_EVENT
2832 DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_defer);
2833 DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_deferred);
2834 
2835 /* per-AG reservation */
2836 DECLARE_EVENT_CLASS(xfs_ag_resv_class,
2837 	TP_PROTO(struct xfs_perag *pag, enum xfs_ag_resv_type resv,
2838 		 xfs_extlen_t len),
2839 	TP_ARGS(pag, resv, len),
2840 	TP_STRUCT__entry(
2841 		__field(dev_t, dev)
2842 		__field(xfs_agnumber_t, agno)
2843 		__field(int, resv)
2844 		__field(xfs_extlen_t, freeblks)
2845 		__field(xfs_extlen_t, flcount)
2846 		__field(xfs_extlen_t, reserved)
2847 		__field(xfs_extlen_t, asked)
2848 		__field(xfs_extlen_t, len)
2849 	),
2850 	TP_fast_assign(
2851 		struct xfs_ag_resv	*r = xfs_perag_resv(pag, resv);
2852 
2853 		__entry->dev = pag->pag_mount->m_super->s_dev;
2854 		__entry->agno = pag->pag_agno;
2855 		__entry->resv = resv;
2856 		__entry->freeblks = pag->pagf_freeblks;
2857 		__entry->flcount = pag->pagf_flcount;
2858 		__entry->reserved = r ? r->ar_reserved : 0;
2859 		__entry->asked = r ? r->ar_asked : 0;
2860 		__entry->len = len;
2861 	),
2862 	TP_printk("dev %d:%d agno 0x%x resv %d freeblks %u flcount %u "
2863 		  "resv %u ask %u len %u",
2864 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2865 		  __entry->agno,
2866 		  __entry->resv,
2867 		  __entry->freeblks,
2868 		  __entry->flcount,
2869 		  __entry->reserved,
2870 		  __entry->asked,
2871 		  __entry->len)
2872 )
2873 #define DEFINE_AG_RESV_EVENT(name) \
2874 DEFINE_EVENT(xfs_ag_resv_class, name, \
2875 	TP_PROTO(struct xfs_perag *pag, enum xfs_ag_resv_type type, \
2876 		 xfs_extlen_t len), \
2877 	TP_ARGS(pag, type, len))
2878 
2879 /* per-AG reservation tracepoints */
2880 DEFINE_AG_RESV_EVENT(xfs_ag_resv_init);
2881 DEFINE_AG_RESV_EVENT(xfs_ag_resv_free);
2882 DEFINE_AG_RESV_EVENT(xfs_ag_resv_alloc_extent);
2883 DEFINE_AG_RESV_EVENT(xfs_ag_resv_free_extent);
2884 DEFINE_AG_RESV_EVENT(xfs_ag_resv_critical);
2885 DEFINE_AG_RESV_EVENT(xfs_ag_resv_needed);
2886 
2887 DEFINE_AG_ERROR_EVENT(xfs_ag_resv_free_error);
2888 DEFINE_AG_ERROR_EVENT(xfs_ag_resv_init_error);
2889 
2890 /* refcount tracepoint classes */
2891 
2892 /* reuse the discard trace class for agbno/aglen-based traces */
2893 #define DEFINE_AG_EXTENT_EVENT(name) DEFINE_DISCARD_EVENT(name)
2894 
2895 /* ag btree lookup tracepoint class */
2896 TRACE_DEFINE_ENUM(XFS_LOOKUP_EQi);
2897 TRACE_DEFINE_ENUM(XFS_LOOKUP_LEi);
2898 TRACE_DEFINE_ENUM(XFS_LOOKUP_GEi);
2899 DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class,
2900 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2901 		 xfs_agblock_t agbno, xfs_lookup_t dir),
2902 	TP_ARGS(mp, agno, agbno, dir),
2903 	TP_STRUCT__entry(
2904 		__field(dev_t, dev)
2905 		__field(xfs_agnumber_t, agno)
2906 		__field(xfs_agblock_t, agbno)
2907 		__field(xfs_lookup_t, dir)
2908 	),
2909 	TP_fast_assign(
2910 		__entry->dev = mp->m_super->s_dev;
2911 		__entry->agno = agno;
2912 		__entry->agbno = agbno;
2913 		__entry->dir = dir;
2914 	),
2915 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x cmp %s(%d)",
2916 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2917 		  __entry->agno,
2918 		  __entry->agbno,
2919 		  __print_symbolic(__entry->dir, XFS_AG_BTREE_CMP_FORMAT_STR),
2920 		  __entry->dir)
2921 )
2922 
2923 #define DEFINE_AG_BTREE_LOOKUP_EVENT(name) \
2924 DEFINE_EVENT(xfs_ag_btree_lookup_class, name, \
2925 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2926 		 xfs_agblock_t agbno, xfs_lookup_t dir), \
2927 	TP_ARGS(mp, agno, agbno, dir))
2928 
2929 /* single-rcext tracepoint class */
2930 DECLARE_EVENT_CLASS(xfs_refcount_extent_class,
2931 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2932 		 struct xfs_refcount_irec *irec),
2933 	TP_ARGS(mp, agno, irec),
2934 	TP_STRUCT__entry(
2935 		__field(dev_t, dev)
2936 		__field(xfs_agnumber_t, agno)
2937 		__field(xfs_agblock_t, startblock)
2938 		__field(xfs_extlen_t, blockcount)
2939 		__field(xfs_nlink_t, refcount)
2940 	),
2941 	TP_fast_assign(
2942 		__entry->dev = mp->m_super->s_dev;
2943 		__entry->agno = agno;
2944 		__entry->startblock = irec->rc_startblock;
2945 		__entry->blockcount = irec->rc_blockcount;
2946 		__entry->refcount = irec->rc_refcount;
2947 	),
2948 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x refcount %u",
2949 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2950 		  __entry->agno,
2951 		  __entry->startblock,
2952 		  __entry->blockcount,
2953 		  __entry->refcount)
2954 )
2955 
2956 #define DEFINE_REFCOUNT_EXTENT_EVENT(name) \
2957 DEFINE_EVENT(xfs_refcount_extent_class, name, \
2958 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2959 		 struct xfs_refcount_irec *irec), \
2960 	TP_ARGS(mp, agno, irec))
2961 
2962 /* single-rcext and an agbno tracepoint class */
2963 DECLARE_EVENT_CLASS(xfs_refcount_extent_at_class,
2964 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2965 		 struct xfs_refcount_irec *irec, xfs_agblock_t agbno),
2966 	TP_ARGS(mp, agno, irec, agbno),
2967 	TP_STRUCT__entry(
2968 		__field(dev_t, dev)
2969 		__field(xfs_agnumber_t, agno)
2970 		__field(xfs_agblock_t, startblock)
2971 		__field(xfs_extlen_t, blockcount)
2972 		__field(xfs_nlink_t, refcount)
2973 		__field(xfs_agblock_t, agbno)
2974 	),
2975 	TP_fast_assign(
2976 		__entry->dev = mp->m_super->s_dev;
2977 		__entry->agno = agno;
2978 		__entry->startblock = irec->rc_startblock;
2979 		__entry->blockcount = irec->rc_blockcount;
2980 		__entry->refcount = irec->rc_refcount;
2981 		__entry->agbno = agbno;
2982 	),
2983 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x refcount %u @ agbno 0x%x",
2984 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2985 		  __entry->agno,
2986 		  __entry->startblock,
2987 		  __entry->blockcount,
2988 		  __entry->refcount,
2989 		  __entry->agbno)
2990 )
2991 
2992 #define DEFINE_REFCOUNT_EXTENT_AT_EVENT(name) \
2993 DEFINE_EVENT(xfs_refcount_extent_at_class, name, \
2994 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2995 		 struct xfs_refcount_irec *irec, xfs_agblock_t agbno), \
2996 	TP_ARGS(mp, agno, irec, agbno))
2997 
2998 /* double-rcext tracepoint class */
2999 DECLARE_EVENT_CLASS(xfs_refcount_double_extent_class,
3000 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3001 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2),
3002 	TP_ARGS(mp, agno, i1, i2),
3003 	TP_STRUCT__entry(
3004 		__field(dev_t, dev)
3005 		__field(xfs_agnumber_t, agno)
3006 		__field(xfs_agblock_t, i1_startblock)
3007 		__field(xfs_extlen_t, i1_blockcount)
3008 		__field(xfs_nlink_t, i1_refcount)
3009 		__field(xfs_agblock_t, i2_startblock)
3010 		__field(xfs_extlen_t, i2_blockcount)
3011 		__field(xfs_nlink_t, i2_refcount)
3012 	),
3013 	TP_fast_assign(
3014 		__entry->dev = mp->m_super->s_dev;
3015 		__entry->agno = agno;
3016 		__entry->i1_startblock = i1->rc_startblock;
3017 		__entry->i1_blockcount = i1->rc_blockcount;
3018 		__entry->i1_refcount = i1->rc_refcount;
3019 		__entry->i2_startblock = i2->rc_startblock;
3020 		__entry->i2_blockcount = i2->rc_blockcount;
3021 		__entry->i2_refcount = i2->rc_refcount;
3022 	),
3023 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x refcount %u -- "
3024 		  "agbno 0x%x fsbcount 0x%x refcount %u",
3025 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3026 		  __entry->agno,
3027 		  __entry->i1_startblock,
3028 		  __entry->i1_blockcount,
3029 		  __entry->i1_refcount,
3030 		  __entry->i2_startblock,
3031 		  __entry->i2_blockcount,
3032 		  __entry->i2_refcount)
3033 )
3034 
3035 #define DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(name) \
3036 DEFINE_EVENT(xfs_refcount_double_extent_class, name, \
3037 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3038 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2), \
3039 	TP_ARGS(mp, agno, i1, i2))
3040 
3041 /* double-rcext and an agbno tracepoint class */
3042 DECLARE_EVENT_CLASS(xfs_refcount_double_extent_at_class,
3043 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3044 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2,
3045 		 xfs_agblock_t agbno),
3046 	TP_ARGS(mp, agno, i1, i2, agbno),
3047 	TP_STRUCT__entry(
3048 		__field(dev_t, dev)
3049 		__field(xfs_agnumber_t, agno)
3050 		__field(xfs_agblock_t, i1_startblock)
3051 		__field(xfs_extlen_t, i1_blockcount)
3052 		__field(xfs_nlink_t, i1_refcount)
3053 		__field(xfs_agblock_t, i2_startblock)
3054 		__field(xfs_extlen_t, i2_blockcount)
3055 		__field(xfs_nlink_t, i2_refcount)
3056 		__field(xfs_agblock_t, agbno)
3057 	),
3058 	TP_fast_assign(
3059 		__entry->dev = mp->m_super->s_dev;
3060 		__entry->agno = agno;
3061 		__entry->i1_startblock = i1->rc_startblock;
3062 		__entry->i1_blockcount = i1->rc_blockcount;
3063 		__entry->i1_refcount = i1->rc_refcount;
3064 		__entry->i2_startblock = i2->rc_startblock;
3065 		__entry->i2_blockcount = i2->rc_blockcount;
3066 		__entry->i2_refcount = i2->rc_refcount;
3067 		__entry->agbno = agbno;
3068 	),
3069 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x refcount %u -- "
3070 		  "agbno 0x%x fsbcount 0x%x refcount %u @ agbno 0x%x",
3071 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3072 		  __entry->agno,
3073 		  __entry->i1_startblock,
3074 		  __entry->i1_blockcount,
3075 		  __entry->i1_refcount,
3076 		  __entry->i2_startblock,
3077 		  __entry->i2_blockcount,
3078 		  __entry->i2_refcount,
3079 		  __entry->agbno)
3080 )
3081 
3082 #define DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(name) \
3083 DEFINE_EVENT(xfs_refcount_double_extent_at_class, name, \
3084 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3085 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \
3086 		 xfs_agblock_t agbno), \
3087 	TP_ARGS(mp, agno, i1, i2, agbno))
3088 
3089 /* triple-rcext tracepoint class */
3090 DECLARE_EVENT_CLASS(xfs_refcount_triple_extent_class,
3091 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3092 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2,
3093 		 struct xfs_refcount_irec *i3),
3094 	TP_ARGS(mp, agno, i1, i2, i3),
3095 	TP_STRUCT__entry(
3096 		__field(dev_t, dev)
3097 		__field(xfs_agnumber_t, agno)
3098 		__field(xfs_agblock_t, i1_startblock)
3099 		__field(xfs_extlen_t, i1_blockcount)
3100 		__field(xfs_nlink_t, i1_refcount)
3101 		__field(xfs_agblock_t, i2_startblock)
3102 		__field(xfs_extlen_t, i2_blockcount)
3103 		__field(xfs_nlink_t, i2_refcount)
3104 		__field(xfs_agblock_t, i3_startblock)
3105 		__field(xfs_extlen_t, i3_blockcount)
3106 		__field(xfs_nlink_t, i3_refcount)
3107 	),
3108 	TP_fast_assign(
3109 		__entry->dev = mp->m_super->s_dev;
3110 		__entry->agno = agno;
3111 		__entry->i1_startblock = i1->rc_startblock;
3112 		__entry->i1_blockcount = i1->rc_blockcount;
3113 		__entry->i1_refcount = i1->rc_refcount;
3114 		__entry->i2_startblock = i2->rc_startblock;
3115 		__entry->i2_blockcount = i2->rc_blockcount;
3116 		__entry->i2_refcount = i2->rc_refcount;
3117 		__entry->i3_startblock = i3->rc_startblock;
3118 		__entry->i3_blockcount = i3->rc_blockcount;
3119 		__entry->i3_refcount = i3->rc_refcount;
3120 	),
3121 	TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x refcount %u -- "
3122 		  "agbno 0x%x fsbcount 0x%x refcount %u -- "
3123 		  "agbno 0x%x fsbcount 0x%x refcount %u",
3124 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3125 		  __entry->agno,
3126 		  __entry->i1_startblock,
3127 		  __entry->i1_blockcount,
3128 		  __entry->i1_refcount,
3129 		  __entry->i2_startblock,
3130 		  __entry->i2_blockcount,
3131 		  __entry->i2_refcount,
3132 		  __entry->i3_startblock,
3133 		  __entry->i3_blockcount,
3134 		  __entry->i3_refcount)
3135 );
3136 
3137 #define DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(name) \
3138 DEFINE_EVENT(xfs_refcount_triple_extent_class, name, \
3139 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3140 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \
3141 		 struct xfs_refcount_irec *i3), \
3142 	TP_ARGS(mp, agno, i1, i2, i3))
3143 
3144 /* refcount btree tracepoints */
3145 DEFINE_BUSY_EVENT(xfs_refcountbt_alloc_block);
3146 DEFINE_BUSY_EVENT(xfs_refcountbt_free_block);
3147 DEFINE_AG_BTREE_LOOKUP_EVENT(xfs_refcount_lookup);
3148 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get);
3149 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_update);
3150 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_insert);
3151 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_delete);
3152 DEFINE_AG_ERROR_EVENT(xfs_refcount_insert_error);
3153 DEFINE_AG_ERROR_EVENT(xfs_refcount_delete_error);
3154 DEFINE_AG_ERROR_EVENT(xfs_refcount_update_error);
3155 
3156 /* refcount adjustment tracepoints */
3157 DEFINE_AG_EXTENT_EVENT(xfs_refcount_increase);
3158 DEFINE_AG_EXTENT_EVENT(xfs_refcount_decrease);
3159 DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_increase);
3160 DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_decrease);
3161 DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(xfs_refcount_merge_center_extents);
3162 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_modify_extent);
3163 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_recover_extent);
3164 DEFINE_REFCOUNT_EXTENT_AT_EVENT(xfs_refcount_split_extent);
3165 DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_left_extent);
3166 DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_right_extent);
3167 DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_left_extent);
3168 DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_right_extent);
3169 DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_error);
3170 DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_cow_error);
3171 DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_center_extents_error);
3172 DEFINE_AG_ERROR_EVENT(xfs_refcount_modify_extent_error);
3173 DEFINE_AG_ERROR_EVENT(xfs_refcount_split_extent_error);
3174 DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_left_extent_error);
3175 DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_right_extent_error);
3176 DEFINE_AG_ERROR_EVENT(xfs_refcount_find_left_extent_error);
3177 DEFINE_AG_ERROR_EVENT(xfs_refcount_find_right_extent_error);
3178 
3179 /* reflink helpers */
3180 DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared);
3181 DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared_result);
3182 DEFINE_AG_ERROR_EVENT(xfs_refcount_find_shared_error);
3183 #define DEFINE_REFCOUNT_DEFERRED_EVENT DEFINE_PHYS_EXTENT_DEFERRED_EVENT
3184 DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_defer);
3185 DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_deferred);
3186 
3187 TRACE_EVENT(xfs_refcount_finish_one_leftover,
3188 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3189 		 int type, xfs_agblock_t agbno, xfs_extlen_t len,
3190 		 xfs_agblock_t new_agbno, xfs_extlen_t new_len),
3191 	TP_ARGS(mp, agno, type, agbno, len, new_agbno, new_len),
3192 	TP_STRUCT__entry(
3193 		__field(dev_t, dev)
3194 		__field(xfs_agnumber_t, agno)
3195 		__field(int, type)
3196 		__field(xfs_agblock_t, agbno)
3197 		__field(xfs_extlen_t, len)
3198 		__field(xfs_agblock_t, new_agbno)
3199 		__field(xfs_extlen_t, new_len)
3200 	),
3201 	TP_fast_assign(
3202 		__entry->dev = mp->m_super->s_dev;
3203 		__entry->agno = agno;
3204 		__entry->type = type;
3205 		__entry->agbno = agbno;
3206 		__entry->len = len;
3207 		__entry->new_agbno = new_agbno;
3208 		__entry->new_len = new_len;
3209 	),
3210 	TP_printk("dev %d:%d type %d agno 0x%x agbno 0x%x fsbcount 0x%x new_agbno 0x%x new_fsbcount 0x%x",
3211 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3212 		  __entry->type,
3213 		  __entry->agno,
3214 		  __entry->agbno,
3215 		  __entry->len,
3216 		  __entry->new_agbno,
3217 		  __entry->new_len)
3218 );
3219 
3220 /* simple inode-based error/%ip tracepoint class */
3221 DECLARE_EVENT_CLASS(xfs_inode_error_class,
3222 	TP_PROTO(struct xfs_inode *ip, int error, unsigned long caller_ip),
3223 	TP_ARGS(ip, error, caller_ip),
3224 	TP_STRUCT__entry(
3225 		__field(dev_t, dev)
3226 		__field(xfs_ino_t, ino)
3227 		__field(int, error)
3228 		__field(unsigned long, caller_ip)
3229 	),
3230 	TP_fast_assign(
3231 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3232 		__entry->ino = ip->i_ino;
3233 		__entry->error = error;
3234 		__entry->caller_ip = caller_ip;
3235 	),
3236 	TP_printk("dev %d:%d ino 0x%llx error %d caller %pS",
3237 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3238 		  __entry->ino,
3239 		  __entry->error,
3240 		  (char *)__entry->caller_ip)
3241 );
3242 
3243 #define DEFINE_INODE_ERROR_EVENT(name) \
3244 DEFINE_EVENT(xfs_inode_error_class, name, \
3245 	TP_PROTO(struct xfs_inode *ip, int error, \
3246 		 unsigned long caller_ip), \
3247 	TP_ARGS(ip, error, caller_ip))
3248 
3249 /* reflink tracepoint classes */
3250 
3251 /* two-file io tracepoint class */
3252 DECLARE_EVENT_CLASS(xfs_double_io_class,
3253 	TP_PROTO(struct xfs_inode *src, xfs_off_t soffset, xfs_off_t len,
3254 		 struct xfs_inode *dest, xfs_off_t doffset),
3255 	TP_ARGS(src, soffset, len, dest, doffset),
3256 	TP_STRUCT__entry(
3257 		__field(dev_t, dev)
3258 		__field(xfs_ino_t, src_ino)
3259 		__field(loff_t, src_isize)
3260 		__field(loff_t, src_disize)
3261 		__field(loff_t, src_offset)
3262 		__field(long long, len)
3263 		__field(xfs_ino_t, dest_ino)
3264 		__field(loff_t, dest_isize)
3265 		__field(loff_t, dest_disize)
3266 		__field(loff_t, dest_offset)
3267 	),
3268 	TP_fast_assign(
3269 		__entry->dev = VFS_I(src)->i_sb->s_dev;
3270 		__entry->src_ino = src->i_ino;
3271 		__entry->src_isize = VFS_I(src)->i_size;
3272 		__entry->src_disize = src->i_disk_size;
3273 		__entry->src_offset = soffset;
3274 		__entry->len = len;
3275 		__entry->dest_ino = dest->i_ino;
3276 		__entry->dest_isize = VFS_I(dest)->i_size;
3277 		__entry->dest_disize = dest->i_disk_size;
3278 		__entry->dest_offset = doffset;
3279 	),
3280 	TP_printk("dev %d:%d bytecount 0x%llx "
3281 		  "ino 0x%llx isize 0x%llx disize 0x%llx pos 0x%llx -> "
3282 		  "ino 0x%llx isize 0x%llx disize 0x%llx pos 0x%llx",
3283 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3284 		  __entry->len,
3285 		  __entry->src_ino,
3286 		  __entry->src_isize,
3287 		  __entry->src_disize,
3288 		  __entry->src_offset,
3289 		  __entry->dest_ino,
3290 		  __entry->dest_isize,
3291 		  __entry->dest_disize,
3292 		  __entry->dest_offset)
3293 )
3294 
3295 #define DEFINE_DOUBLE_IO_EVENT(name)	\
3296 DEFINE_EVENT(xfs_double_io_class, name,	\
3297 	TP_PROTO(struct xfs_inode *src, xfs_off_t soffset, xfs_off_t len, \
3298 		 struct xfs_inode *dest, xfs_off_t doffset), \
3299 	TP_ARGS(src, soffset, len, dest, doffset))
3300 
3301 /* inode/irec events */
3302 DECLARE_EVENT_CLASS(xfs_inode_irec_class,
3303 	TP_PROTO(struct xfs_inode *ip, struct xfs_bmbt_irec *irec),
3304 	TP_ARGS(ip, irec),
3305 	TP_STRUCT__entry(
3306 		__field(dev_t, dev)
3307 		__field(xfs_ino_t, ino)
3308 		__field(xfs_fileoff_t, lblk)
3309 		__field(xfs_extlen_t, len)
3310 		__field(xfs_fsblock_t, pblk)
3311 		__field(int, state)
3312 	),
3313 	TP_fast_assign(
3314 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3315 		__entry->ino = ip->i_ino;
3316 		__entry->lblk = irec->br_startoff;
3317 		__entry->len = irec->br_blockcount;
3318 		__entry->pblk = irec->br_startblock;
3319 		__entry->state = irec->br_state;
3320 	),
3321 	TP_printk("dev %d:%d ino 0x%llx fileoff 0x%llx fsbcount 0x%x startblock 0x%llx st %d",
3322 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3323 		  __entry->ino,
3324 		  __entry->lblk,
3325 		  __entry->len,
3326 		  __entry->pblk,
3327 		  __entry->state)
3328 );
3329 #define DEFINE_INODE_IREC_EVENT(name) \
3330 DEFINE_EVENT(xfs_inode_irec_class, name, \
3331 	TP_PROTO(struct xfs_inode *ip, struct xfs_bmbt_irec *irec), \
3332 	TP_ARGS(ip, irec))
3333 
3334 /* refcount/reflink tracepoint definitions */
3335 
3336 /* reflink tracepoints */
3337 DEFINE_INODE_EVENT(xfs_reflink_set_inode_flag);
3338 DEFINE_INODE_EVENT(xfs_reflink_unset_inode_flag);
3339 DEFINE_ITRUNC_EVENT(xfs_reflink_update_inode_size);
3340 TRACE_EVENT(xfs_reflink_remap_blocks,
3341 	TP_PROTO(struct xfs_inode *src, xfs_fileoff_t soffset,
3342 		 xfs_filblks_t len, struct xfs_inode *dest,
3343 		 xfs_fileoff_t doffset),
3344 	TP_ARGS(src, soffset, len, dest, doffset),
3345 	TP_STRUCT__entry(
3346 		__field(dev_t, dev)
3347 		__field(xfs_ino_t, src_ino)
3348 		__field(xfs_fileoff_t, src_lblk)
3349 		__field(xfs_filblks_t, len)
3350 		__field(xfs_ino_t, dest_ino)
3351 		__field(xfs_fileoff_t, dest_lblk)
3352 	),
3353 	TP_fast_assign(
3354 		__entry->dev = VFS_I(src)->i_sb->s_dev;
3355 		__entry->src_ino = src->i_ino;
3356 		__entry->src_lblk = soffset;
3357 		__entry->len = len;
3358 		__entry->dest_ino = dest->i_ino;
3359 		__entry->dest_lblk = doffset;
3360 	),
3361 	TP_printk("dev %d:%d fsbcount 0x%llx "
3362 		  "ino 0x%llx fileoff 0x%llx -> ino 0x%llx fileoff 0x%llx",
3363 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3364 		  __entry->len,
3365 		  __entry->src_ino,
3366 		  __entry->src_lblk,
3367 		  __entry->dest_ino,
3368 		  __entry->dest_lblk)
3369 );
3370 DEFINE_DOUBLE_IO_EVENT(xfs_reflink_remap_range);
3371 DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_range_error);
3372 DEFINE_INODE_ERROR_EVENT(xfs_reflink_set_inode_flag_error);
3373 DEFINE_INODE_ERROR_EVENT(xfs_reflink_update_inode_size_error);
3374 DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_blocks_error);
3375 DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_extent_error);
3376 DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_src);
3377 DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_dest);
3378 
3379 /* dedupe tracepoints */
3380 DEFINE_DOUBLE_IO_EVENT(xfs_reflink_compare_extents);
3381 DEFINE_INODE_ERROR_EVENT(xfs_reflink_compare_extents_error);
3382 
3383 /* ioctl tracepoints */
3384 TRACE_EVENT(xfs_ioctl_clone,
3385 	TP_PROTO(struct inode *src, struct inode *dest),
3386 	TP_ARGS(src, dest),
3387 	TP_STRUCT__entry(
3388 		__field(dev_t, dev)
3389 		__field(unsigned long, src_ino)
3390 		__field(loff_t, src_isize)
3391 		__field(unsigned long, dest_ino)
3392 		__field(loff_t, dest_isize)
3393 	),
3394 	TP_fast_assign(
3395 		__entry->dev = src->i_sb->s_dev;
3396 		__entry->src_ino = src->i_ino;
3397 		__entry->src_isize = i_size_read(src);
3398 		__entry->dest_ino = dest->i_ino;
3399 		__entry->dest_isize = i_size_read(dest);
3400 	),
3401 	TP_printk("dev %d:%d ino 0x%lx isize 0x%llx -> ino 0x%lx isize 0x%llx",
3402 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3403 		  __entry->src_ino,
3404 		  __entry->src_isize,
3405 		  __entry->dest_ino,
3406 		  __entry->dest_isize)
3407 );
3408 
3409 /* unshare tracepoints */
3410 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_unshare);
3411 DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);
3412 
3413 /* copy on write */
3414 DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_around_shared);
3415 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found);
3416 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
3417 DEFINE_INODE_IREC_EVENT(xfs_reflink_convert_cow);
3418 
3419 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_cancel_cow_range);
3420 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_end_cow);
3421 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap);
3422 
3423 DEFINE_INODE_ERROR_EVENT(xfs_reflink_cancel_cow_range_error);
3424 DEFINE_INODE_ERROR_EVENT(xfs_reflink_end_cow_error);
3425 
3426 
3427 DEFINE_INODE_IREC_EVENT(xfs_reflink_cancel_cow);
3428 
3429 /* rmap swapext tracepoints */
3430 DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap);
3431 DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap_piece);
3432 DEFINE_INODE_ERROR_EVENT(xfs_swap_extent_rmap_error);
3433 
3434 /* fsmap traces */
3435 DECLARE_EVENT_CLASS(xfs_fsmap_class,
3436 	TP_PROTO(struct xfs_mount *mp, u32 keydev, xfs_agnumber_t agno,
3437 		 const struct xfs_rmap_irec *rmap),
3438 	TP_ARGS(mp, keydev, agno, rmap),
3439 	TP_STRUCT__entry(
3440 		__field(dev_t, dev)
3441 		__field(dev_t, keydev)
3442 		__field(xfs_agnumber_t, agno)
3443 		__field(xfs_fsblock_t, bno)
3444 		__field(xfs_filblks_t, len)
3445 		__field(uint64_t, owner)
3446 		__field(uint64_t, offset)
3447 		__field(unsigned int, flags)
3448 	),
3449 	TP_fast_assign(
3450 		__entry->dev = mp->m_super->s_dev;
3451 		__entry->keydev = new_decode_dev(keydev);
3452 		__entry->agno = agno;
3453 		__entry->bno = rmap->rm_startblock;
3454 		__entry->len = rmap->rm_blockcount;
3455 		__entry->owner = rmap->rm_owner;
3456 		__entry->offset = rmap->rm_offset;
3457 		__entry->flags = rmap->rm_flags;
3458 	),
3459 	TP_printk("dev %d:%d keydev %d:%d agno 0x%x startblock 0x%llx fsbcount 0x%llx owner 0x%llx fileoff 0x%llx flags 0x%x",
3460 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3461 		  MAJOR(__entry->keydev), MINOR(__entry->keydev),
3462 		  __entry->agno,
3463 		  __entry->bno,
3464 		  __entry->len,
3465 		  __entry->owner,
3466 		  __entry->offset,
3467 		  __entry->flags)
3468 )
3469 #define DEFINE_FSMAP_EVENT(name) \
3470 DEFINE_EVENT(xfs_fsmap_class, name, \
3471 	TP_PROTO(struct xfs_mount *mp, u32 keydev, xfs_agnumber_t agno, \
3472 		 const struct xfs_rmap_irec *rmap), \
3473 	TP_ARGS(mp, keydev, agno, rmap))
3474 DEFINE_FSMAP_EVENT(xfs_fsmap_low_key);
3475 DEFINE_FSMAP_EVENT(xfs_fsmap_high_key);
3476 DEFINE_FSMAP_EVENT(xfs_fsmap_mapping);
3477 
3478 DECLARE_EVENT_CLASS(xfs_getfsmap_class,
3479 	TP_PROTO(struct xfs_mount *mp, struct xfs_fsmap *fsmap),
3480 	TP_ARGS(mp, fsmap),
3481 	TP_STRUCT__entry(
3482 		__field(dev_t, dev)
3483 		__field(dev_t, keydev)
3484 		__field(xfs_daddr_t, block)
3485 		__field(xfs_daddr_t, len)
3486 		__field(uint64_t, owner)
3487 		__field(uint64_t, offset)
3488 		__field(uint64_t, flags)
3489 	),
3490 	TP_fast_assign(
3491 		__entry->dev = mp->m_super->s_dev;
3492 		__entry->keydev = new_decode_dev(fsmap->fmr_device);
3493 		__entry->block = fsmap->fmr_physical;
3494 		__entry->len = fsmap->fmr_length;
3495 		__entry->owner = fsmap->fmr_owner;
3496 		__entry->offset = fsmap->fmr_offset;
3497 		__entry->flags = fsmap->fmr_flags;
3498 	),
3499 	TP_printk("dev %d:%d keydev %d:%d daddr 0x%llx bbcount 0x%llx owner 0x%llx fileoff_daddr 0x%llx flags 0x%llx",
3500 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3501 		  MAJOR(__entry->keydev), MINOR(__entry->keydev),
3502 		  __entry->block,
3503 		  __entry->len,
3504 		  __entry->owner,
3505 		  __entry->offset,
3506 		  __entry->flags)
3507 )
3508 #define DEFINE_GETFSMAP_EVENT(name) \
3509 DEFINE_EVENT(xfs_getfsmap_class, name, \
3510 	TP_PROTO(struct xfs_mount *mp, struct xfs_fsmap *fsmap), \
3511 	TP_ARGS(mp, fsmap))
3512 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_low_key);
3513 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_high_key);
3514 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_mapping);
3515 
3516 TRACE_EVENT(xfs_trans_resv_calc,
3517 	TP_PROTO(struct xfs_mount *mp, unsigned int type,
3518 		 struct xfs_trans_res *res),
3519 	TP_ARGS(mp, type, res),
3520 	TP_STRUCT__entry(
3521 		__field(dev_t, dev)
3522 		__field(int, type)
3523 		__field(uint, logres)
3524 		__field(int, logcount)
3525 		__field(int, logflags)
3526 	),
3527 	TP_fast_assign(
3528 		__entry->dev = mp->m_super->s_dev;
3529 		__entry->type = type;
3530 		__entry->logres = res->tr_logres;
3531 		__entry->logcount = res->tr_logcount;
3532 		__entry->logflags = res->tr_logflags;
3533 	),
3534 	TP_printk("dev %d:%d type %d logres %u logcount %d flags 0x%x",
3535 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3536 		  __entry->type,
3537 		  __entry->logres,
3538 		  __entry->logcount,
3539 		  __entry->logflags)
3540 );
3541 
3542 DECLARE_EVENT_CLASS(xfs_trans_class,
3543 	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
3544 	TP_ARGS(tp, caller_ip),
3545 	TP_STRUCT__entry(
3546 		__field(dev_t, dev)
3547 		__field(uint32_t, tid)
3548 		__field(uint32_t, flags)
3549 		__field(unsigned long, caller_ip)
3550 	),
3551 	TP_fast_assign(
3552 		__entry->dev = tp->t_mountp->m_super->s_dev;
3553 		__entry->tid = 0;
3554 		if (tp->t_ticket)
3555 			__entry->tid = tp->t_ticket->t_tid;
3556 		__entry->flags = tp->t_flags;
3557 		__entry->caller_ip = caller_ip;
3558 	),
3559 	TP_printk("dev %d:%d trans %x flags 0x%x caller %pS",
3560 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3561 		  __entry->tid,
3562 		  __entry->flags,
3563 		  (char *)__entry->caller_ip)
3564 )
3565 
3566 #define DEFINE_TRANS_EVENT(name) \
3567 DEFINE_EVENT(xfs_trans_class, name, \
3568 	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip), \
3569 	TP_ARGS(tp, caller_ip))
3570 DEFINE_TRANS_EVENT(xfs_trans_alloc);
3571 DEFINE_TRANS_EVENT(xfs_trans_cancel);
3572 DEFINE_TRANS_EVENT(xfs_trans_commit);
3573 DEFINE_TRANS_EVENT(xfs_trans_dup);
3574 DEFINE_TRANS_EVENT(xfs_trans_free);
3575 DEFINE_TRANS_EVENT(xfs_trans_roll);
3576 DEFINE_TRANS_EVENT(xfs_trans_add_item);
3577 DEFINE_TRANS_EVENT(xfs_trans_commit_items);
3578 DEFINE_TRANS_EVENT(xfs_trans_free_items);
3579 
3580 TRACE_EVENT(xfs_iunlink_update_bucket,
3581 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int bucket,
3582 		 xfs_agino_t old_ptr, xfs_agino_t new_ptr),
3583 	TP_ARGS(mp, agno, bucket, old_ptr, new_ptr),
3584 	TP_STRUCT__entry(
3585 		__field(dev_t, dev)
3586 		__field(xfs_agnumber_t, agno)
3587 		__field(unsigned int, bucket)
3588 		__field(xfs_agino_t, old_ptr)
3589 		__field(xfs_agino_t, new_ptr)
3590 	),
3591 	TP_fast_assign(
3592 		__entry->dev = mp->m_super->s_dev;
3593 		__entry->agno = agno;
3594 		__entry->bucket = bucket;
3595 		__entry->old_ptr = old_ptr;
3596 		__entry->new_ptr = new_ptr;
3597 	),
3598 	TP_printk("dev %d:%d agno 0x%x bucket %u old 0x%x new 0x%x",
3599 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3600 		  __entry->agno,
3601 		  __entry->bucket,
3602 		  __entry->old_ptr,
3603 		  __entry->new_ptr)
3604 );
3605 
3606 TRACE_EVENT(xfs_iunlink_update_dinode,
3607 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
3608 		 xfs_agino_t old_ptr, xfs_agino_t new_ptr),
3609 	TP_ARGS(mp, agno, agino, old_ptr, new_ptr),
3610 	TP_STRUCT__entry(
3611 		__field(dev_t, dev)
3612 		__field(xfs_agnumber_t, agno)
3613 		__field(xfs_agino_t, agino)
3614 		__field(xfs_agino_t, old_ptr)
3615 		__field(xfs_agino_t, new_ptr)
3616 	),
3617 	TP_fast_assign(
3618 		__entry->dev = mp->m_super->s_dev;
3619 		__entry->agno = agno;
3620 		__entry->agino = agino;
3621 		__entry->old_ptr = old_ptr;
3622 		__entry->new_ptr = new_ptr;
3623 	),
3624 	TP_printk("dev %d:%d agno 0x%x agino 0x%x old 0x%x new 0x%x",
3625 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3626 		  __entry->agno,
3627 		  __entry->agino,
3628 		  __entry->old_ptr,
3629 		  __entry->new_ptr)
3630 );
3631 
3632 DECLARE_EVENT_CLASS(xfs_ag_inode_class,
3633 	TP_PROTO(struct xfs_inode *ip),
3634 	TP_ARGS(ip),
3635 	TP_STRUCT__entry(
3636 		__field(dev_t, dev)
3637 		__field(xfs_agnumber_t, agno)
3638 		__field(xfs_agino_t, agino)
3639 	),
3640 	TP_fast_assign(
3641 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3642 		__entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino);
3643 		__entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino);
3644 	),
3645 	TP_printk("dev %d:%d agno 0x%x agino 0x%x",
3646 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3647 		  __entry->agno, __entry->agino)
3648 )
3649 
3650 #define DEFINE_AGINODE_EVENT(name) \
3651 DEFINE_EVENT(xfs_ag_inode_class, name, \
3652 	TP_PROTO(struct xfs_inode *ip), \
3653 	TP_ARGS(ip))
3654 DEFINE_AGINODE_EVENT(xfs_iunlink);
3655 DEFINE_AGINODE_EVENT(xfs_iunlink_remove);
3656 DEFINE_AG_EVENT(xfs_iunlink_map_prev_fallback);
3657 
3658 DECLARE_EVENT_CLASS(xfs_fs_corrupt_class,
3659 	TP_PROTO(struct xfs_mount *mp, unsigned int flags),
3660 	TP_ARGS(mp, flags),
3661 	TP_STRUCT__entry(
3662 		__field(dev_t, dev)
3663 		__field(unsigned int, flags)
3664 	),
3665 	TP_fast_assign(
3666 		__entry->dev = mp->m_super->s_dev;
3667 		__entry->flags = flags;
3668 	),
3669 	TP_printk("dev %d:%d flags 0x%x",
3670 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3671 		  __entry->flags)
3672 );
3673 #define DEFINE_FS_CORRUPT_EVENT(name)	\
3674 DEFINE_EVENT(xfs_fs_corrupt_class, name,	\
3675 	TP_PROTO(struct xfs_mount *mp, unsigned int flags), \
3676 	TP_ARGS(mp, flags))
3677 DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_sick);
3678 DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_healthy);
3679 DEFINE_FS_CORRUPT_EVENT(xfs_fs_unfixed_corruption);
3680 DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_sick);
3681 DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_healthy);
3682 DEFINE_FS_CORRUPT_EVENT(xfs_rt_unfixed_corruption);
3683 
3684 DECLARE_EVENT_CLASS(xfs_ag_corrupt_class,
3685 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int flags),
3686 	TP_ARGS(mp, agno, flags),
3687 	TP_STRUCT__entry(
3688 		__field(dev_t, dev)
3689 		__field(xfs_agnumber_t, agno)
3690 		__field(unsigned int, flags)
3691 	),
3692 	TP_fast_assign(
3693 		__entry->dev = mp->m_super->s_dev;
3694 		__entry->agno = agno;
3695 		__entry->flags = flags;
3696 	),
3697 	TP_printk("dev %d:%d agno 0x%x flags 0x%x",
3698 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3699 		  __entry->agno, __entry->flags)
3700 );
3701 #define DEFINE_AG_CORRUPT_EVENT(name)	\
3702 DEFINE_EVENT(xfs_ag_corrupt_class, name,	\
3703 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3704 		 unsigned int flags), \
3705 	TP_ARGS(mp, agno, flags))
3706 DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_sick);
3707 DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_healthy);
3708 DEFINE_AG_CORRUPT_EVENT(xfs_ag_unfixed_corruption);
3709 
3710 DECLARE_EVENT_CLASS(xfs_inode_corrupt_class,
3711 	TP_PROTO(struct xfs_inode *ip, unsigned int flags),
3712 	TP_ARGS(ip, flags),
3713 	TP_STRUCT__entry(
3714 		__field(dev_t, dev)
3715 		__field(xfs_ino_t, ino)
3716 		__field(unsigned int, flags)
3717 	),
3718 	TP_fast_assign(
3719 		__entry->dev = ip->i_mount->m_super->s_dev;
3720 		__entry->ino = ip->i_ino;
3721 		__entry->flags = flags;
3722 	),
3723 	TP_printk("dev %d:%d ino 0x%llx flags 0x%x",
3724 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3725 		  __entry->ino, __entry->flags)
3726 );
3727 #define DEFINE_INODE_CORRUPT_EVENT(name)	\
3728 DEFINE_EVENT(xfs_inode_corrupt_class, name,	\
3729 	TP_PROTO(struct xfs_inode *ip, unsigned int flags), \
3730 	TP_ARGS(ip, flags))
3731 DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_sick);
3732 DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_healthy);
3733 
3734 TRACE_EVENT(xfs_iwalk_ag,
3735 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3736 		 xfs_agino_t startino),
3737 	TP_ARGS(mp, agno, startino),
3738 	TP_STRUCT__entry(
3739 		__field(dev_t, dev)
3740 		__field(xfs_agnumber_t, agno)
3741 		__field(xfs_agino_t, startino)
3742 	),
3743 	TP_fast_assign(
3744 		__entry->dev = mp->m_super->s_dev;
3745 		__entry->agno = agno;
3746 		__entry->startino = startino;
3747 	),
3748 	TP_printk("dev %d:%d agno 0x%x startino 0x%x",
3749 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno,
3750 		  __entry->startino)
3751 )
3752 
3753 TRACE_EVENT(xfs_iwalk_ag_rec,
3754 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3755 		 struct xfs_inobt_rec_incore *irec),
3756 	TP_ARGS(mp, agno, irec),
3757 	TP_STRUCT__entry(
3758 		__field(dev_t, dev)
3759 		__field(xfs_agnumber_t, agno)
3760 		__field(xfs_agino_t, startino)
3761 		__field(uint64_t, freemask)
3762 	),
3763 	TP_fast_assign(
3764 		__entry->dev = mp->m_super->s_dev;
3765 		__entry->agno = agno;
3766 		__entry->startino = irec->ir_startino;
3767 		__entry->freemask = irec->ir_free;
3768 	),
3769 	TP_printk("dev %d:%d agno 0x%x startino 0x%x freemask 0x%llx",
3770 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno,
3771 		  __entry->startino, __entry->freemask)
3772 )
3773 
3774 TRACE_EVENT(xfs_pwork_init,
3775 	TP_PROTO(struct xfs_mount *mp, unsigned int nr_threads, pid_t pid),
3776 	TP_ARGS(mp, nr_threads, pid),
3777 	TP_STRUCT__entry(
3778 		__field(dev_t, dev)
3779 		__field(unsigned int, nr_threads)
3780 		__field(pid_t, pid)
3781 	),
3782 	TP_fast_assign(
3783 		__entry->dev = mp->m_super->s_dev;
3784 		__entry->nr_threads = nr_threads;
3785 		__entry->pid = pid;
3786 	),
3787 	TP_printk("dev %d:%d nr_threads %u pid %u",
3788 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3789 		  __entry->nr_threads, __entry->pid)
3790 )
3791 
3792 DECLARE_EVENT_CLASS(xfs_kmem_class,
3793 	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip),
3794 	TP_ARGS(size, flags, caller_ip),
3795 	TP_STRUCT__entry(
3796 		__field(ssize_t, size)
3797 		__field(int, flags)
3798 		__field(unsigned long, caller_ip)
3799 	),
3800 	TP_fast_assign(
3801 		__entry->size = size;
3802 		__entry->flags = flags;
3803 		__entry->caller_ip = caller_ip;
3804 	),
3805 	TP_printk("size %zd flags 0x%x caller %pS",
3806 		  __entry->size,
3807 		  __entry->flags,
3808 		  (char *)__entry->caller_ip)
3809 )
3810 
3811 #define DEFINE_KMEM_EVENT(name) \
3812 DEFINE_EVENT(xfs_kmem_class, name, \
3813 	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip), \
3814 	TP_ARGS(size, flags, caller_ip))
3815 DEFINE_KMEM_EVENT(kmem_alloc);
3816 
3817 TRACE_EVENT(xfs_check_new_dalign,
3818 	TP_PROTO(struct xfs_mount *mp, int new_dalign, xfs_ino_t calc_rootino),
3819 	TP_ARGS(mp, new_dalign, calc_rootino),
3820 	TP_STRUCT__entry(
3821 		__field(dev_t, dev)
3822 		__field(int, new_dalign)
3823 		__field(xfs_ino_t, sb_rootino)
3824 		__field(xfs_ino_t, calc_rootino)
3825 	),
3826 	TP_fast_assign(
3827 		__entry->dev = mp->m_super->s_dev;
3828 		__entry->new_dalign = new_dalign;
3829 		__entry->sb_rootino = mp->m_sb.sb_rootino;
3830 		__entry->calc_rootino = calc_rootino;
3831 	),
3832 	TP_printk("dev %d:%d new_dalign %d sb_rootino 0x%llx calc_rootino 0x%llx",
3833 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3834 		  __entry->new_dalign, __entry->sb_rootino,
3835 		  __entry->calc_rootino)
3836 )
3837 
3838 TRACE_EVENT(xfs_btree_commit_afakeroot,
3839 	TP_PROTO(struct xfs_btree_cur *cur),
3840 	TP_ARGS(cur),
3841 	TP_STRUCT__entry(
3842 		__field(dev_t, dev)
3843 		__field(xfs_btnum_t, btnum)
3844 		__field(xfs_agnumber_t, agno)
3845 		__field(xfs_agblock_t, agbno)
3846 		__field(unsigned int, levels)
3847 		__field(unsigned int, blocks)
3848 	),
3849 	TP_fast_assign(
3850 		__entry->dev = cur->bc_mp->m_super->s_dev;
3851 		__entry->btnum = cur->bc_btnum;
3852 		__entry->agno = cur->bc_ag.pag->pag_agno;
3853 		__entry->agbno = cur->bc_ag.afake->af_root;
3854 		__entry->levels = cur->bc_ag.afake->af_levels;
3855 		__entry->blocks = cur->bc_ag.afake->af_blocks;
3856 	),
3857 	TP_printk("dev %d:%d btree %s agno 0x%x levels %u blocks %u root %u",
3858 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3859 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3860 		  __entry->agno,
3861 		  __entry->levels,
3862 		  __entry->blocks,
3863 		  __entry->agbno)
3864 )
3865 
3866 TRACE_EVENT(xfs_btree_commit_ifakeroot,
3867 	TP_PROTO(struct xfs_btree_cur *cur),
3868 	TP_ARGS(cur),
3869 	TP_STRUCT__entry(
3870 		__field(dev_t, dev)
3871 		__field(xfs_btnum_t, btnum)
3872 		__field(xfs_agnumber_t, agno)
3873 		__field(xfs_agino_t, agino)
3874 		__field(unsigned int, levels)
3875 		__field(unsigned int, blocks)
3876 		__field(int, whichfork)
3877 	),
3878 	TP_fast_assign(
3879 		__entry->dev = cur->bc_mp->m_super->s_dev;
3880 		__entry->btnum = cur->bc_btnum;
3881 		__entry->agno = XFS_INO_TO_AGNO(cur->bc_mp,
3882 					cur->bc_ino.ip->i_ino);
3883 		__entry->agino = XFS_INO_TO_AGINO(cur->bc_mp,
3884 					cur->bc_ino.ip->i_ino);
3885 		__entry->levels = cur->bc_ino.ifake->if_levels;
3886 		__entry->blocks = cur->bc_ino.ifake->if_blocks;
3887 		__entry->whichfork = cur->bc_ino.whichfork;
3888 	),
3889 	TP_printk("dev %d:%d btree %s agno 0x%x agino 0x%x whichfork %s levels %u blocks %u",
3890 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3891 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3892 		  __entry->agno,
3893 		  __entry->agino,
3894 		  __print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
3895 		  __entry->levels,
3896 		  __entry->blocks)
3897 )
3898 
3899 TRACE_EVENT(xfs_btree_bload_level_geometry,
3900 	TP_PROTO(struct xfs_btree_cur *cur, unsigned int level,
3901 		 uint64_t nr_this_level, unsigned int nr_per_block,
3902 		 unsigned int desired_npb, uint64_t blocks,
3903 		 uint64_t blocks_with_extra),
3904 	TP_ARGS(cur, level, nr_this_level, nr_per_block, desired_npb, blocks,
3905 		blocks_with_extra),
3906 	TP_STRUCT__entry(
3907 		__field(dev_t, dev)
3908 		__field(xfs_btnum_t, btnum)
3909 		__field(unsigned int, level)
3910 		__field(unsigned int, nlevels)
3911 		__field(uint64_t, nr_this_level)
3912 		__field(unsigned int, nr_per_block)
3913 		__field(unsigned int, desired_npb)
3914 		__field(unsigned long long, blocks)
3915 		__field(unsigned long long, blocks_with_extra)
3916 	),
3917 	TP_fast_assign(
3918 		__entry->dev = cur->bc_mp->m_super->s_dev;
3919 		__entry->btnum = cur->bc_btnum;
3920 		__entry->level = level;
3921 		__entry->nlevels = cur->bc_nlevels;
3922 		__entry->nr_this_level = nr_this_level;
3923 		__entry->nr_per_block = nr_per_block;
3924 		__entry->desired_npb = desired_npb;
3925 		__entry->blocks = blocks;
3926 		__entry->blocks_with_extra = blocks_with_extra;
3927 	),
3928 	TP_printk("dev %d:%d btree %s level %u/%u nr_this_level %llu nr_per_block %u desired_npb %u blocks %llu blocks_with_extra %llu",
3929 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3930 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3931 		  __entry->level,
3932 		  __entry->nlevels,
3933 		  __entry->nr_this_level,
3934 		  __entry->nr_per_block,
3935 		  __entry->desired_npb,
3936 		  __entry->blocks,
3937 		  __entry->blocks_with_extra)
3938 )
3939 
3940 TRACE_EVENT(xfs_btree_bload_block,
3941 	TP_PROTO(struct xfs_btree_cur *cur, unsigned int level,
3942 		 uint64_t block_idx, uint64_t nr_blocks,
3943 		 union xfs_btree_ptr *ptr, unsigned int nr_records),
3944 	TP_ARGS(cur, level, block_idx, nr_blocks, ptr, nr_records),
3945 	TP_STRUCT__entry(
3946 		__field(dev_t, dev)
3947 		__field(xfs_btnum_t, btnum)
3948 		__field(unsigned int, level)
3949 		__field(unsigned long long, block_idx)
3950 		__field(unsigned long long, nr_blocks)
3951 		__field(xfs_agnumber_t, agno)
3952 		__field(xfs_agblock_t, agbno)
3953 		__field(unsigned int, nr_records)
3954 	),
3955 	TP_fast_assign(
3956 		__entry->dev = cur->bc_mp->m_super->s_dev;
3957 		__entry->btnum = cur->bc_btnum;
3958 		__entry->level = level;
3959 		__entry->block_idx = block_idx;
3960 		__entry->nr_blocks = nr_blocks;
3961 		if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
3962 			xfs_fsblock_t	fsb = be64_to_cpu(ptr->l);
3963 
3964 			__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsb);
3965 			__entry->agbno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsb);
3966 		} else {
3967 			__entry->agno = cur->bc_ag.pag->pag_agno;
3968 			__entry->agbno = be32_to_cpu(ptr->s);
3969 		}
3970 		__entry->nr_records = nr_records;
3971 	),
3972 	TP_printk("dev %d:%d btree %s level %u block %llu/%llu agno 0x%x agbno 0x%x recs %u",
3973 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3974 		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3975 		  __entry->level,
3976 		  __entry->block_idx,
3977 		  __entry->nr_blocks,
3978 		  __entry->agno,
3979 		  __entry->agbno,
3980 		  __entry->nr_records)
3981 )
3982 
3983 DECLARE_EVENT_CLASS(xfs_timestamp_range_class,
3984 	TP_PROTO(struct xfs_mount *mp, time64_t min, time64_t max),
3985 	TP_ARGS(mp, min, max),
3986 	TP_STRUCT__entry(
3987 		__field(dev_t, dev)
3988 		__field(long long, min)
3989 		__field(long long, max)
3990 	),
3991 	TP_fast_assign(
3992 		__entry->dev = mp->m_super->s_dev;
3993 		__entry->min = min;
3994 		__entry->max = max;
3995 	),
3996 	TP_printk("dev %d:%d min %lld max %lld",
3997 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3998 		  __entry->min,
3999 		  __entry->max)
4000 )
4001 
4002 #define DEFINE_TIMESTAMP_RANGE_EVENT(name) \
4003 DEFINE_EVENT(xfs_timestamp_range_class, name, \
4004 	TP_PROTO(struct xfs_mount *mp, long long min, long long max), \
4005 	TP_ARGS(mp, min, max))
4006 DEFINE_TIMESTAMP_RANGE_EVENT(xfs_inode_timestamp_range);
4007 DEFINE_TIMESTAMP_RANGE_EVENT(xfs_quota_expiry_range);
4008 
4009 DECLARE_EVENT_CLASS(xfs_icwalk_class,
4010 	TP_PROTO(struct xfs_mount *mp, struct xfs_icwalk *icw,
4011 		 unsigned long caller_ip),
4012 	TP_ARGS(mp, icw, caller_ip),
4013 	TP_STRUCT__entry(
4014 		__field(dev_t, dev)
4015 		__field(__u32, flags)
4016 		__field(uint32_t, uid)
4017 		__field(uint32_t, gid)
4018 		__field(prid_t, prid)
4019 		__field(__u64, min_file_size)
4020 		__field(long, scan_limit)
4021 		__field(unsigned long, caller_ip)
4022 	),
4023 	TP_fast_assign(
4024 		__entry->dev = mp->m_super->s_dev;
4025 		__entry->flags = icw ? icw->icw_flags : 0;
4026 		__entry->uid = icw ? from_kuid(mp->m_super->s_user_ns,
4027 						icw->icw_uid) : 0;
4028 		__entry->gid = icw ? from_kgid(mp->m_super->s_user_ns,
4029 						icw->icw_gid) : 0;
4030 		__entry->prid = icw ? icw->icw_prid : 0;
4031 		__entry->min_file_size = icw ? icw->icw_min_file_size : 0;
4032 		__entry->scan_limit = icw ? icw->icw_scan_limit : 0;
4033 		__entry->caller_ip = caller_ip;
4034 	),
4035 	TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %ld caller %pS",
4036 		  MAJOR(__entry->dev), MINOR(__entry->dev),
4037 		  __entry->flags,
4038 		  __entry->uid,
4039 		  __entry->gid,
4040 		  __entry->prid,
4041 		  __entry->min_file_size,
4042 		  __entry->scan_limit,
4043 		  (char *)__entry->caller_ip)
4044 );
4045 #define DEFINE_ICWALK_EVENT(name)	\
4046 DEFINE_EVENT(xfs_icwalk_class, name,	\
4047 	TP_PROTO(struct xfs_mount *mp, struct xfs_icwalk *icw, \
4048 		 unsigned long caller_ip), \
4049 	TP_ARGS(mp, icw, caller_ip))
4050 DEFINE_ICWALK_EVENT(xfs_ioc_free_eofblocks);
4051 DEFINE_ICWALK_EVENT(xfs_blockgc_free_space);
4052 
4053 TRACE_DEFINE_ENUM(XLOG_STATE_ACTIVE);
4054 TRACE_DEFINE_ENUM(XLOG_STATE_WANT_SYNC);
4055 TRACE_DEFINE_ENUM(XLOG_STATE_SYNCING);
4056 TRACE_DEFINE_ENUM(XLOG_STATE_DONE_SYNC);
4057 TRACE_DEFINE_ENUM(XLOG_STATE_CALLBACK);
4058 TRACE_DEFINE_ENUM(XLOG_STATE_DIRTY);
4059 
4060 DECLARE_EVENT_CLASS(xlog_iclog_class,
4061 	TP_PROTO(struct xlog_in_core *iclog, unsigned long caller_ip),
4062 	TP_ARGS(iclog, caller_ip),
4063 	TP_STRUCT__entry(
4064 		__field(dev_t, dev)
4065 		__field(uint32_t, state)
4066 		__field(int32_t, refcount)
4067 		__field(uint32_t, offset)
4068 		__field(uint32_t, flags)
4069 		__field(unsigned long long, lsn)
4070 		__field(unsigned long, caller_ip)
4071 	),
4072 	TP_fast_assign(
4073 		__entry->dev = iclog->ic_log->l_mp->m_super->s_dev;
4074 		__entry->state = iclog->ic_state;
4075 		__entry->refcount = atomic_read(&iclog->ic_refcnt);
4076 		__entry->offset = iclog->ic_offset;
4077 		__entry->flags = iclog->ic_flags;
4078 		__entry->lsn = be64_to_cpu(iclog->ic_header.h_lsn);
4079 		__entry->caller_ip = caller_ip;
4080 	),
4081 	TP_printk("dev %d:%d state %s refcnt %d offset %u lsn 0x%llx flags %s caller %pS",
4082 		  MAJOR(__entry->dev), MINOR(__entry->dev),
4083 		  __print_symbolic(__entry->state, XLOG_STATE_STRINGS),
4084 		  __entry->refcount,
4085 		  __entry->offset,
4086 		  __entry->lsn,
4087 		  __print_flags(__entry->flags, "|", XLOG_ICL_STRINGS),
4088 		  (char *)__entry->caller_ip)
4089 
4090 );
4091 
4092 #define DEFINE_ICLOG_EVENT(name)	\
4093 DEFINE_EVENT(xlog_iclog_class, name,	\
4094 	TP_PROTO(struct xlog_in_core *iclog, unsigned long caller_ip), \
4095 	TP_ARGS(iclog, caller_ip))
4096 
4097 DEFINE_ICLOG_EVENT(xlog_iclog_activate);
4098 DEFINE_ICLOG_EVENT(xlog_iclog_clean);
4099 DEFINE_ICLOG_EVENT(xlog_iclog_callback);
4100 DEFINE_ICLOG_EVENT(xlog_iclog_callbacks_start);
4101 DEFINE_ICLOG_EVENT(xlog_iclog_callbacks_done);
4102 DEFINE_ICLOG_EVENT(xlog_iclog_force);
4103 DEFINE_ICLOG_EVENT(xlog_iclog_force_lsn);
4104 DEFINE_ICLOG_EVENT(xlog_iclog_get_space);
4105 DEFINE_ICLOG_EVENT(xlog_iclog_release);
4106 DEFINE_ICLOG_EVENT(xlog_iclog_switch);
4107 DEFINE_ICLOG_EVENT(xlog_iclog_sync);
4108 DEFINE_ICLOG_EVENT(xlog_iclog_syncing);
4109 DEFINE_ICLOG_EVENT(xlog_iclog_sync_done);
4110 DEFINE_ICLOG_EVENT(xlog_iclog_want_sync);
4111 DEFINE_ICLOG_EVENT(xlog_iclog_wait_on);
4112 DEFINE_ICLOG_EVENT(xlog_iclog_write);
4113 
4114 DECLARE_EVENT_CLASS(xfs_das_state_class,
4115 	TP_PROTO(int das, struct xfs_inode *ip),
4116 	TP_ARGS(das, ip),
4117 	TP_STRUCT__entry(
4118 		__field(int, das)
4119 		__field(xfs_ino_t, ino)
4120 	),
4121 	TP_fast_assign(
4122 		__entry->das = das;
4123 		__entry->ino = ip->i_ino;
4124 	),
4125 	TP_printk("state change %d ino 0x%llx",
4126 		  __entry->das, __entry->ino)
4127 )
4128 
4129 #define DEFINE_DAS_STATE_EVENT(name) \
4130 DEFINE_EVENT(xfs_das_state_class, name, \
4131 	TP_PROTO(int das, struct xfs_inode *ip), \
4132 	TP_ARGS(das, ip))
4133 DEFINE_DAS_STATE_EVENT(xfs_attr_sf_addname_return);
4134 DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return);
4135 DEFINE_DAS_STATE_EVENT(xfs_attr_node_addname_return);
4136 DEFINE_DAS_STATE_EVENT(xfs_attr_remove_iter_return);
4137 DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return);
4138 
4139 TRACE_EVENT(xfs_force_shutdown,
4140 	TP_PROTO(struct xfs_mount *mp, int ptag, int flags, const char *fname,
4141 		 int line_num),
4142 	TP_ARGS(mp, ptag, flags, fname, line_num),
4143 	TP_STRUCT__entry(
4144 		__field(dev_t, dev)
4145 		__field(int, ptag)
4146 		__field(int, flags)
4147 		__string(fname, fname)
4148 		__field(int, line_num)
4149 	),
4150 	TP_fast_assign(
4151 		__entry->dev = mp->m_super->s_dev;
4152 		__entry->ptag = ptag;
4153 		__entry->flags = flags;
4154 		__assign_str(fname, fname);
4155 		__entry->line_num = line_num;
4156 	),
4157 	TP_printk("dev %d:%d tag %s flags %s file %s line_num %d",
4158 		  MAJOR(__entry->dev), MINOR(__entry->dev),
4159 		__print_flags(__entry->ptag, "|", XFS_PTAG_STRINGS),
4160 		__print_flags(__entry->flags, "|", XFS_SHUTDOWN_STRINGS),
4161 		__get_str(fname),
4162 		__entry->line_num)
4163 );
4164 
4165 #endif /* _TRACE_XFS_H */
4166 
4167 #undef TRACE_INCLUDE_PATH
4168 #define TRACE_INCLUDE_PATH .
4169 #define TRACE_INCLUDE_FILE xfs_trace
4170 #include <trace/define_trace.h>
4171