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