xref: /linux/fs/xfs/xfs_trace.h (revision bfd5bb6f90af092aa345b15cd78143956a13c2a8)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2009, Christoph Hellwig
4  * All Rights Reserved.
5  */
6 #undef TRACE_SYSTEM
7 #define TRACE_SYSTEM xfs
8 
9 #if !defined(_TRACE_XFS_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _TRACE_XFS_H
11 
12 #include <linux/tracepoint.h>
13 
14 struct xfs_agf;
15 struct xfs_alloc_arg;
16 struct xfs_attr_list_context;
17 struct xfs_buf_log_item;
18 struct xfs_da_args;
19 struct xfs_da_node_entry;
20 struct xfs_dquot;
21 struct xfs_log_item;
22 struct xlog;
23 struct xlog_ticket;
24 struct xlog_recover;
25 struct xlog_recover_item;
26 struct xfs_buf_log_format;
27 struct xfs_inode_log_format;
28 struct xfs_bmbt_irec;
29 struct xfs_btree_cur;
30 struct xfs_refcount_irec;
31 struct xfs_fsmap;
32 struct xfs_rmap_irec;
33 
34 DECLARE_EVENT_CLASS(xfs_attr_list_class,
35 	TP_PROTO(struct xfs_attr_list_context *ctx),
36 	TP_ARGS(ctx),
37 	TP_STRUCT__entry(
38 		__field(dev_t, dev)
39 		__field(xfs_ino_t, ino)
40 		__field(u32, hashval)
41 		__field(u32, blkno)
42 		__field(u32, offset)
43 		__field(void *, alist)
44 		__field(int, bufsize)
45 		__field(int, count)
46 		__field(int, firstu)
47 		__field(int, dupcnt)
48 		__field(int, flags)
49 	),
50 	TP_fast_assign(
51 		__entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
52 		__entry->ino = ctx->dp->i_ino;
53 		__entry->hashval = ctx->cursor->hashval;
54 		__entry->blkno = ctx->cursor->blkno;
55 		__entry->offset = ctx->cursor->offset;
56 		__entry->alist = ctx->alist;
57 		__entry->bufsize = ctx->bufsize;
58 		__entry->count = ctx->count;
59 		__entry->firstu = ctx->firstu;
60 		__entry->flags = ctx->flags;
61 	),
62 	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
63 		  "alist %p size %u count %u firstu %u flags %d %s",
64 		  MAJOR(__entry->dev), MINOR(__entry->dev),
65 		   __entry->ino,
66 		   __entry->hashval,
67 		   __entry->blkno,
68 		   __entry->offset,
69 		   __entry->dupcnt,
70 		   __entry->alist,
71 		   __entry->bufsize,
72 		   __entry->count,
73 		   __entry->firstu,
74 		   __entry->flags,
75 		   __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS)
76 	)
77 )
78 
79 #define DEFINE_ATTR_LIST_EVENT(name) \
80 DEFINE_EVENT(xfs_attr_list_class, name, \
81 	TP_PROTO(struct xfs_attr_list_context *ctx), \
82 	TP_ARGS(ctx))
83 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf);
84 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf_all);
85 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf);
86 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf_end);
87 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_full);
88 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_add);
89 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_wrong_blk);
90 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_notfound);
91 DEFINE_ATTR_LIST_EVENT(xfs_attr_leaf_list);
92 DEFINE_ATTR_LIST_EVENT(xfs_attr_node_list);
93 
94 DECLARE_EVENT_CLASS(xfs_perag_class,
95 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int refcount,
96 		 unsigned long caller_ip),
97 	TP_ARGS(mp, agno, refcount, caller_ip),
98 	TP_STRUCT__entry(
99 		__field(dev_t, dev)
100 		__field(xfs_agnumber_t, agno)
101 		__field(int, refcount)
102 		__field(unsigned long, caller_ip)
103 	),
104 	TP_fast_assign(
105 		__entry->dev = mp->m_super->s_dev;
106 		__entry->agno = agno;
107 		__entry->refcount = refcount;
108 		__entry->caller_ip = caller_ip;
109 	),
110 	TP_printk("dev %d:%d agno %u refcount %d caller %pS",
111 		  MAJOR(__entry->dev), MINOR(__entry->dev),
112 		  __entry->agno,
113 		  __entry->refcount,
114 		  (char *)__entry->caller_ip)
115 );
116 
117 #define DEFINE_PERAG_REF_EVENT(name)	\
118 DEFINE_EVENT(xfs_perag_class, name,	\
119 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int refcount,	\
120 		 unsigned long caller_ip),					\
121 	TP_ARGS(mp, agno, refcount, caller_ip))
122 DEFINE_PERAG_REF_EVENT(xfs_perag_get);
123 DEFINE_PERAG_REF_EVENT(xfs_perag_get_tag);
124 DEFINE_PERAG_REF_EVENT(xfs_perag_put);
125 DEFINE_PERAG_REF_EVENT(xfs_perag_set_reclaim);
126 DEFINE_PERAG_REF_EVENT(xfs_perag_clear_reclaim);
127 DEFINE_PERAG_REF_EVENT(xfs_perag_set_eofblocks);
128 DEFINE_PERAG_REF_EVENT(xfs_perag_clear_eofblocks);
129 DEFINE_PERAG_REF_EVENT(xfs_perag_set_cowblocks);
130 DEFINE_PERAG_REF_EVENT(xfs_perag_clear_cowblocks);
131 
132 DECLARE_EVENT_CLASS(xfs_ag_class,
133 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno),
134 	TP_ARGS(mp, agno),
135 	TP_STRUCT__entry(
136 		__field(dev_t, dev)
137 		__field(xfs_agnumber_t, agno)
138 	),
139 	TP_fast_assign(
140 		__entry->dev = mp->m_super->s_dev;
141 		__entry->agno = agno;
142 	),
143 	TP_printk("dev %d:%d agno %u",
144 		  MAJOR(__entry->dev), MINOR(__entry->dev),
145 		  __entry->agno)
146 );
147 #define DEFINE_AG_EVENT(name)	\
148 DEFINE_EVENT(xfs_ag_class, name,	\
149 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno),	\
150 	TP_ARGS(mp, agno))
151 
152 DEFINE_AG_EVENT(xfs_read_agf);
153 DEFINE_AG_EVENT(xfs_alloc_read_agf);
154 DEFINE_AG_EVENT(xfs_read_agi);
155 DEFINE_AG_EVENT(xfs_ialloc_read_agi);
156 
157 TRACE_EVENT(xfs_attr_list_node_descend,
158 	TP_PROTO(struct xfs_attr_list_context *ctx,
159 		 struct xfs_da_node_entry *btree),
160 	TP_ARGS(ctx, btree),
161 	TP_STRUCT__entry(
162 		__field(dev_t, dev)
163 		__field(xfs_ino_t, ino)
164 		__field(u32, hashval)
165 		__field(u32, blkno)
166 		__field(u32, offset)
167 		__field(void *, alist)
168 		__field(int, bufsize)
169 		__field(int, count)
170 		__field(int, firstu)
171 		__field(int, dupcnt)
172 		__field(int, flags)
173 		__field(u32, bt_hashval)
174 		__field(u32, bt_before)
175 	),
176 	TP_fast_assign(
177 		__entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
178 		__entry->ino = ctx->dp->i_ino;
179 		__entry->hashval = ctx->cursor->hashval;
180 		__entry->blkno = ctx->cursor->blkno;
181 		__entry->offset = ctx->cursor->offset;
182 		__entry->alist = ctx->alist;
183 		__entry->bufsize = ctx->bufsize;
184 		__entry->count = ctx->count;
185 		__entry->firstu = ctx->firstu;
186 		__entry->flags = ctx->flags;
187 		__entry->bt_hashval = be32_to_cpu(btree->hashval);
188 		__entry->bt_before = be32_to_cpu(btree->before);
189 	),
190 	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
191 		  "alist %p size %u count %u firstu %u flags %d %s "
192 		  "node hashval %u, node before %u",
193 		  MAJOR(__entry->dev), MINOR(__entry->dev),
194 		   __entry->ino,
195 		   __entry->hashval,
196 		   __entry->blkno,
197 		   __entry->offset,
198 		   __entry->dupcnt,
199 		   __entry->alist,
200 		   __entry->bufsize,
201 		   __entry->count,
202 		   __entry->firstu,
203 		   __entry->flags,
204 		   __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS),
205 		   __entry->bt_hashval,
206 		   __entry->bt_before)
207 );
208 
209 DECLARE_EVENT_CLASS(xfs_bmap_class,
210 	TP_PROTO(struct xfs_inode *ip, struct xfs_iext_cursor *cur, int state,
211 		 unsigned long caller_ip),
212 	TP_ARGS(ip, cur, state, caller_ip),
213 	TP_STRUCT__entry(
214 		__field(dev_t, dev)
215 		__field(xfs_ino_t, ino)
216 		__field(void *, leaf);
217 		__field(int, pos);
218 		__field(xfs_fileoff_t, startoff)
219 		__field(xfs_fsblock_t, startblock)
220 		__field(xfs_filblks_t, blockcount)
221 		__field(xfs_exntst_t, state)
222 		__field(int, bmap_state)
223 		__field(unsigned long, caller_ip)
224 	),
225 	TP_fast_assign(
226 		struct xfs_ifork	*ifp;
227 		struct xfs_bmbt_irec	r;
228 
229 		ifp = xfs_iext_state_to_fork(ip, state);
230 		xfs_iext_get_extent(ifp, cur, &r);
231 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
232 		__entry->ino = ip->i_ino;
233 		__entry->leaf = cur->leaf;
234 		__entry->pos = cur->pos;
235 		__entry->startoff = r.br_startoff;
236 		__entry->startblock = r.br_startblock;
237 		__entry->blockcount = r.br_blockcount;
238 		__entry->state = r.br_state;
239 		__entry->bmap_state = state;
240 		__entry->caller_ip = caller_ip;
241 	),
242 	TP_printk("dev %d:%d ino 0x%llx state %s cur %p/%d "
243 		  "offset %lld block %lld count %lld flag %d caller %pS",
244 		  MAJOR(__entry->dev), MINOR(__entry->dev),
245 		  __entry->ino,
246 		  __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS),
247 		  __entry->leaf,
248 		  __entry->pos,
249 		  __entry->startoff,
250 		  (int64_t)__entry->startblock,
251 		  __entry->blockcount,
252 		  __entry->state,
253 		  (char *)__entry->caller_ip)
254 )
255 
256 #define DEFINE_BMAP_EVENT(name) \
257 DEFINE_EVENT(xfs_bmap_class, name, \
258 	TP_PROTO(struct xfs_inode *ip, struct xfs_iext_cursor *cur, int state, \
259 		 unsigned long caller_ip), \
260 	TP_ARGS(ip, cur, state, caller_ip))
261 DEFINE_BMAP_EVENT(xfs_iext_insert);
262 DEFINE_BMAP_EVENT(xfs_iext_remove);
263 DEFINE_BMAP_EVENT(xfs_bmap_pre_update);
264 DEFINE_BMAP_EVENT(xfs_bmap_post_update);
265 DEFINE_BMAP_EVENT(xfs_read_extent);
266 DEFINE_BMAP_EVENT(xfs_write_extent);
267 
268 DECLARE_EVENT_CLASS(xfs_buf_class,
269 	TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip),
270 	TP_ARGS(bp, caller_ip),
271 	TP_STRUCT__entry(
272 		__field(dev_t, dev)
273 		__field(xfs_daddr_t, bno)
274 		__field(int, nblks)
275 		__field(int, hold)
276 		__field(int, pincount)
277 		__field(unsigned, lockval)
278 		__field(unsigned, flags)
279 		__field(unsigned long, caller_ip)
280 	),
281 	TP_fast_assign(
282 		__entry->dev = bp->b_target->bt_dev;
283 		__entry->bno = bp->b_bn;
284 		__entry->nblks = bp->b_length;
285 		__entry->hold = atomic_read(&bp->b_hold);
286 		__entry->pincount = atomic_read(&bp->b_pin_count);
287 		__entry->lockval = bp->b_sema.count;
288 		__entry->flags = bp->b_flags;
289 		__entry->caller_ip = caller_ip;
290 	),
291 	TP_printk("dev %d:%d bno 0x%llx nblks 0x%x hold %d pincount %d "
292 		  "lock %d flags %s caller %pS",
293 		  MAJOR(__entry->dev), MINOR(__entry->dev),
294 		  (unsigned long long)__entry->bno,
295 		  __entry->nblks,
296 		  __entry->hold,
297 		  __entry->pincount,
298 		  __entry->lockval,
299 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
300 		  (void *)__entry->caller_ip)
301 )
302 
303 #define DEFINE_BUF_EVENT(name) \
304 DEFINE_EVENT(xfs_buf_class, name, \
305 	TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip), \
306 	TP_ARGS(bp, caller_ip))
307 DEFINE_BUF_EVENT(xfs_buf_init);
308 DEFINE_BUF_EVENT(xfs_buf_free);
309 DEFINE_BUF_EVENT(xfs_buf_hold);
310 DEFINE_BUF_EVENT(xfs_buf_rele);
311 DEFINE_BUF_EVENT(xfs_buf_iodone);
312 DEFINE_BUF_EVENT(xfs_buf_submit);
313 DEFINE_BUF_EVENT(xfs_buf_submit_wait);
314 DEFINE_BUF_EVENT(xfs_buf_lock);
315 DEFINE_BUF_EVENT(xfs_buf_lock_done);
316 DEFINE_BUF_EVENT(xfs_buf_trylock_fail);
317 DEFINE_BUF_EVENT(xfs_buf_trylock);
318 DEFINE_BUF_EVENT(xfs_buf_unlock);
319 DEFINE_BUF_EVENT(xfs_buf_iowait);
320 DEFINE_BUF_EVENT(xfs_buf_iowait_done);
321 DEFINE_BUF_EVENT(xfs_buf_delwri_queue);
322 DEFINE_BUF_EVENT(xfs_buf_delwri_queued);
323 DEFINE_BUF_EVENT(xfs_buf_delwri_split);
324 DEFINE_BUF_EVENT(xfs_buf_delwri_pushbuf);
325 DEFINE_BUF_EVENT(xfs_buf_get_uncached);
326 DEFINE_BUF_EVENT(xfs_buf_item_relse);
327 DEFINE_BUF_EVENT(xfs_buf_item_iodone_async);
328 DEFINE_BUF_EVENT(xfs_buf_error_relse);
329 DEFINE_BUF_EVENT(xfs_buf_wait_buftarg);
330 DEFINE_BUF_EVENT(xfs_trans_read_buf_shut);
331 
332 /* not really buffer traces, but the buf provides useful information */
333 DEFINE_BUF_EVENT(xfs_btree_corrupt);
334 DEFINE_BUF_EVENT(xfs_reset_dqcounts);
335 
336 /* pass flags explicitly */
337 DECLARE_EVENT_CLASS(xfs_buf_flags_class,
338 	TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip),
339 	TP_ARGS(bp, flags, caller_ip),
340 	TP_STRUCT__entry(
341 		__field(dev_t, dev)
342 		__field(xfs_daddr_t, bno)
343 		__field(size_t, buffer_length)
344 		__field(int, hold)
345 		__field(int, pincount)
346 		__field(unsigned, lockval)
347 		__field(unsigned, flags)
348 		__field(unsigned long, caller_ip)
349 	),
350 	TP_fast_assign(
351 		__entry->dev = bp->b_target->bt_dev;
352 		__entry->bno = bp->b_bn;
353 		__entry->buffer_length = BBTOB(bp->b_length);
354 		__entry->flags = flags;
355 		__entry->hold = atomic_read(&bp->b_hold);
356 		__entry->pincount = atomic_read(&bp->b_pin_count);
357 		__entry->lockval = bp->b_sema.count;
358 		__entry->caller_ip = caller_ip;
359 	),
360 	TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
361 		  "lock %d flags %s caller %pS",
362 		  MAJOR(__entry->dev), MINOR(__entry->dev),
363 		  (unsigned long long)__entry->bno,
364 		  __entry->buffer_length,
365 		  __entry->hold,
366 		  __entry->pincount,
367 		  __entry->lockval,
368 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
369 		  (void *)__entry->caller_ip)
370 )
371 
372 #define DEFINE_BUF_FLAGS_EVENT(name) \
373 DEFINE_EVENT(xfs_buf_flags_class, name, \
374 	TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip), \
375 	TP_ARGS(bp, flags, caller_ip))
376 DEFINE_BUF_FLAGS_EVENT(xfs_buf_find);
377 DEFINE_BUF_FLAGS_EVENT(xfs_buf_get);
378 DEFINE_BUF_FLAGS_EVENT(xfs_buf_read);
379 
380 TRACE_EVENT(xfs_buf_ioerror,
381 	TP_PROTO(struct xfs_buf *bp, int error, xfs_failaddr_t caller_ip),
382 	TP_ARGS(bp, error, caller_ip),
383 	TP_STRUCT__entry(
384 		__field(dev_t, dev)
385 		__field(xfs_daddr_t, bno)
386 		__field(size_t, buffer_length)
387 		__field(unsigned, flags)
388 		__field(int, hold)
389 		__field(int, pincount)
390 		__field(unsigned, lockval)
391 		__field(int, error)
392 		__field(xfs_failaddr_t, caller_ip)
393 	),
394 	TP_fast_assign(
395 		__entry->dev = bp->b_target->bt_dev;
396 		__entry->bno = bp->b_bn;
397 		__entry->buffer_length = BBTOB(bp->b_length);
398 		__entry->hold = atomic_read(&bp->b_hold);
399 		__entry->pincount = atomic_read(&bp->b_pin_count);
400 		__entry->lockval = bp->b_sema.count;
401 		__entry->error = error;
402 		__entry->flags = bp->b_flags;
403 		__entry->caller_ip = caller_ip;
404 	),
405 	TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
406 		  "lock %d error %d flags %s caller %pS",
407 		  MAJOR(__entry->dev), MINOR(__entry->dev),
408 		  (unsigned long long)__entry->bno,
409 		  __entry->buffer_length,
410 		  __entry->hold,
411 		  __entry->pincount,
412 		  __entry->lockval,
413 		  __entry->error,
414 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
415 		  (void *)__entry->caller_ip)
416 );
417 
418 DECLARE_EVENT_CLASS(xfs_buf_item_class,
419 	TP_PROTO(struct xfs_buf_log_item *bip),
420 	TP_ARGS(bip),
421 	TP_STRUCT__entry(
422 		__field(dev_t, dev)
423 		__field(xfs_daddr_t, buf_bno)
424 		__field(size_t, buf_len)
425 		__field(int, buf_hold)
426 		__field(int, buf_pincount)
427 		__field(int, buf_lockval)
428 		__field(unsigned, buf_flags)
429 		__field(unsigned, bli_recur)
430 		__field(int, bli_refcount)
431 		__field(unsigned, bli_flags)
432 		__field(unsigned long, li_flags)
433 	),
434 	TP_fast_assign(
435 		__entry->dev = bip->bli_buf->b_target->bt_dev;
436 		__entry->bli_flags = bip->bli_flags;
437 		__entry->bli_recur = bip->bli_recur;
438 		__entry->bli_refcount = atomic_read(&bip->bli_refcount);
439 		__entry->buf_bno = bip->bli_buf->b_bn;
440 		__entry->buf_len = BBTOB(bip->bli_buf->b_length);
441 		__entry->buf_flags = bip->bli_buf->b_flags;
442 		__entry->buf_hold = atomic_read(&bip->bli_buf->b_hold);
443 		__entry->buf_pincount = atomic_read(&bip->bli_buf->b_pin_count);
444 		__entry->buf_lockval = bip->bli_buf->b_sema.count;
445 		__entry->li_flags = bip->bli_item.li_flags;
446 	),
447 	TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
448 		  "lock %d flags %s recur %d refcount %d bliflags %s "
449 		  "liflags %s",
450 		  MAJOR(__entry->dev), MINOR(__entry->dev),
451 		  (unsigned long long)__entry->buf_bno,
452 		  __entry->buf_len,
453 		  __entry->buf_hold,
454 		  __entry->buf_pincount,
455 		  __entry->buf_lockval,
456 		  __print_flags(__entry->buf_flags, "|", XFS_BUF_FLAGS),
457 		  __entry->bli_recur,
458 		  __entry->bli_refcount,
459 		  __print_flags(__entry->bli_flags, "|", XFS_BLI_FLAGS),
460 		  __print_flags(__entry->li_flags, "|", XFS_LI_FLAGS))
461 )
462 
463 #define DEFINE_BUF_ITEM_EVENT(name) \
464 DEFINE_EVENT(xfs_buf_item_class, name, \
465 	TP_PROTO(struct xfs_buf_log_item *bip), \
466 	TP_ARGS(bip))
467 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size);
468 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_ordered);
469 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale);
470 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format);
471 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale);
472 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_ordered);
473 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
474 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin);
475 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale);
476 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock);
477 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock_stale);
478 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed);
479 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push);
480 DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf);
481 DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf_recur);
482 DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb);
483 DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb_recur);
484 DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf);
485 DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf_recur);
486 DEFINE_BUF_ITEM_EVENT(xfs_trans_log_buf);
487 DEFINE_BUF_ITEM_EVENT(xfs_trans_brelse);
488 DEFINE_BUF_ITEM_EVENT(xfs_trans_bjoin);
489 DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold);
490 DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release);
491 DEFINE_BUF_ITEM_EVENT(xfs_trans_binval);
492 
493 DECLARE_EVENT_CLASS(xfs_filestream_class,
494 	TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino, xfs_agnumber_t agno),
495 	TP_ARGS(mp, ino, agno),
496 	TP_STRUCT__entry(
497 		__field(dev_t, dev)
498 		__field(xfs_ino_t, ino)
499 		__field(xfs_agnumber_t, agno)
500 		__field(int, streams)
501 	),
502 	TP_fast_assign(
503 		__entry->dev = mp->m_super->s_dev;
504 		__entry->ino = ino;
505 		__entry->agno = agno;
506 		__entry->streams = xfs_filestream_peek_ag(mp, agno);
507 	),
508 	TP_printk("dev %d:%d ino 0x%llx agno %u streams %d",
509 		  MAJOR(__entry->dev), MINOR(__entry->dev),
510 		  __entry->ino,
511 		  __entry->agno,
512 		  __entry->streams)
513 )
514 #define DEFINE_FILESTREAM_EVENT(name) \
515 DEFINE_EVENT(xfs_filestream_class, name, \
516 	TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino, xfs_agnumber_t agno), \
517 	TP_ARGS(mp, ino, agno))
518 DEFINE_FILESTREAM_EVENT(xfs_filestream_free);
519 DEFINE_FILESTREAM_EVENT(xfs_filestream_lookup);
520 DEFINE_FILESTREAM_EVENT(xfs_filestream_scan);
521 
522 TRACE_EVENT(xfs_filestream_pick,
523 	TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno,
524 		 xfs_extlen_t free, int nscan),
525 	TP_ARGS(ip, agno, free, nscan),
526 	TP_STRUCT__entry(
527 		__field(dev_t, dev)
528 		__field(xfs_ino_t, ino)
529 		__field(xfs_agnumber_t, agno)
530 		__field(int, streams)
531 		__field(xfs_extlen_t, free)
532 		__field(int, nscan)
533 	),
534 	TP_fast_assign(
535 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
536 		__entry->ino = ip->i_ino;
537 		__entry->agno = agno;
538 		__entry->streams = xfs_filestream_peek_ag(ip->i_mount, agno);
539 		__entry->free = free;
540 		__entry->nscan = nscan;
541 	),
542 	TP_printk("dev %d:%d ino 0x%llx agno %u streams %d free %d nscan %d",
543 		  MAJOR(__entry->dev), MINOR(__entry->dev),
544 		  __entry->ino,
545 		  __entry->agno,
546 		  __entry->streams,
547 		  __entry->free,
548 		  __entry->nscan)
549 );
550 
551 DECLARE_EVENT_CLASS(xfs_lock_class,
552 	TP_PROTO(struct xfs_inode *ip, unsigned lock_flags,
553 		 unsigned long caller_ip),
554 	TP_ARGS(ip,  lock_flags, caller_ip),
555 	TP_STRUCT__entry(
556 		__field(dev_t, dev)
557 		__field(xfs_ino_t, ino)
558 		__field(int, lock_flags)
559 		__field(unsigned long, caller_ip)
560 	),
561 	TP_fast_assign(
562 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
563 		__entry->ino = ip->i_ino;
564 		__entry->lock_flags = lock_flags;
565 		__entry->caller_ip = caller_ip;
566 	),
567 	TP_printk("dev %d:%d ino 0x%llx flags %s caller %pS",
568 		  MAJOR(__entry->dev), MINOR(__entry->dev),
569 		  __entry->ino,
570 		  __print_flags(__entry->lock_flags, "|", XFS_LOCK_FLAGS),
571 		  (void *)__entry->caller_ip)
572 )
573 
574 #define DEFINE_LOCK_EVENT(name) \
575 DEFINE_EVENT(xfs_lock_class, name, \
576 	TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, \
577 		 unsigned long caller_ip), \
578 	TP_ARGS(ip,  lock_flags, caller_ip))
579 DEFINE_LOCK_EVENT(xfs_ilock);
580 DEFINE_LOCK_EVENT(xfs_ilock_nowait);
581 DEFINE_LOCK_EVENT(xfs_ilock_demote);
582 DEFINE_LOCK_EVENT(xfs_iunlock);
583 
584 DECLARE_EVENT_CLASS(xfs_inode_class,
585 	TP_PROTO(struct xfs_inode *ip),
586 	TP_ARGS(ip),
587 	TP_STRUCT__entry(
588 		__field(dev_t, dev)
589 		__field(xfs_ino_t, ino)
590 	),
591 	TP_fast_assign(
592 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
593 		__entry->ino = ip->i_ino;
594 	),
595 	TP_printk("dev %d:%d ino 0x%llx",
596 		  MAJOR(__entry->dev), MINOR(__entry->dev),
597 		  __entry->ino)
598 )
599 
600 #define DEFINE_INODE_EVENT(name) \
601 DEFINE_EVENT(xfs_inode_class, name, \
602 	TP_PROTO(struct xfs_inode *ip), \
603 	TP_ARGS(ip))
604 DEFINE_INODE_EVENT(xfs_iget_skip);
605 DEFINE_INODE_EVENT(xfs_iget_reclaim);
606 DEFINE_INODE_EVENT(xfs_iget_reclaim_fail);
607 DEFINE_INODE_EVENT(xfs_iget_hit);
608 DEFINE_INODE_EVENT(xfs_iget_miss);
609 
610 DEFINE_INODE_EVENT(xfs_getattr);
611 DEFINE_INODE_EVENT(xfs_setattr);
612 DEFINE_INODE_EVENT(xfs_readlink);
613 DEFINE_INODE_EVENT(xfs_inactive_symlink);
614 DEFINE_INODE_EVENT(xfs_alloc_file_space);
615 DEFINE_INODE_EVENT(xfs_free_file_space);
616 DEFINE_INODE_EVENT(xfs_zero_file_space);
617 DEFINE_INODE_EVENT(xfs_collapse_file_space);
618 DEFINE_INODE_EVENT(xfs_insert_file_space);
619 DEFINE_INODE_EVENT(xfs_readdir);
620 #ifdef CONFIG_XFS_POSIX_ACL
621 DEFINE_INODE_EVENT(xfs_get_acl);
622 #endif
623 DEFINE_INODE_EVENT(xfs_vm_bmap);
624 DEFINE_INODE_EVENT(xfs_file_ioctl);
625 DEFINE_INODE_EVENT(xfs_file_compat_ioctl);
626 DEFINE_INODE_EVENT(xfs_ioctl_setattr);
627 DEFINE_INODE_EVENT(xfs_dir_fsync);
628 DEFINE_INODE_EVENT(xfs_file_fsync);
629 DEFINE_INODE_EVENT(xfs_destroy_inode);
630 DEFINE_INODE_EVENT(xfs_update_time);
631 
632 DEFINE_INODE_EVENT(xfs_dquot_dqalloc);
633 DEFINE_INODE_EVENT(xfs_dquot_dqdetach);
634 
635 DEFINE_INODE_EVENT(xfs_inode_set_eofblocks_tag);
636 DEFINE_INODE_EVENT(xfs_inode_clear_eofblocks_tag);
637 DEFINE_INODE_EVENT(xfs_inode_free_eofblocks_invalid);
638 DEFINE_INODE_EVENT(xfs_inode_set_cowblocks_tag);
639 DEFINE_INODE_EVENT(xfs_inode_clear_cowblocks_tag);
640 DEFINE_INODE_EVENT(xfs_inode_free_cowblocks_invalid);
641 
642 TRACE_EVENT(xfs_filemap_fault,
643 	TP_PROTO(struct xfs_inode *ip, enum page_entry_size pe_size,
644 		 bool write_fault),
645 	TP_ARGS(ip, pe_size, write_fault),
646 	TP_STRUCT__entry(
647 		__field(dev_t, dev)
648 		__field(xfs_ino_t, ino)
649 		__field(enum page_entry_size, pe_size)
650 		__field(bool, write_fault)
651 	),
652 	TP_fast_assign(
653 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
654 		__entry->ino = ip->i_ino;
655 		__entry->pe_size = pe_size;
656 		__entry->write_fault = write_fault;
657 	),
658 	TP_printk("dev %d:%d ino 0x%llx %s write_fault %d",
659 		  MAJOR(__entry->dev), MINOR(__entry->dev),
660 		  __entry->ino,
661 		  __print_symbolic(__entry->pe_size,
662 			{ PE_SIZE_PTE,	"PTE" },
663 			{ PE_SIZE_PMD,	"PMD" },
664 			{ PE_SIZE_PUD,	"PUD" }),
665 		  __entry->write_fault)
666 )
667 
668 DECLARE_EVENT_CLASS(xfs_iref_class,
669 	TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip),
670 	TP_ARGS(ip, caller_ip),
671 	TP_STRUCT__entry(
672 		__field(dev_t, dev)
673 		__field(xfs_ino_t, ino)
674 		__field(int, count)
675 		__field(int, pincount)
676 		__field(unsigned long, caller_ip)
677 	),
678 	TP_fast_assign(
679 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
680 		__entry->ino = ip->i_ino;
681 		__entry->count = atomic_read(&VFS_I(ip)->i_count);
682 		__entry->pincount = atomic_read(&ip->i_pincount);
683 		__entry->caller_ip = caller_ip;
684 	),
685 	TP_printk("dev %d:%d ino 0x%llx count %d pincount %d caller %pS",
686 		  MAJOR(__entry->dev), MINOR(__entry->dev),
687 		  __entry->ino,
688 		  __entry->count,
689 		  __entry->pincount,
690 		  (char *)__entry->caller_ip)
691 )
692 
693 TRACE_EVENT(xfs_iomap_prealloc_size,
694 	TP_PROTO(struct xfs_inode *ip, xfs_fsblock_t blocks, int shift,
695 		 unsigned int writeio_blocks),
696 	TP_ARGS(ip, blocks, shift, writeio_blocks),
697 	TP_STRUCT__entry(
698 		__field(dev_t, dev)
699 		__field(xfs_ino_t, ino)
700 		__field(xfs_fsblock_t, blocks)
701 		__field(int, shift)
702 		__field(unsigned int, writeio_blocks)
703 	),
704 	TP_fast_assign(
705 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
706 		__entry->ino = ip->i_ino;
707 		__entry->blocks = blocks;
708 		__entry->shift = shift;
709 		__entry->writeio_blocks = writeio_blocks;
710 	),
711 	TP_printk("dev %d:%d ino 0x%llx prealloc blocks %llu shift %d "
712 		  "m_writeio_blocks %u",
713 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino,
714 		  __entry->blocks, __entry->shift, __entry->writeio_blocks)
715 )
716 
717 TRACE_EVENT(xfs_irec_merge_pre,
718 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
719 		 uint16_t holemask, xfs_agino_t nagino, uint16_t nholemask),
720 	TP_ARGS(mp, agno, agino, holemask, nagino, nholemask),
721 	TP_STRUCT__entry(
722 		__field(dev_t, dev)
723 		__field(xfs_agnumber_t, agno)
724 		__field(xfs_agino_t, agino)
725 		__field(uint16_t, holemask)
726 		__field(xfs_agino_t, nagino)
727 		__field(uint16_t, nholemask)
728 	),
729 	TP_fast_assign(
730 		__entry->dev = mp->m_super->s_dev;
731 		__entry->agno = agno;
732 		__entry->agino = agino;
733 		__entry->holemask = holemask;
734 		__entry->nagino = nagino;
735 		__entry->nholemask = holemask;
736 	),
737 	TP_printk("dev %d:%d agno %d inobt (%u:0x%x) new (%u:0x%x)",
738 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno,
739 		  __entry->agino, __entry->holemask, __entry->nagino,
740 		  __entry->nholemask)
741 )
742 
743 TRACE_EVENT(xfs_irec_merge_post,
744 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
745 		 uint16_t holemask),
746 	TP_ARGS(mp, agno, agino, holemask),
747 	TP_STRUCT__entry(
748 		__field(dev_t, dev)
749 		__field(xfs_agnumber_t, agno)
750 		__field(xfs_agino_t, agino)
751 		__field(uint16_t, holemask)
752 	),
753 	TP_fast_assign(
754 		__entry->dev = mp->m_super->s_dev;
755 		__entry->agno = agno;
756 		__entry->agino = agino;
757 		__entry->holemask = holemask;
758 	),
759 	TP_printk("dev %d:%d agno %d inobt (%u:0x%x)", MAJOR(__entry->dev),
760 		  MINOR(__entry->dev), __entry->agno, __entry->agino,
761 		  __entry->holemask)
762 )
763 
764 #define DEFINE_IREF_EVENT(name) \
765 DEFINE_EVENT(xfs_iref_class, name, \
766 	TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \
767 	TP_ARGS(ip, caller_ip))
768 DEFINE_IREF_EVENT(xfs_irele);
769 DEFINE_IREF_EVENT(xfs_inode_pin);
770 DEFINE_IREF_EVENT(xfs_inode_unpin);
771 DEFINE_IREF_EVENT(xfs_inode_unpin_nowait);
772 
773 DECLARE_EVENT_CLASS(xfs_namespace_class,
774 	TP_PROTO(struct xfs_inode *dp, struct xfs_name *name),
775 	TP_ARGS(dp, name),
776 	TP_STRUCT__entry(
777 		__field(dev_t, dev)
778 		__field(xfs_ino_t, dp_ino)
779 		__field(int, namelen)
780 		__dynamic_array(char, name, name->len)
781 	),
782 	TP_fast_assign(
783 		__entry->dev = VFS_I(dp)->i_sb->s_dev;
784 		__entry->dp_ino = dp->i_ino;
785 		__entry->namelen = name->len;
786 		memcpy(__get_str(name), name->name, name->len);
787 	),
788 	TP_printk("dev %d:%d dp ino 0x%llx name %.*s",
789 		  MAJOR(__entry->dev), MINOR(__entry->dev),
790 		  __entry->dp_ino,
791 		  __entry->namelen,
792 		  __get_str(name))
793 )
794 
795 #define DEFINE_NAMESPACE_EVENT(name) \
796 DEFINE_EVENT(xfs_namespace_class, name, \
797 	TP_PROTO(struct xfs_inode *dp, struct xfs_name *name), \
798 	TP_ARGS(dp, name))
799 DEFINE_NAMESPACE_EVENT(xfs_remove);
800 DEFINE_NAMESPACE_EVENT(xfs_link);
801 DEFINE_NAMESPACE_EVENT(xfs_lookup);
802 DEFINE_NAMESPACE_EVENT(xfs_create);
803 DEFINE_NAMESPACE_EVENT(xfs_symlink);
804 
805 TRACE_EVENT(xfs_rename,
806 	TP_PROTO(struct xfs_inode *src_dp, struct xfs_inode *target_dp,
807 		 struct xfs_name *src_name, struct xfs_name *target_name),
808 	TP_ARGS(src_dp, target_dp, src_name, target_name),
809 	TP_STRUCT__entry(
810 		__field(dev_t, dev)
811 		__field(xfs_ino_t, src_dp_ino)
812 		__field(xfs_ino_t, target_dp_ino)
813 		__field(int, src_namelen)
814 		__field(int, target_namelen)
815 		__dynamic_array(char, src_name, src_name->len)
816 		__dynamic_array(char, target_name, target_name->len)
817 	),
818 	TP_fast_assign(
819 		__entry->dev = VFS_I(src_dp)->i_sb->s_dev;
820 		__entry->src_dp_ino = src_dp->i_ino;
821 		__entry->target_dp_ino = target_dp->i_ino;
822 		__entry->src_namelen = src_name->len;
823 		__entry->target_namelen = target_name->len;
824 		memcpy(__get_str(src_name), src_name->name, src_name->len);
825 		memcpy(__get_str(target_name), target_name->name,
826 			target_name->len);
827 	),
828 	TP_printk("dev %d:%d src dp ino 0x%llx target dp ino 0x%llx"
829 		  " src name %.*s target name %.*s",
830 		  MAJOR(__entry->dev), MINOR(__entry->dev),
831 		  __entry->src_dp_ino,
832 		  __entry->target_dp_ino,
833 		  __entry->src_namelen,
834 		  __get_str(src_name),
835 		  __entry->target_namelen,
836 		  __get_str(target_name))
837 )
838 
839 DECLARE_EVENT_CLASS(xfs_dquot_class,
840 	TP_PROTO(struct xfs_dquot *dqp),
841 	TP_ARGS(dqp),
842 	TP_STRUCT__entry(
843 		__field(dev_t, dev)
844 		__field(u32, id)
845 		__field(unsigned, flags)
846 		__field(unsigned, nrefs)
847 		__field(unsigned long long, res_bcount)
848 		__field(unsigned long long, bcount)
849 		__field(unsigned long long, icount)
850 		__field(unsigned long long, blk_hardlimit)
851 		__field(unsigned long long, blk_softlimit)
852 		__field(unsigned long long, ino_hardlimit)
853 		__field(unsigned long long, ino_softlimit)
854 	), \
855 	TP_fast_assign(
856 		__entry->dev = dqp->q_mount->m_super->s_dev;
857 		__entry->id = be32_to_cpu(dqp->q_core.d_id);
858 		__entry->flags = dqp->dq_flags;
859 		__entry->nrefs = dqp->q_nrefs;
860 		__entry->res_bcount = dqp->q_res_bcount;
861 		__entry->bcount = be64_to_cpu(dqp->q_core.d_bcount);
862 		__entry->icount = be64_to_cpu(dqp->q_core.d_icount);
863 		__entry->blk_hardlimit =
864 			be64_to_cpu(dqp->q_core.d_blk_hardlimit);
865 		__entry->blk_softlimit =
866 			be64_to_cpu(dqp->q_core.d_blk_softlimit);
867 		__entry->ino_hardlimit =
868 			be64_to_cpu(dqp->q_core.d_ino_hardlimit);
869 		__entry->ino_softlimit =
870 			be64_to_cpu(dqp->q_core.d_ino_softlimit);
871 	),
872 	TP_printk("dev %d:%d id 0x%x flags %s nrefs %u res_bc 0x%llx "
873 		  "bcnt 0x%llx bhardlimit 0x%llx bsoftlimit 0x%llx "
874 		  "icnt 0x%llx ihardlimit 0x%llx isoftlimit 0x%llx]",
875 		  MAJOR(__entry->dev), MINOR(__entry->dev),
876 		  __entry->id,
877 		  __print_flags(__entry->flags, "|", XFS_DQ_FLAGS),
878 		  __entry->nrefs,
879 		  __entry->res_bcount,
880 		  __entry->bcount,
881 		  __entry->blk_hardlimit,
882 		  __entry->blk_softlimit,
883 		  __entry->icount,
884 		  __entry->ino_hardlimit,
885 		  __entry->ino_softlimit)
886 )
887 
888 #define DEFINE_DQUOT_EVENT(name) \
889 DEFINE_EVENT(xfs_dquot_class, name, \
890 	TP_PROTO(struct xfs_dquot *dqp), \
891 	TP_ARGS(dqp))
892 DEFINE_DQUOT_EVENT(xfs_dqadjust);
893 DEFINE_DQUOT_EVENT(xfs_dqreclaim_want);
894 DEFINE_DQUOT_EVENT(xfs_dqreclaim_dirty);
895 DEFINE_DQUOT_EVENT(xfs_dqreclaim_busy);
896 DEFINE_DQUOT_EVENT(xfs_dqreclaim_done);
897 DEFINE_DQUOT_EVENT(xfs_dqattach_found);
898 DEFINE_DQUOT_EVENT(xfs_dqattach_get);
899 DEFINE_DQUOT_EVENT(xfs_dqalloc);
900 DEFINE_DQUOT_EVENT(xfs_dqtobp_read);
901 DEFINE_DQUOT_EVENT(xfs_dqread);
902 DEFINE_DQUOT_EVENT(xfs_dqread_fail);
903 DEFINE_DQUOT_EVENT(xfs_dqget_hit);
904 DEFINE_DQUOT_EVENT(xfs_dqget_miss);
905 DEFINE_DQUOT_EVENT(xfs_dqget_freeing);
906 DEFINE_DQUOT_EVENT(xfs_dqget_dup);
907 DEFINE_DQUOT_EVENT(xfs_dqput);
908 DEFINE_DQUOT_EVENT(xfs_dqput_free);
909 DEFINE_DQUOT_EVENT(xfs_dqrele);
910 DEFINE_DQUOT_EVENT(xfs_dqflush);
911 DEFINE_DQUOT_EVENT(xfs_dqflush_force);
912 DEFINE_DQUOT_EVENT(xfs_dqflush_done);
913 
914 DECLARE_EVENT_CLASS(xfs_loggrant_class,
915 	TP_PROTO(struct xlog *log, struct xlog_ticket *tic),
916 	TP_ARGS(log, tic),
917 	TP_STRUCT__entry(
918 		__field(dev_t, dev)
919 		__field(char, ocnt)
920 		__field(char, cnt)
921 		__field(int, curr_res)
922 		__field(int, unit_res)
923 		__field(unsigned int, flags)
924 		__field(int, reserveq)
925 		__field(int, writeq)
926 		__field(int, grant_reserve_cycle)
927 		__field(int, grant_reserve_bytes)
928 		__field(int, grant_write_cycle)
929 		__field(int, grant_write_bytes)
930 		__field(int, curr_cycle)
931 		__field(int, curr_block)
932 		__field(xfs_lsn_t, tail_lsn)
933 	),
934 	TP_fast_assign(
935 		__entry->dev = log->l_mp->m_super->s_dev;
936 		__entry->ocnt = tic->t_ocnt;
937 		__entry->cnt = tic->t_cnt;
938 		__entry->curr_res = tic->t_curr_res;
939 		__entry->unit_res = tic->t_unit_res;
940 		__entry->flags = tic->t_flags;
941 		__entry->reserveq = list_empty(&log->l_reserve_head.waiters);
942 		__entry->writeq = list_empty(&log->l_write_head.waiters);
943 		xlog_crack_grant_head(&log->l_reserve_head.grant,
944 				&__entry->grant_reserve_cycle,
945 				&__entry->grant_reserve_bytes);
946 		xlog_crack_grant_head(&log->l_write_head.grant,
947 				&__entry->grant_write_cycle,
948 				&__entry->grant_write_bytes);
949 		__entry->curr_cycle = log->l_curr_cycle;
950 		__entry->curr_block = log->l_curr_block;
951 		__entry->tail_lsn = atomic64_read(&log->l_tail_lsn);
952 	),
953 	TP_printk("dev %d:%d t_ocnt %u t_cnt %u t_curr_res %u "
954 		  "t_unit_res %u t_flags %s reserveq %s "
955 		  "writeq %s grant_reserve_cycle %d "
956 		  "grant_reserve_bytes %d grant_write_cycle %d "
957 		  "grant_write_bytes %d curr_cycle %d curr_block %d "
958 		  "tail_cycle %d tail_block %d",
959 		  MAJOR(__entry->dev), MINOR(__entry->dev),
960 		  __entry->ocnt,
961 		  __entry->cnt,
962 		  __entry->curr_res,
963 		  __entry->unit_res,
964 		  __print_flags(__entry->flags, "|", XLOG_TIC_FLAGS),
965 		  __entry->reserveq ? "empty" : "active",
966 		  __entry->writeq ? "empty" : "active",
967 		  __entry->grant_reserve_cycle,
968 		  __entry->grant_reserve_bytes,
969 		  __entry->grant_write_cycle,
970 		  __entry->grant_write_bytes,
971 		  __entry->curr_cycle,
972 		  __entry->curr_block,
973 		  CYCLE_LSN(__entry->tail_lsn),
974 		  BLOCK_LSN(__entry->tail_lsn)
975 	)
976 )
977 
978 #define DEFINE_LOGGRANT_EVENT(name) \
979 DEFINE_EVENT(xfs_loggrant_class, name, \
980 	TP_PROTO(struct xlog *log, struct xlog_ticket *tic), \
981 	TP_ARGS(log, tic))
982 DEFINE_LOGGRANT_EVENT(xfs_log_done_nonperm);
983 DEFINE_LOGGRANT_EVENT(xfs_log_done_perm);
984 DEFINE_LOGGRANT_EVENT(xfs_log_umount_write);
985 DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep);
986 DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake);
987 DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake_up);
988 DEFINE_LOGGRANT_EVENT(xfs_log_reserve);
989 DEFINE_LOGGRANT_EVENT(xfs_log_reserve_exit);
990 DEFINE_LOGGRANT_EVENT(xfs_log_regrant);
991 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_exit);
992 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter);
993 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit);
994 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_sub);
995 DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_enter);
996 DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_exit);
997 DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_sub);
998 
999 DECLARE_EVENT_CLASS(xfs_log_item_class,
1000 	TP_PROTO(struct xfs_log_item *lip),
1001 	TP_ARGS(lip),
1002 	TP_STRUCT__entry(
1003 		__field(dev_t, dev)
1004 		__field(void *, lip)
1005 		__field(uint, type)
1006 		__field(unsigned long, flags)
1007 		__field(xfs_lsn_t, lsn)
1008 	),
1009 	TP_fast_assign(
1010 		__entry->dev = lip->li_mountp->m_super->s_dev;
1011 		__entry->lip = lip;
1012 		__entry->type = lip->li_type;
1013 		__entry->flags = lip->li_flags;
1014 		__entry->lsn = lip->li_lsn;
1015 	),
1016 	TP_printk("dev %d:%d lip %p lsn %d/%d type %s flags %s",
1017 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1018 		  __entry->lip,
1019 		  CYCLE_LSN(__entry->lsn), BLOCK_LSN(__entry->lsn),
1020 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
1021 		  __print_flags(__entry->flags, "|", XFS_LI_FLAGS))
1022 )
1023 
1024 TRACE_EVENT(xfs_log_force,
1025 	TP_PROTO(struct xfs_mount *mp, xfs_lsn_t lsn, unsigned long caller_ip),
1026 	TP_ARGS(mp, lsn, caller_ip),
1027 	TP_STRUCT__entry(
1028 		__field(dev_t, dev)
1029 		__field(xfs_lsn_t, lsn)
1030 		__field(unsigned long, caller_ip)
1031 	),
1032 	TP_fast_assign(
1033 		__entry->dev = mp->m_super->s_dev;
1034 		__entry->lsn = lsn;
1035 		__entry->caller_ip = caller_ip;
1036 	),
1037 	TP_printk("dev %d:%d lsn 0x%llx caller %pS",
1038 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1039 		  __entry->lsn, (void *)__entry->caller_ip)
1040 )
1041 
1042 #define DEFINE_LOG_ITEM_EVENT(name) \
1043 DEFINE_EVENT(xfs_log_item_class, name, \
1044 	TP_PROTO(struct xfs_log_item *lip), \
1045 	TP_ARGS(lip))
1046 DEFINE_LOG_ITEM_EVENT(xfs_ail_push);
1047 DEFINE_LOG_ITEM_EVENT(xfs_ail_pinned);
1048 DEFINE_LOG_ITEM_EVENT(xfs_ail_locked);
1049 DEFINE_LOG_ITEM_EVENT(xfs_ail_flushing);
1050 
1051 DECLARE_EVENT_CLASS(xfs_ail_class,
1052 	TP_PROTO(struct xfs_log_item *lip, xfs_lsn_t old_lsn, xfs_lsn_t new_lsn),
1053 	TP_ARGS(lip, old_lsn, new_lsn),
1054 	TP_STRUCT__entry(
1055 		__field(dev_t, dev)
1056 		__field(void *, lip)
1057 		__field(uint, type)
1058 		__field(unsigned long, flags)
1059 		__field(xfs_lsn_t, old_lsn)
1060 		__field(xfs_lsn_t, new_lsn)
1061 	),
1062 	TP_fast_assign(
1063 		__entry->dev = lip->li_mountp->m_super->s_dev;
1064 		__entry->lip = lip;
1065 		__entry->type = lip->li_type;
1066 		__entry->flags = lip->li_flags;
1067 		__entry->old_lsn = old_lsn;
1068 		__entry->new_lsn = new_lsn;
1069 	),
1070 	TP_printk("dev %d:%d lip %p old lsn %d/%d new lsn %d/%d type %s flags %s",
1071 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1072 		  __entry->lip,
1073 		  CYCLE_LSN(__entry->old_lsn), BLOCK_LSN(__entry->old_lsn),
1074 		  CYCLE_LSN(__entry->new_lsn), BLOCK_LSN(__entry->new_lsn),
1075 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
1076 		  __print_flags(__entry->flags, "|", XFS_LI_FLAGS))
1077 )
1078 
1079 #define DEFINE_AIL_EVENT(name) \
1080 DEFINE_EVENT(xfs_ail_class, name, \
1081 	TP_PROTO(struct xfs_log_item *lip, xfs_lsn_t old_lsn, xfs_lsn_t new_lsn), \
1082 	TP_ARGS(lip, old_lsn, new_lsn))
1083 DEFINE_AIL_EVENT(xfs_ail_insert);
1084 DEFINE_AIL_EVENT(xfs_ail_move);
1085 DEFINE_AIL_EVENT(xfs_ail_delete);
1086 
1087 TRACE_EVENT(xfs_log_assign_tail_lsn,
1088 	TP_PROTO(struct xlog *log, xfs_lsn_t new_lsn),
1089 	TP_ARGS(log, new_lsn),
1090 	TP_STRUCT__entry(
1091 		__field(dev_t, dev)
1092 		__field(xfs_lsn_t, new_lsn)
1093 		__field(xfs_lsn_t, old_lsn)
1094 		__field(xfs_lsn_t, last_sync_lsn)
1095 	),
1096 	TP_fast_assign(
1097 		__entry->dev = log->l_mp->m_super->s_dev;
1098 		__entry->new_lsn = new_lsn;
1099 		__entry->old_lsn = atomic64_read(&log->l_tail_lsn);
1100 		__entry->last_sync_lsn = atomic64_read(&log->l_last_sync_lsn);
1101 	),
1102 	TP_printk("dev %d:%d new tail lsn %d/%d, old lsn %d/%d, last sync %d/%d",
1103 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1104 		  CYCLE_LSN(__entry->new_lsn), BLOCK_LSN(__entry->new_lsn),
1105 		  CYCLE_LSN(__entry->old_lsn), BLOCK_LSN(__entry->old_lsn),
1106 		  CYCLE_LSN(__entry->last_sync_lsn), BLOCK_LSN(__entry->last_sync_lsn))
1107 )
1108 
1109 DECLARE_EVENT_CLASS(xfs_file_class,
1110 	TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset),
1111 	TP_ARGS(ip, count, offset),
1112 	TP_STRUCT__entry(
1113 		__field(dev_t, dev)
1114 		__field(xfs_ino_t, ino)
1115 		__field(xfs_fsize_t, size)
1116 		__field(loff_t, offset)
1117 		__field(size_t, count)
1118 	),
1119 	TP_fast_assign(
1120 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1121 		__entry->ino = ip->i_ino;
1122 		__entry->size = ip->i_d.di_size;
1123 		__entry->offset = offset;
1124 		__entry->count = count;
1125 	),
1126 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx count 0x%zx",
1127 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1128 		  __entry->ino,
1129 		  __entry->size,
1130 		  __entry->offset,
1131 		  __entry->count)
1132 )
1133 
1134 #define DEFINE_RW_EVENT(name)		\
1135 DEFINE_EVENT(xfs_file_class, name,	\
1136 	TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset),	\
1137 	TP_ARGS(ip, count, offset))
1138 DEFINE_RW_EVENT(xfs_file_buffered_read);
1139 DEFINE_RW_EVENT(xfs_file_direct_read);
1140 DEFINE_RW_EVENT(xfs_file_dax_read);
1141 DEFINE_RW_EVENT(xfs_file_buffered_write);
1142 DEFINE_RW_EVENT(xfs_file_direct_write);
1143 DEFINE_RW_EVENT(xfs_file_dax_write);
1144 
1145 DECLARE_EVENT_CLASS(xfs_page_class,
1146 	TP_PROTO(struct inode *inode, struct page *page, unsigned long off,
1147 		 unsigned int len),
1148 	TP_ARGS(inode, page, off, len),
1149 	TP_STRUCT__entry(
1150 		__field(dev_t, dev)
1151 		__field(xfs_ino_t, ino)
1152 		__field(pgoff_t, pgoff)
1153 		__field(loff_t, size)
1154 		__field(unsigned long, offset)
1155 		__field(unsigned int, length)
1156 		__field(int, delalloc)
1157 		__field(int, unwritten)
1158 	),
1159 	TP_fast_assign(
1160 		int delalloc = -1, unwritten = -1;
1161 
1162 		if (page_has_buffers(page))
1163 			xfs_count_page_state(page, &delalloc, &unwritten);
1164 		__entry->dev = inode->i_sb->s_dev;
1165 		__entry->ino = XFS_I(inode)->i_ino;
1166 		__entry->pgoff = page_offset(page);
1167 		__entry->size = i_size_read(inode);
1168 		__entry->offset = off;
1169 		__entry->length = len;
1170 		__entry->delalloc = delalloc;
1171 		__entry->unwritten = unwritten;
1172 	),
1173 	TP_printk("dev %d:%d ino 0x%llx pgoff 0x%lx size 0x%llx offset %lx "
1174 		  "length %x delalloc %d unwritten %d",
1175 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1176 		  __entry->ino,
1177 		  __entry->pgoff,
1178 		  __entry->size,
1179 		  __entry->offset,
1180 		  __entry->length,
1181 		  __entry->delalloc,
1182 		  __entry->unwritten)
1183 )
1184 
1185 #define DEFINE_PAGE_EVENT(name)		\
1186 DEFINE_EVENT(xfs_page_class, name,	\
1187 	TP_PROTO(struct inode *inode, struct page *page, unsigned long off, \
1188 		 unsigned int len),	\
1189 	TP_ARGS(inode, page, off, len))
1190 DEFINE_PAGE_EVENT(xfs_writepage);
1191 DEFINE_PAGE_EVENT(xfs_releasepage);
1192 DEFINE_PAGE_EVENT(xfs_invalidatepage);
1193 
1194 DECLARE_EVENT_CLASS(xfs_readpage_class,
1195 	TP_PROTO(struct inode *inode, int nr_pages),
1196 	TP_ARGS(inode, nr_pages),
1197 	TP_STRUCT__entry(
1198 		__field(dev_t, dev)
1199 		__field(xfs_ino_t, ino)
1200 		__field(int, nr_pages)
1201 	),
1202 	TP_fast_assign(
1203 		__entry->dev = inode->i_sb->s_dev;
1204 		__entry->ino = inode->i_ino;
1205 		__entry->nr_pages = nr_pages;
1206 	),
1207 	TP_printk("dev %d:%d ino 0x%llx nr_pages %d",
1208 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1209 		  __entry->ino,
1210 		  __entry->nr_pages)
1211 )
1212 
1213 #define DEFINE_READPAGE_EVENT(name)		\
1214 DEFINE_EVENT(xfs_readpage_class, name,	\
1215 	TP_PROTO(struct inode *inode, int nr_pages), \
1216 	TP_ARGS(inode, nr_pages))
1217 DEFINE_READPAGE_EVENT(xfs_vm_readpage);
1218 DEFINE_READPAGE_EVENT(xfs_vm_readpages);
1219 
1220 DECLARE_EVENT_CLASS(xfs_imap_class,
1221 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,
1222 		 int type, struct xfs_bmbt_irec *irec),
1223 	TP_ARGS(ip, offset, count, type, irec),
1224 	TP_STRUCT__entry(
1225 		__field(dev_t, dev)
1226 		__field(xfs_ino_t, ino)
1227 		__field(loff_t, size)
1228 		__field(loff_t, offset)
1229 		__field(size_t, count)
1230 		__field(int, type)
1231 		__field(xfs_fileoff_t, startoff)
1232 		__field(xfs_fsblock_t, startblock)
1233 		__field(xfs_filblks_t, blockcount)
1234 	),
1235 	TP_fast_assign(
1236 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1237 		__entry->ino = ip->i_ino;
1238 		__entry->size = ip->i_d.di_size;
1239 		__entry->offset = offset;
1240 		__entry->count = count;
1241 		__entry->type = type;
1242 		__entry->startoff = irec ? irec->br_startoff : 0;
1243 		__entry->startblock = irec ? irec->br_startblock : 0;
1244 		__entry->blockcount = irec ? irec->br_blockcount : 0;
1245 	),
1246 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx count %zd "
1247 		  "type %s startoff 0x%llx startblock %lld blockcount 0x%llx",
1248 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1249 		  __entry->ino,
1250 		  __entry->size,
1251 		  __entry->offset,
1252 		  __entry->count,
1253 		  __print_symbolic(__entry->type, XFS_IO_TYPES),
1254 		  __entry->startoff,
1255 		  (int64_t)__entry->startblock,
1256 		  __entry->blockcount)
1257 )
1258 
1259 #define DEFINE_IOMAP_EVENT(name)	\
1260 DEFINE_EVENT(xfs_imap_class, name,	\
1261 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,	\
1262 		 int type, struct xfs_bmbt_irec *irec),		\
1263 	TP_ARGS(ip, offset, count, type, irec))
1264 DEFINE_IOMAP_EVENT(xfs_map_blocks_found);
1265 DEFINE_IOMAP_EVENT(xfs_map_blocks_alloc);
1266 DEFINE_IOMAP_EVENT(xfs_get_blocks_found);
1267 DEFINE_IOMAP_EVENT(xfs_get_blocks_alloc);
1268 DEFINE_IOMAP_EVENT(xfs_get_blocks_map_direct);
1269 DEFINE_IOMAP_EVENT(xfs_iomap_alloc);
1270 DEFINE_IOMAP_EVENT(xfs_iomap_found);
1271 
1272 DECLARE_EVENT_CLASS(xfs_simple_io_class,
1273 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),
1274 	TP_ARGS(ip, offset, count),
1275 	TP_STRUCT__entry(
1276 		__field(dev_t, dev)
1277 		__field(xfs_ino_t, ino)
1278 		__field(loff_t, isize)
1279 		__field(loff_t, disize)
1280 		__field(loff_t, offset)
1281 		__field(size_t, count)
1282 	),
1283 	TP_fast_assign(
1284 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1285 		__entry->ino = ip->i_ino;
1286 		__entry->isize = VFS_I(ip)->i_size;
1287 		__entry->disize = ip->i_d.di_size;
1288 		__entry->offset = offset;
1289 		__entry->count = count;
1290 	),
1291 	TP_printk("dev %d:%d ino 0x%llx isize 0x%llx disize 0x%llx "
1292 		  "offset 0x%llx count %zd",
1293 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1294 		  __entry->ino,
1295 		  __entry->isize,
1296 		  __entry->disize,
1297 		  __entry->offset,
1298 		  __entry->count)
1299 );
1300 
1301 #define DEFINE_SIMPLE_IO_EVENT(name)	\
1302 DEFINE_EVENT(xfs_simple_io_class, name,	\
1303 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),	\
1304 	TP_ARGS(ip, offset, count))
1305 DEFINE_SIMPLE_IO_EVENT(xfs_delalloc_enospc);
1306 DEFINE_SIMPLE_IO_EVENT(xfs_unwritten_convert);
1307 DEFINE_SIMPLE_IO_EVENT(xfs_get_blocks_notfound);
1308 DEFINE_SIMPLE_IO_EVENT(xfs_setfilesize);
1309 DEFINE_SIMPLE_IO_EVENT(xfs_zero_eof);
1310 DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write);
1311 DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_unwritten);
1312 DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_append);
1313 
1314 DECLARE_EVENT_CLASS(xfs_itrunc_class,
1315 	TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size),
1316 	TP_ARGS(ip, new_size),
1317 	TP_STRUCT__entry(
1318 		__field(dev_t, dev)
1319 		__field(xfs_ino_t, ino)
1320 		__field(xfs_fsize_t, size)
1321 		__field(xfs_fsize_t, new_size)
1322 	),
1323 	TP_fast_assign(
1324 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1325 		__entry->ino = ip->i_ino;
1326 		__entry->size = ip->i_d.di_size;
1327 		__entry->new_size = new_size;
1328 	),
1329 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx",
1330 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1331 		  __entry->ino,
1332 		  __entry->size,
1333 		  __entry->new_size)
1334 )
1335 
1336 #define DEFINE_ITRUNC_EVENT(name) \
1337 DEFINE_EVENT(xfs_itrunc_class, name, \
1338 	TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), \
1339 	TP_ARGS(ip, new_size))
1340 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_start);
1341 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_end);
1342 
1343 TRACE_EVENT(xfs_pagecache_inval,
1344 	TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),
1345 	TP_ARGS(ip, start, finish),
1346 	TP_STRUCT__entry(
1347 		__field(dev_t, dev)
1348 		__field(xfs_ino_t, ino)
1349 		__field(xfs_fsize_t, size)
1350 		__field(xfs_off_t, start)
1351 		__field(xfs_off_t, finish)
1352 	),
1353 	TP_fast_assign(
1354 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1355 		__entry->ino = ip->i_ino;
1356 		__entry->size = ip->i_d.di_size;
1357 		__entry->start = start;
1358 		__entry->finish = finish;
1359 	),
1360 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx start 0x%llx finish 0x%llx",
1361 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1362 		  __entry->ino,
1363 		  __entry->size,
1364 		  __entry->start,
1365 		  __entry->finish)
1366 );
1367 
1368 TRACE_EVENT(xfs_bunmap,
1369 	TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t len,
1370 		 int flags, unsigned long caller_ip),
1371 	TP_ARGS(ip, bno, len, flags, caller_ip),
1372 	TP_STRUCT__entry(
1373 		__field(dev_t, dev)
1374 		__field(xfs_ino_t, ino)
1375 		__field(xfs_fsize_t, size)
1376 		__field(xfs_fileoff_t, bno)
1377 		__field(xfs_filblks_t, len)
1378 		__field(unsigned long, caller_ip)
1379 		__field(int, flags)
1380 	),
1381 	TP_fast_assign(
1382 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1383 		__entry->ino = ip->i_ino;
1384 		__entry->size = ip->i_d.di_size;
1385 		__entry->bno = bno;
1386 		__entry->len = len;
1387 		__entry->caller_ip = caller_ip;
1388 		__entry->flags = flags;
1389 	),
1390 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx bno 0x%llx len 0x%llx"
1391 		  "flags %s caller %pS",
1392 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1393 		  __entry->ino,
1394 		  __entry->size,
1395 		  __entry->bno,
1396 		  __entry->len,
1397 		  __print_flags(__entry->flags, "|", XFS_BMAPI_FLAGS),
1398 		  (void *)__entry->caller_ip)
1399 
1400 );
1401 
1402 DECLARE_EVENT_CLASS(xfs_extent_busy_class,
1403 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1404 		 xfs_agblock_t agbno, xfs_extlen_t len),
1405 	TP_ARGS(mp, agno, agbno, len),
1406 	TP_STRUCT__entry(
1407 		__field(dev_t, dev)
1408 		__field(xfs_agnumber_t, agno)
1409 		__field(xfs_agblock_t, agbno)
1410 		__field(xfs_extlen_t, len)
1411 	),
1412 	TP_fast_assign(
1413 		__entry->dev = mp->m_super->s_dev;
1414 		__entry->agno = agno;
1415 		__entry->agbno = agbno;
1416 		__entry->len = len;
1417 	),
1418 	TP_printk("dev %d:%d agno %u agbno %u len %u",
1419 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1420 		  __entry->agno,
1421 		  __entry->agbno,
1422 		  __entry->len)
1423 );
1424 #define DEFINE_BUSY_EVENT(name) \
1425 DEFINE_EVENT(xfs_extent_busy_class, name, \
1426 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1427 		 xfs_agblock_t agbno, xfs_extlen_t len), \
1428 	TP_ARGS(mp, agno, agbno, len))
1429 DEFINE_BUSY_EVENT(xfs_extent_busy);
1430 DEFINE_BUSY_EVENT(xfs_extent_busy_enomem);
1431 DEFINE_BUSY_EVENT(xfs_extent_busy_force);
1432 DEFINE_BUSY_EVENT(xfs_extent_busy_reuse);
1433 DEFINE_BUSY_EVENT(xfs_extent_busy_clear);
1434 
1435 TRACE_EVENT(xfs_extent_busy_trim,
1436 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1437 		 xfs_agblock_t agbno, xfs_extlen_t len,
1438 		 xfs_agblock_t tbno, xfs_extlen_t tlen),
1439 	TP_ARGS(mp, agno, agbno, len, tbno, tlen),
1440 	TP_STRUCT__entry(
1441 		__field(dev_t, dev)
1442 		__field(xfs_agnumber_t, agno)
1443 		__field(xfs_agblock_t, agbno)
1444 		__field(xfs_extlen_t, len)
1445 		__field(xfs_agblock_t, tbno)
1446 		__field(xfs_extlen_t, tlen)
1447 	),
1448 	TP_fast_assign(
1449 		__entry->dev = mp->m_super->s_dev;
1450 		__entry->agno = agno;
1451 		__entry->agbno = agbno;
1452 		__entry->len = len;
1453 		__entry->tbno = tbno;
1454 		__entry->tlen = tlen;
1455 	),
1456 	TP_printk("dev %d:%d agno %u agbno %u len %u tbno %u tlen %u",
1457 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1458 		  __entry->agno,
1459 		  __entry->agbno,
1460 		  __entry->len,
1461 		  __entry->tbno,
1462 		  __entry->tlen)
1463 );
1464 
1465 DECLARE_EVENT_CLASS(xfs_agf_class,
1466 	TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags,
1467 		 unsigned long caller_ip),
1468 	TP_ARGS(mp, agf, flags, caller_ip),
1469 	TP_STRUCT__entry(
1470 		__field(dev_t, dev)
1471 		__field(xfs_agnumber_t, agno)
1472 		__field(int, flags)
1473 		__field(__u32, length)
1474 		__field(__u32, bno_root)
1475 		__field(__u32, cnt_root)
1476 		__field(__u32, bno_level)
1477 		__field(__u32, cnt_level)
1478 		__field(__u32, flfirst)
1479 		__field(__u32, fllast)
1480 		__field(__u32, flcount)
1481 		__field(__u32, freeblks)
1482 		__field(__u32, longest)
1483 		__field(unsigned long, caller_ip)
1484 	),
1485 	TP_fast_assign(
1486 		__entry->dev = mp->m_super->s_dev;
1487 		__entry->agno = be32_to_cpu(agf->agf_seqno),
1488 		__entry->flags = flags;
1489 		__entry->length = be32_to_cpu(agf->agf_length),
1490 		__entry->bno_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
1491 		__entry->cnt_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
1492 		__entry->bno_level =
1493 				be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
1494 		__entry->cnt_level =
1495 				be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
1496 		__entry->flfirst = be32_to_cpu(agf->agf_flfirst),
1497 		__entry->fllast = be32_to_cpu(agf->agf_fllast),
1498 		__entry->flcount = be32_to_cpu(agf->agf_flcount),
1499 		__entry->freeblks = be32_to_cpu(agf->agf_freeblks),
1500 		__entry->longest = be32_to_cpu(agf->agf_longest);
1501 		__entry->caller_ip = caller_ip;
1502 	),
1503 	TP_printk("dev %d:%d agno %u flags %s length %u roots b %u c %u "
1504 		  "levels b %u c %u flfirst %u fllast %u flcount %u "
1505 		  "freeblks %u longest %u caller %pS",
1506 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1507 		  __entry->agno,
1508 		  __print_flags(__entry->flags, "|", XFS_AGF_FLAGS),
1509 		  __entry->length,
1510 		  __entry->bno_root,
1511 		  __entry->cnt_root,
1512 		  __entry->bno_level,
1513 		  __entry->cnt_level,
1514 		  __entry->flfirst,
1515 		  __entry->fllast,
1516 		  __entry->flcount,
1517 		  __entry->freeblks,
1518 		  __entry->longest,
1519 		  (void *)__entry->caller_ip)
1520 );
1521 #define DEFINE_AGF_EVENT(name) \
1522 DEFINE_EVENT(xfs_agf_class, name, \
1523 	TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags, \
1524 		 unsigned long caller_ip), \
1525 	TP_ARGS(mp, agf, flags, caller_ip))
1526 DEFINE_AGF_EVENT(xfs_agf);
1527 DEFINE_AGF_EVENT(xfs_agfl_reset);
1528 
1529 TRACE_EVENT(xfs_free_extent,
1530 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
1531 		 xfs_extlen_t len, enum xfs_ag_resv_type resv, int haveleft,
1532 		 int haveright),
1533 	TP_ARGS(mp, agno, agbno, len, resv, haveleft, haveright),
1534 	TP_STRUCT__entry(
1535 		__field(dev_t, dev)
1536 		__field(xfs_agnumber_t, agno)
1537 		__field(xfs_agblock_t, agbno)
1538 		__field(xfs_extlen_t, len)
1539 		__field(int, resv)
1540 		__field(int, haveleft)
1541 		__field(int, haveright)
1542 	),
1543 	TP_fast_assign(
1544 		__entry->dev = mp->m_super->s_dev;
1545 		__entry->agno = agno;
1546 		__entry->agbno = agbno;
1547 		__entry->len = len;
1548 		__entry->resv = resv;
1549 		__entry->haveleft = haveleft;
1550 		__entry->haveright = haveright;
1551 	),
1552 	TP_printk("dev %d:%d agno %u agbno %u len %u resv %d %s",
1553 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1554 		  __entry->agno,
1555 		  __entry->agbno,
1556 		  __entry->len,
1557 		  __entry->resv,
1558 		  __entry->haveleft ?
1559 			(__entry->haveright ? "both" : "left") :
1560 			(__entry->haveright ? "right" : "none"))
1561 
1562 );
1563 
1564 DECLARE_EVENT_CLASS(xfs_alloc_class,
1565 	TP_PROTO(struct xfs_alloc_arg *args),
1566 	TP_ARGS(args),
1567 	TP_STRUCT__entry(
1568 		__field(dev_t, dev)
1569 		__field(xfs_agnumber_t, agno)
1570 		__field(xfs_agblock_t, agbno)
1571 		__field(xfs_extlen_t, minlen)
1572 		__field(xfs_extlen_t, maxlen)
1573 		__field(xfs_extlen_t, mod)
1574 		__field(xfs_extlen_t, prod)
1575 		__field(xfs_extlen_t, minleft)
1576 		__field(xfs_extlen_t, total)
1577 		__field(xfs_extlen_t, alignment)
1578 		__field(xfs_extlen_t, minalignslop)
1579 		__field(xfs_extlen_t, len)
1580 		__field(short, type)
1581 		__field(short, otype)
1582 		__field(char, wasdel)
1583 		__field(char, wasfromfl)
1584 		__field(int, resv)
1585 		__field(int, datatype)
1586 		__field(xfs_fsblock_t, firstblock)
1587 	),
1588 	TP_fast_assign(
1589 		__entry->dev = args->mp->m_super->s_dev;
1590 		__entry->agno = args->agno;
1591 		__entry->agbno = args->agbno;
1592 		__entry->minlen = args->minlen;
1593 		__entry->maxlen = args->maxlen;
1594 		__entry->mod = args->mod;
1595 		__entry->prod = args->prod;
1596 		__entry->minleft = args->minleft;
1597 		__entry->total = args->total;
1598 		__entry->alignment = args->alignment;
1599 		__entry->minalignslop = args->minalignslop;
1600 		__entry->len = args->len;
1601 		__entry->type = args->type;
1602 		__entry->otype = args->otype;
1603 		__entry->wasdel = args->wasdel;
1604 		__entry->wasfromfl = args->wasfromfl;
1605 		__entry->resv = args->resv;
1606 		__entry->datatype = args->datatype;
1607 		__entry->firstblock = args->firstblock;
1608 	),
1609 	TP_printk("dev %d:%d agno %u agbno %u minlen %u maxlen %u mod %u "
1610 		  "prod %u minleft %u total %u alignment %u minalignslop %u "
1611 		  "len %u type %s otype %s wasdel %d wasfromfl %d resv %d "
1612 		  "datatype 0x%x firstblock 0x%llx",
1613 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1614 		  __entry->agno,
1615 		  __entry->agbno,
1616 		  __entry->minlen,
1617 		  __entry->maxlen,
1618 		  __entry->mod,
1619 		  __entry->prod,
1620 		  __entry->minleft,
1621 		  __entry->total,
1622 		  __entry->alignment,
1623 		  __entry->minalignslop,
1624 		  __entry->len,
1625 		  __print_symbolic(__entry->type, XFS_ALLOC_TYPES),
1626 		  __print_symbolic(__entry->otype, XFS_ALLOC_TYPES),
1627 		  __entry->wasdel,
1628 		  __entry->wasfromfl,
1629 		  __entry->resv,
1630 		  __entry->datatype,
1631 		  (unsigned long long)__entry->firstblock)
1632 )
1633 
1634 #define DEFINE_ALLOC_EVENT(name) \
1635 DEFINE_EVENT(xfs_alloc_class, name, \
1636 	TP_PROTO(struct xfs_alloc_arg *args), \
1637 	TP_ARGS(args))
1638 DEFINE_ALLOC_EVENT(xfs_alloc_exact_done);
1639 DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound);
1640 DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
1641 DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
1642 DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
1643 DEFINE_ALLOC_EVENT(xfs_alloc_near_greater);
1644 DEFINE_ALLOC_EVENT(xfs_alloc_near_lesser);
1645 DEFINE_ALLOC_EVENT(xfs_alloc_near_error);
1646 DEFINE_ALLOC_EVENT(xfs_alloc_near_noentry);
1647 DEFINE_ALLOC_EVENT(xfs_alloc_near_busy);
1648 DEFINE_ALLOC_EVENT(xfs_alloc_size_neither);
1649 DEFINE_ALLOC_EVENT(xfs_alloc_size_noentry);
1650 DEFINE_ALLOC_EVENT(xfs_alloc_size_nominleft);
1651 DEFINE_ALLOC_EVENT(xfs_alloc_size_done);
1652 DEFINE_ALLOC_EVENT(xfs_alloc_size_error);
1653 DEFINE_ALLOC_EVENT(xfs_alloc_size_busy);
1654 DEFINE_ALLOC_EVENT(xfs_alloc_small_freelist);
1655 DEFINE_ALLOC_EVENT(xfs_alloc_small_notenough);
1656 DEFINE_ALLOC_EVENT(xfs_alloc_small_done);
1657 DEFINE_ALLOC_EVENT(xfs_alloc_small_error);
1658 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_badargs);
1659 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_nofix);
1660 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp);
1661 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed);
1662 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed);
1663 
1664 DECLARE_EVENT_CLASS(xfs_da_class,
1665 	TP_PROTO(struct xfs_da_args *args),
1666 	TP_ARGS(args),
1667 	TP_STRUCT__entry(
1668 		__field(dev_t, dev)
1669 		__field(xfs_ino_t, ino)
1670 		__dynamic_array(char, name, args->namelen)
1671 		__field(int, namelen)
1672 		__field(xfs_dahash_t, hashval)
1673 		__field(xfs_ino_t, inumber)
1674 		__field(int, op_flags)
1675 	),
1676 	TP_fast_assign(
1677 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1678 		__entry->ino = args->dp->i_ino;
1679 		if (args->namelen)
1680 			memcpy(__get_str(name), args->name, args->namelen);
1681 		__entry->namelen = args->namelen;
1682 		__entry->hashval = args->hashval;
1683 		__entry->inumber = args->inumber;
1684 		__entry->op_flags = args->op_flags;
1685 	),
1686 	TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d hashval 0x%x "
1687 		  "inumber 0x%llx op_flags %s",
1688 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1689 		  __entry->ino,
1690 		  __entry->namelen,
1691 		  __entry->namelen ? __get_str(name) : NULL,
1692 		  __entry->namelen,
1693 		  __entry->hashval,
1694 		  __entry->inumber,
1695 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS))
1696 )
1697 
1698 #define DEFINE_DIR2_EVENT(name) \
1699 DEFINE_EVENT(xfs_da_class, name, \
1700 	TP_PROTO(struct xfs_da_args *args), \
1701 	TP_ARGS(args))
1702 DEFINE_DIR2_EVENT(xfs_dir2_sf_addname);
1703 DEFINE_DIR2_EVENT(xfs_dir2_sf_create);
1704 DEFINE_DIR2_EVENT(xfs_dir2_sf_lookup);
1705 DEFINE_DIR2_EVENT(xfs_dir2_sf_replace);
1706 DEFINE_DIR2_EVENT(xfs_dir2_sf_removename);
1707 DEFINE_DIR2_EVENT(xfs_dir2_sf_toino4);
1708 DEFINE_DIR2_EVENT(xfs_dir2_sf_toino8);
1709 DEFINE_DIR2_EVENT(xfs_dir2_sf_to_block);
1710 DEFINE_DIR2_EVENT(xfs_dir2_block_addname);
1711 DEFINE_DIR2_EVENT(xfs_dir2_block_lookup);
1712 DEFINE_DIR2_EVENT(xfs_dir2_block_replace);
1713 DEFINE_DIR2_EVENT(xfs_dir2_block_removename);
1714 DEFINE_DIR2_EVENT(xfs_dir2_block_to_sf);
1715 DEFINE_DIR2_EVENT(xfs_dir2_block_to_leaf);
1716 DEFINE_DIR2_EVENT(xfs_dir2_leaf_addname);
1717 DEFINE_DIR2_EVENT(xfs_dir2_leaf_lookup);
1718 DEFINE_DIR2_EVENT(xfs_dir2_leaf_replace);
1719 DEFINE_DIR2_EVENT(xfs_dir2_leaf_removename);
1720 DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_block);
1721 DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_node);
1722 DEFINE_DIR2_EVENT(xfs_dir2_node_addname);
1723 DEFINE_DIR2_EVENT(xfs_dir2_node_lookup);
1724 DEFINE_DIR2_EVENT(xfs_dir2_node_replace);
1725 DEFINE_DIR2_EVENT(xfs_dir2_node_removename);
1726 DEFINE_DIR2_EVENT(xfs_dir2_node_to_leaf);
1727 
1728 DECLARE_EVENT_CLASS(xfs_attr_class,
1729 	TP_PROTO(struct xfs_da_args *args),
1730 	TP_ARGS(args),
1731 	TP_STRUCT__entry(
1732 		__field(dev_t, dev)
1733 		__field(xfs_ino_t, ino)
1734 		__dynamic_array(char, name, args->namelen)
1735 		__field(int, namelen)
1736 		__field(int, valuelen)
1737 		__field(xfs_dahash_t, hashval)
1738 		__field(int, flags)
1739 		__field(int, op_flags)
1740 	),
1741 	TP_fast_assign(
1742 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1743 		__entry->ino = args->dp->i_ino;
1744 		if (args->namelen)
1745 			memcpy(__get_str(name), args->name, args->namelen);
1746 		__entry->namelen = args->namelen;
1747 		__entry->valuelen = args->valuelen;
1748 		__entry->hashval = args->hashval;
1749 		__entry->flags = args->flags;
1750 		__entry->op_flags = args->op_flags;
1751 	),
1752 	TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d "
1753 		  "hashval 0x%x flags %s op_flags %s",
1754 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1755 		  __entry->ino,
1756 		  __entry->namelen,
1757 		  __entry->namelen ? __get_str(name) : NULL,
1758 		  __entry->namelen,
1759 		  __entry->valuelen,
1760 		  __entry->hashval,
1761 		  __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS),
1762 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS))
1763 )
1764 
1765 #define DEFINE_ATTR_EVENT(name) \
1766 DEFINE_EVENT(xfs_attr_class, name, \
1767 	TP_PROTO(struct xfs_da_args *args), \
1768 	TP_ARGS(args))
1769 DEFINE_ATTR_EVENT(xfs_attr_sf_add);
1770 DEFINE_ATTR_EVENT(xfs_attr_sf_addname);
1771 DEFINE_ATTR_EVENT(xfs_attr_sf_create);
1772 DEFINE_ATTR_EVENT(xfs_attr_sf_lookup);
1773 DEFINE_ATTR_EVENT(xfs_attr_sf_remove);
1774 DEFINE_ATTR_EVENT(xfs_attr_sf_to_leaf);
1775 
1776 DEFINE_ATTR_EVENT(xfs_attr_leaf_add);
1777 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old);
1778 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new);
1779 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_work);
1780 DEFINE_ATTR_EVENT(xfs_attr_leaf_addname);
1781 DEFINE_ATTR_EVENT(xfs_attr_leaf_create);
1782 DEFINE_ATTR_EVENT(xfs_attr_leaf_compact);
1783 DEFINE_ATTR_EVENT(xfs_attr_leaf_get);
1784 DEFINE_ATTR_EVENT(xfs_attr_leaf_lookup);
1785 DEFINE_ATTR_EVENT(xfs_attr_leaf_replace);
1786 DEFINE_ATTR_EVENT(xfs_attr_leaf_remove);
1787 DEFINE_ATTR_EVENT(xfs_attr_leaf_removename);
1788 DEFINE_ATTR_EVENT(xfs_attr_leaf_split);
1789 DEFINE_ATTR_EVENT(xfs_attr_leaf_split_before);
1790 DEFINE_ATTR_EVENT(xfs_attr_leaf_split_after);
1791 DEFINE_ATTR_EVENT(xfs_attr_leaf_clearflag);
1792 DEFINE_ATTR_EVENT(xfs_attr_leaf_setflag);
1793 DEFINE_ATTR_EVENT(xfs_attr_leaf_flipflags);
1794 DEFINE_ATTR_EVENT(xfs_attr_leaf_to_sf);
1795 DEFINE_ATTR_EVENT(xfs_attr_leaf_to_node);
1796 DEFINE_ATTR_EVENT(xfs_attr_leaf_rebalance);
1797 DEFINE_ATTR_EVENT(xfs_attr_leaf_unbalance);
1798 DEFINE_ATTR_EVENT(xfs_attr_leaf_toosmall);
1799 
1800 DEFINE_ATTR_EVENT(xfs_attr_node_addname);
1801 DEFINE_ATTR_EVENT(xfs_attr_node_get);
1802 DEFINE_ATTR_EVENT(xfs_attr_node_replace);
1803 DEFINE_ATTR_EVENT(xfs_attr_node_removename);
1804 
1805 DEFINE_ATTR_EVENT(xfs_attr_fillstate);
1806 DEFINE_ATTR_EVENT(xfs_attr_refillstate);
1807 
1808 DEFINE_ATTR_EVENT(xfs_attr_rmtval_get);
1809 DEFINE_ATTR_EVENT(xfs_attr_rmtval_set);
1810 DEFINE_ATTR_EVENT(xfs_attr_rmtval_remove);
1811 
1812 #define DEFINE_DA_EVENT(name) \
1813 DEFINE_EVENT(xfs_da_class, name, \
1814 	TP_PROTO(struct xfs_da_args *args), \
1815 	TP_ARGS(args))
1816 DEFINE_DA_EVENT(xfs_da_split);
1817 DEFINE_DA_EVENT(xfs_da_join);
1818 DEFINE_DA_EVENT(xfs_da_link_before);
1819 DEFINE_DA_EVENT(xfs_da_link_after);
1820 DEFINE_DA_EVENT(xfs_da_unlink_back);
1821 DEFINE_DA_EVENT(xfs_da_unlink_forward);
1822 DEFINE_DA_EVENT(xfs_da_root_split);
1823 DEFINE_DA_EVENT(xfs_da_root_join);
1824 DEFINE_DA_EVENT(xfs_da_node_add);
1825 DEFINE_DA_EVENT(xfs_da_node_create);
1826 DEFINE_DA_EVENT(xfs_da_node_split);
1827 DEFINE_DA_EVENT(xfs_da_node_remove);
1828 DEFINE_DA_EVENT(xfs_da_node_rebalance);
1829 DEFINE_DA_EVENT(xfs_da_node_unbalance);
1830 DEFINE_DA_EVENT(xfs_da_node_toosmall);
1831 DEFINE_DA_EVENT(xfs_da_swap_lastblock);
1832 DEFINE_DA_EVENT(xfs_da_grow_inode);
1833 DEFINE_DA_EVENT(xfs_da_shrink_inode);
1834 DEFINE_DA_EVENT(xfs_da_fixhashpath);
1835 DEFINE_DA_EVENT(xfs_da_path_shift);
1836 
1837 DECLARE_EVENT_CLASS(xfs_dir2_space_class,
1838 	TP_PROTO(struct xfs_da_args *args, int idx),
1839 	TP_ARGS(args, idx),
1840 	TP_STRUCT__entry(
1841 		__field(dev_t, dev)
1842 		__field(xfs_ino_t, ino)
1843 		__field(int, op_flags)
1844 		__field(int, idx)
1845 	),
1846 	TP_fast_assign(
1847 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1848 		__entry->ino = args->dp->i_ino;
1849 		__entry->op_flags = args->op_flags;
1850 		__entry->idx = idx;
1851 	),
1852 	TP_printk("dev %d:%d ino 0x%llx op_flags %s index %d",
1853 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1854 		  __entry->ino,
1855 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
1856 		  __entry->idx)
1857 )
1858 
1859 #define DEFINE_DIR2_SPACE_EVENT(name) \
1860 DEFINE_EVENT(xfs_dir2_space_class, name, \
1861 	TP_PROTO(struct xfs_da_args *args, int idx), \
1862 	TP_ARGS(args, idx))
1863 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_add);
1864 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_remove);
1865 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_grow_inode);
1866 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_shrink_inode);
1867 
1868 TRACE_EVENT(xfs_dir2_leafn_moveents,
1869 	TP_PROTO(struct xfs_da_args *args, int src_idx, int dst_idx, int count),
1870 	TP_ARGS(args, src_idx, dst_idx, count),
1871 	TP_STRUCT__entry(
1872 		__field(dev_t, dev)
1873 		__field(xfs_ino_t, ino)
1874 		__field(int, op_flags)
1875 		__field(int, src_idx)
1876 		__field(int, dst_idx)
1877 		__field(int, count)
1878 	),
1879 	TP_fast_assign(
1880 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1881 		__entry->ino = args->dp->i_ino;
1882 		__entry->op_flags = args->op_flags;
1883 		__entry->src_idx = src_idx;
1884 		__entry->dst_idx = dst_idx;
1885 		__entry->count = count;
1886 	),
1887 	TP_printk("dev %d:%d ino 0x%llx op_flags %s "
1888 		  "src_idx %d dst_idx %d count %d",
1889 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1890 		  __entry->ino,
1891 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
1892 		  __entry->src_idx,
1893 		  __entry->dst_idx,
1894 		  __entry->count)
1895 );
1896 
1897 #define XFS_SWAPEXT_INODES \
1898 	{ 0,	"target" }, \
1899 	{ 1,	"temp" }
1900 
1901 #define XFS_INODE_FORMAT_STR \
1902 	{ 0,	"invalid" }, \
1903 	{ 1,	"local" }, \
1904 	{ 2,	"extent" }, \
1905 	{ 3,	"btree" }
1906 
1907 DECLARE_EVENT_CLASS(xfs_swap_extent_class,
1908 	TP_PROTO(struct xfs_inode *ip, int which),
1909 	TP_ARGS(ip, which),
1910 	TP_STRUCT__entry(
1911 		__field(dev_t, dev)
1912 		__field(int, which)
1913 		__field(xfs_ino_t, ino)
1914 		__field(int, format)
1915 		__field(int, nex)
1916 		__field(int, broot_size)
1917 		__field(int, fork_off)
1918 	),
1919 	TP_fast_assign(
1920 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1921 		__entry->which = which;
1922 		__entry->ino = ip->i_ino;
1923 		__entry->format = ip->i_d.di_format;
1924 		__entry->nex = ip->i_d.di_nextents;
1925 		__entry->broot_size = ip->i_df.if_broot_bytes;
1926 		__entry->fork_off = XFS_IFORK_BOFF(ip);
1927 	),
1928 	TP_printk("dev %d:%d ino 0x%llx (%s), %s format, num_extents %d, "
1929 		  "broot size %d, fork offset %d",
1930 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1931 		  __entry->ino,
1932 		  __print_symbolic(__entry->which, XFS_SWAPEXT_INODES),
1933 		  __print_symbolic(__entry->format, XFS_INODE_FORMAT_STR),
1934 		  __entry->nex,
1935 		  __entry->broot_size,
1936 		  __entry->fork_off)
1937 )
1938 
1939 #define DEFINE_SWAPEXT_EVENT(name) \
1940 DEFINE_EVENT(xfs_swap_extent_class, name, \
1941 	TP_PROTO(struct xfs_inode *ip, int which), \
1942 	TP_ARGS(ip, which))
1943 
1944 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_before);
1945 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_after);
1946 
1947 TRACE_EVENT(xfs_log_recover,
1948 	TP_PROTO(struct xlog *log, xfs_daddr_t headblk, xfs_daddr_t tailblk),
1949 	TP_ARGS(log, headblk, tailblk),
1950 	TP_STRUCT__entry(
1951 		__field(dev_t, dev)
1952 		__field(xfs_daddr_t, headblk)
1953 		__field(xfs_daddr_t, tailblk)
1954 	),
1955 	TP_fast_assign(
1956 		__entry->dev = log->l_mp->m_super->s_dev;
1957 		__entry->headblk = headblk;
1958 		__entry->tailblk = tailblk;
1959 	),
1960 	TP_printk("dev %d:%d headblk 0x%llx tailblk 0x%llx",
1961 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->headblk,
1962 		  __entry->tailblk)
1963 )
1964 
1965 TRACE_EVENT(xfs_log_recover_record,
1966 	TP_PROTO(struct xlog *log, struct xlog_rec_header *rhead, int pass),
1967 	TP_ARGS(log, rhead, pass),
1968 	TP_STRUCT__entry(
1969 		__field(dev_t, dev)
1970 		__field(xfs_lsn_t, lsn)
1971 		__field(int, len)
1972 		__field(int, num_logops)
1973 		__field(int, pass)
1974 	),
1975 	TP_fast_assign(
1976 		__entry->dev = log->l_mp->m_super->s_dev;
1977 		__entry->lsn = be64_to_cpu(rhead->h_lsn);
1978 		__entry->len = be32_to_cpu(rhead->h_len);
1979 		__entry->num_logops = be32_to_cpu(rhead->h_num_logops);
1980 		__entry->pass = pass;
1981 	),
1982 	TP_printk("dev %d:%d lsn 0x%llx len 0x%x num_logops 0x%x pass %d",
1983 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1984 		  __entry->lsn, __entry->len, __entry->num_logops,
1985 		   __entry->pass)
1986 )
1987 
1988 DECLARE_EVENT_CLASS(xfs_log_recover_item_class,
1989 	TP_PROTO(struct xlog *log, struct xlog_recover *trans,
1990 		struct xlog_recover_item *item, int pass),
1991 	TP_ARGS(log, trans, item, pass),
1992 	TP_STRUCT__entry(
1993 		__field(dev_t, dev)
1994 		__field(unsigned long, item)
1995 		__field(xlog_tid_t, tid)
1996 		__field(xfs_lsn_t, lsn)
1997 		__field(int, type)
1998 		__field(int, pass)
1999 		__field(int, count)
2000 		__field(int, total)
2001 	),
2002 	TP_fast_assign(
2003 		__entry->dev = log->l_mp->m_super->s_dev;
2004 		__entry->item = (unsigned long)item;
2005 		__entry->tid = trans->r_log_tid;
2006 		__entry->lsn = trans->r_lsn;
2007 		__entry->type = ITEM_TYPE(item);
2008 		__entry->pass = pass;
2009 		__entry->count = item->ri_cnt;
2010 		__entry->total = item->ri_total;
2011 	),
2012 	TP_printk("dev %d:%d tid 0x%x lsn 0x%llx, pass %d, item %p, "
2013 		  "item type %s item region count/total %d/%d",
2014 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2015 		  __entry->tid,
2016 		  __entry->lsn,
2017 		  __entry->pass,
2018 		  (void *)__entry->item,
2019 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
2020 		  __entry->count,
2021 		  __entry->total)
2022 )
2023 
2024 #define DEFINE_LOG_RECOVER_ITEM(name) \
2025 DEFINE_EVENT(xfs_log_recover_item_class, name, \
2026 	TP_PROTO(struct xlog *log, struct xlog_recover *trans, \
2027 		struct xlog_recover_item *item, int pass), \
2028 	TP_ARGS(log, trans, item, pass))
2029 
2030 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add);
2031 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add_cont);
2032 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_head);
2033 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_tail);
2034 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_recover);
2035 
2036 DECLARE_EVENT_CLASS(xfs_log_recover_buf_item_class,
2037 	TP_PROTO(struct xlog *log, struct xfs_buf_log_format *buf_f),
2038 	TP_ARGS(log, buf_f),
2039 	TP_STRUCT__entry(
2040 		__field(dev_t, dev)
2041 		__field(int64_t, blkno)
2042 		__field(unsigned short, len)
2043 		__field(unsigned short, flags)
2044 		__field(unsigned short, size)
2045 		__field(unsigned int, map_size)
2046 	),
2047 	TP_fast_assign(
2048 		__entry->dev = log->l_mp->m_super->s_dev;
2049 		__entry->blkno = buf_f->blf_blkno;
2050 		__entry->len = buf_f->blf_len;
2051 		__entry->flags = buf_f->blf_flags;
2052 		__entry->size = buf_f->blf_size;
2053 		__entry->map_size = buf_f->blf_map_size;
2054 	),
2055 	TP_printk("dev %d:%d blkno 0x%llx, len %u, flags 0x%x, size %d, "
2056 			"map_size %d",
2057 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2058 		  __entry->blkno,
2059 		  __entry->len,
2060 		  __entry->flags,
2061 		  __entry->size,
2062 		  __entry->map_size)
2063 )
2064 
2065 #define DEFINE_LOG_RECOVER_BUF_ITEM(name) \
2066 DEFINE_EVENT(xfs_log_recover_buf_item_class, name, \
2067 	TP_PROTO(struct xlog *log, struct xfs_buf_log_format *buf_f), \
2068 	TP_ARGS(log, buf_f))
2069 
2070 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_not_cancel);
2071 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel);
2072 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_add);
2073 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_ref_inc);
2074 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_recover);
2075 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_skip);
2076 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_inode_buf);
2077 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_reg_buf);
2078 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_dquot_buf);
2079 
2080 DECLARE_EVENT_CLASS(xfs_log_recover_ino_item_class,
2081 	TP_PROTO(struct xlog *log, struct xfs_inode_log_format *in_f),
2082 	TP_ARGS(log, in_f),
2083 	TP_STRUCT__entry(
2084 		__field(dev_t, dev)
2085 		__field(xfs_ino_t, ino)
2086 		__field(unsigned short, size)
2087 		__field(int, fields)
2088 		__field(unsigned short, asize)
2089 		__field(unsigned short, dsize)
2090 		__field(int64_t, blkno)
2091 		__field(int, len)
2092 		__field(int, boffset)
2093 	),
2094 	TP_fast_assign(
2095 		__entry->dev = log->l_mp->m_super->s_dev;
2096 		__entry->ino = in_f->ilf_ino;
2097 		__entry->size = in_f->ilf_size;
2098 		__entry->fields = in_f->ilf_fields;
2099 		__entry->asize = in_f->ilf_asize;
2100 		__entry->dsize = in_f->ilf_dsize;
2101 		__entry->blkno = in_f->ilf_blkno;
2102 		__entry->len = in_f->ilf_len;
2103 		__entry->boffset = in_f->ilf_boffset;
2104 	),
2105 	TP_printk("dev %d:%d ino 0x%llx, size %u, fields 0x%x, asize %d, "
2106 			"dsize %d, blkno 0x%llx, len %d, boffset %d",
2107 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2108 		  __entry->ino,
2109 		  __entry->size,
2110 		  __entry->fields,
2111 		  __entry->asize,
2112 		  __entry->dsize,
2113 		  __entry->blkno,
2114 		  __entry->len,
2115 		  __entry->boffset)
2116 )
2117 #define DEFINE_LOG_RECOVER_INO_ITEM(name) \
2118 DEFINE_EVENT(xfs_log_recover_ino_item_class, name, \
2119 	TP_PROTO(struct xlog *log, struct xfs_inode_log_format *in_f), \
2120 	TP_ARGS(log, in_f))
2121 
2122 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_recover);
2123 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_cancel);
2124 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_skip);
2125 
2126 DECLARE_EVENT_CLASS(xfs_log_recover_icreate_item_class,
2127 	TP_PROTO(struct xlog *log, struct xfs_icreate_log *in_f),
2128 	TP_ARGS(log, in_f),
2129 	TP_STRUCT__entry(
2130 		__field(dev_t, dev)
2131 		__field(xfs_agnumber_t, agno)
2132 		__field(xfs_agblock_t, agbno)
2133 		__field(unsigned int, count)
2134 		__field(unsigned int, isize)
2135 		__field(xfs_agblock_t, length)
2136 		__field(unsigned int, gen)
2137 	),
2138 	TP_fast_assign(
2139 		__entry->dev = log->l_mp->m_super->s_dev;
2140 		__entry->agno = be32_to_cpu(in_f->icl_ag);
2141 		__entry->agbno = be32_to_cpu(in_f->icl_agbno);
2142 		__entry->count = be32_to_cpu(in_f->icl_count);
2143 		__entry->isize = be32_to_cpu(in_f->icl_isize);
2144 		__entry->length = be32_to_cpu(in_f->icl_length);
2145 		__entry->gen = be32_to_cpu(in_f->icl_gen);
2146 	),
2147 	TP_printk("dev %d:%d agno %u agbno %u count %u isize %u length %u "
2148 		  "gen %u", MAJOR(__entry->dev), MINOR(__entry->dev),
2149 		  __entry->agno, __entry->agbno, __entry->count, __entry->isize,
2150 		  __entry->length, __entry->gen)
2151 )
2152 #define DEFINE_LOG_RECOVER_ICREATE_ITEM(name) \
2153 DEFINE_EVENT(xfs_log_recover_icreate_item_class, name, \
2154 	TP_PROTO(struct xlog *log, struct xfs_icreate_log *in_f), \
2155 	TP_ARGS(log, in_f))
2156 
2157 DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_cancel);
2158 DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_recover);
2159 
2160 DECLARE_EVENT_CLASS(xfs_discard_class,
2161 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2162 		 xfs_agblock_t agbno, xfs_extlen_t len),
2163 	TP_ARGS(mp, agno, agbno, len),
2164 	TP_STRUCT__entry(
2165 		__field(dev_t, dev)
2166 		__field(xfs_agnumber_t, agno)
2167 		__field(xfs_agblock_t, agbno)
2168 		__field(xfs_extlen_t, len)
2169 	),
2170 	TP_fast_assign(
2171 		__entry->dev = mp->m_super->s_dev;
2172 		__entry->agno = agno;
2173 		__entry->agbno = agbno;
2174 		__entry->len = len;
2175 	),
2176 	TP_printk("dev %d:%d agno %u agbno %u len %u",
2177 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2178 		  __entry->agno,
2179 		  __entry->agbno,
2180 		  __entry->len)
2181 )
2182 
2183 #define DEFINE_DISCARD_EVENT(name) \
2184 DEFINE_EVENT(xfs_discard_class, name, \
2185 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2186 		 xfs_agblock_t agbno, xfs_extlen_t len), \
2187 	TP_ARGS(mp, agno, agbno, len))
2188 DEFINE_DISCARD_EVENT(xfs_discard_extent);
2189 DEFINE_DISCARD_EVENT(xfs_discard_toosmall);
2190 DEFINE_DISCARD_EVENT(xfs_discard_exclude);
2191 DEFINE_DISCARD_EVENT(xfs_discard_busy);
2192 
2193 /* btree cursor events */
2194 DECLARE_EVENT_CLASS(xfs_btree_cur_class,
2195 	TP_PROTO(struct xfs_btree_cur *cur, int level, struct xfs_buf *bp),
2196 	TP_ARGS(cur, level, bp),
2197 	TP_STRUCT__entry(
2198 		__field(dev_t, dev)
2199 		__field(xfs_btnum_t, btnum)
2200 		__field(int, level)
2201 		__field(int, nlevels)
2202 		__field(int, ptr)
2203 		__field(xfs_daddr_t, daddr)
2204 	),
2205 	TP_fast_assign(
2206 		__entry->dev = cur->bc_mp->m_super->s_dev;
2207 		__entry->btnum = cur->bc_btnum;
2208 		__entry->level = level;
2209 		__entry->nlevels = cur->bc_nlevels;
2210 		__entry->ptr = cur->bc_ptrs[level];
2211 		__entry->daddr = bp ? bp->b_bn : -1;
2212 	),
2213 	TP_printk("dev %d:%d btnum %d level %d/%d ptr %d daddr 0x%llx",
2214 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2215 		  __entry->btnum,
2216 		  __entry->level,
2217 		  __entry->nlevels,
2218 		  __entry->ptr,
2219 		  (unsigned long long)__entry->daddr)
2220 )
2221 
2222 #define DEFINE_BTREE_CUR_EVENT(name) \
2223 DEFINE_EVENT(xfs_btree_cur_class, name, \
2224 	TP_PROTO(struct xfs_btree_cur *cur, int level, struct xfs_buf *bp), \
2225 	TP_ARGS(cur, level, bp))
2226 DEFINE_BTREE_CUR_EVENT(xfs_btree_updkeys);
2227 DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range);
2228 
2229 /* deferred ops */
2230 struct xfs_defer_pending;
2231 struct xfs_defer_ops;
2232 
2233 DECLARE_EVENT_CLASS(xfs_defer_class,
2234 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop,
2235 		 unsigned long caller_ip),
2236 	TP_ARGS(mp, dop, caller_ip),
2237 	TP_STRUCT__entry(
2238 		__field(dev_t, dev)
2239 		__field(void *, dop)
2240 		__field(char, committed)
2241 		__field(char, low)
2242 		__field(unsigned long, caller_ip)
2243 	),
2244 	TP_fast_assign(
2245 		__entry->dev = mp ? mp->m_super->s_dev : 0;
2246 		__entry->dop = dop;
2247 		__entry->committed = dop->dop_committed;
2248 		__entry->low = dop->dop_low;
2249 		__entry->caller_ip = caller_ip;
2250 	),
2251 	TP_printk("dev %d:%d ops %p committed %d low %d, caller %pS",
2252 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2253 		  __entry->dop,
2254 		  __entry->committed,
2255 		  __entry->low,
2256 		  (char *)__entry->caller_ip)
2257 )
2258 #define DEFINE_DEFER_EVENT(name) \
2259 DEFINE_EVENT(xfs_defer_class, name, \
2260 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, \
2261 		 unsigned long caller_ip), \
2262 	TP_ARGS(mp, dop, caller_ip))
2263 
2264 DECLARE_EVENT_CLASS(xfs_defer_error_class,
2265 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, int error),
2266 	TP_ARGS(mp, dop, error),
2267 	TP_STRUCT__entry(
2268 		__field(dev_t, dev)
2269 		__field(void *, dop)
2270 		__field(char, committed)
2271 		__field(char, low)
2272 		__field(int, error)
2273 	),
2274 	TP_fast_assign(
2275 		__entry->dev = mp ? mp->m_super->s_dev : 0;
2276 		__entry->dop = dop;
2277 		__entry->committed = dop->dop_committed;
2278 		__entry->low = dop->dop_low;
2279 		__entry->error = error;
2280 	),
2281 	TP_printk("dev %d:%d ops %p committed %d low %d err %d",
2282 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2283 		  __entry->dop,
2284 		  __entry->committed,
2285 		  __entry->low,
2286 		  __entry->error)
2287 )
2288 #define DEFINE_DEFER_ERROR_EVENT(name) \
2289 DEFINE_EVENT(xfs_defer_error_class, name, \
2290 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, int error), \
2291 	TP_ARGS(mp, dop, error))
2292 
2293 DECLARE_EVENT_CLASS(xfs_defer_pending_class,
2294 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp),
2295 	TP_ARGS(mp, dfp),
2296 	TP_STRUCT__entry(
2297 		__field(dev_t, dev)
2298 		__field(int, type)
2299 		__field(void *, intent)
2300 		__field(char, committed)
2301 		__field(int, nr)
2302 	),
2303 	TP_fast_assign(
2304 		__entry->dev = mp ? mp->m_super->s_dev : 0;
2305 		__entry->type = dfp->dfp_type->type;
2306 		__entry->intent = dfp->dfp_intent;
2307 		__entry->committed = dfp->dfp_done != NULL;
2308 		__entry->nr = dfp->dfp_count;
2309 	),
2310 	TP_printk("dev %d:%d optype %d intent %p committed %d nr %d",
2311 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2312 		  __entry->type,
2313 		  __entry->intent,
2314 		  __entry->committed,
2315 		  __entry->nr)
2316 )
2317 #define DEFINE_DEFER_PENDING_EVENT(name) \
2318 DEFINE_EVENT(xfs_defer_pending_class, name, \
2319 	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp), \
2320 	TP_ARGS(mp, dfp))
2321 
2322 DECLARE_EVENT_CLASS(xfs_phys_extent_deferred_class,
2323 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2324 		 int type, xfs_agblock_t agbno, xfs_extlen_t len),
2325 	TP_ARGS(mp, agno, type, agbno, len),
2326 	TP_STRUCT__entry(
2327 		__field(dev_t, dev)
2328 		__field(xfs_agnumber_t, agno)
2329 		__field(int, type)
2330 		__field(xfs_agblock_t, agbno)
2331 		__field(xfs_extlen_t, len)
2332 	),
2333 	TP_fast_assign(
2334 		__entry->dev = mp->m_super->s_dev;
2335 		__entry->agno = agno;
2336 		__entry->type = type;
2337 		__entry->agbno = agbno;
2338 		__entry->len = len;
2339 	),
2340 	TP_printk("dev %d:%d op %d agno %u agbno %u len %u",
2341 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2342 		  __entry->type,
2343 		  __entry->agno,
2344 		  __entry->agbno,
2345 		  __entry->len)
2346 );
2347 #define DEFINE_PHYS_EXTENT_DEFERRED_EVENT(name) \
2348 DEFINE_EVENT(xfs_phys_extent_deferred_class, name, \
2349 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2350 		 int type, \
2351 		 xfs_agblock_t bno, \
2352 		 xfs_extlen_t len), \
2353 	TP_ARGS(mp, agno, type, bno, len))
2354 
2355 DECLARE_EVENT_CLASS(xfs_map_extent_deferred_class,
2356 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2357 		 int op,
2358 		 xfs_agblock_t agbno,
2359 		 xfs_ino_t ino,
2360 		 int whichfork,
2361 		 xfs_fileoff_t offset,
2362 		 xfs_filblks_t len,
2363 		 xfs_exntst_t state),
2364 	TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state),
2365 	TP_STRUCT__entry(
2366 		__field(dev_t, dev)
2367 		__field(xfs_agnumber_t, agno)
2368 		__field(xfs_ino_t, ino)
2369 		__field(xfs_agblock_t, agbno)
2370 		__field(int, whichfork)
2371 		__field(xfs_fileoff_t, l_loff)
2372 		__field(xfs_filblks_t, l_len)
2373 		__field(xfs_exntst_t, l_state)
2374 		__field(int, op)
2375 	),
2376 	TP_fast_assign(
2377 		__entry->dev = mp->m_super->s_dev;
2378 		__entry->agno = agno;
2379 		__entry->ino = ino;
2380 		__entry->agbno = agbno;
2381 		__entry->whichfork = whichfork;
2382 		__entry->l_loff = offset;
2383 		__entry->l_len = len;
2384 		__entry->l_state = state;
2385 		__entry->op = op;
2386 	),
2387 	TP_printk("dev %d:%d op %d agno %u agbno %u owner %lld %s offset %llu len %llu state %d",
2388 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2389 		  __entry->op,
2390 		  __entry->agno,
2391 		  __entry->agbno,
2392 		  __entry->ino,
2393 		  __entry->whichfork == XFS_ATTR_FORK ? "attr" : "data",
2394 		  __entry->l_loff,
2395 		  __entry->l_len,
2396 		  __entry->l_state)
2397 );
2398 #define DEFINE_MAP_EXTENT_DEFERRED_EVENT(name) \
2399 DEFINE_EVENT(xfs_map_extent_deferred_class, name, \
2400 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2401 		 int op, \
2402 		 xfs_agblock_t agbno, \
2403 		 xfs_ino_t ino, \
2404 		 int whichfork, \
2405 		 xfs_fileoff_t offset, \
2406 		 xfs_filblks_t len, \
2407 		 xfs_exntst_t state), \
2408 	TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state))
2409 
2410 DEFINE_DEFER_EVENT(xfs_defer_init);
2411 DEFINE_DEFER_EVENT(xfs_defer_cancel);
2412 DEFINE_DEFER_EVENT(xfs_defer_trans_roll);
2413 DEFINE_DEFER_EVENT(xfs_defer_trans_abort);
2414 DEFINE_DEFER_EVENT(xfs_defer_finish);
2415 DEFINE_DEFER_EVENT(xfs_defer_finish_done);
2416 
2417 DEFINE_DEFER_ERROR_EVENT(xfs_defer_trans_roll_error);
2418 DEFINE_DEFER_ERROR_EVENT(xfs_defer_finish_error);
2419 
2420 DEFINE_DEFER_PENDING_EVENT(xfs_defer_intake_work);
2421 DEFINE_DEFER_PENDING_EVENT(xfs_defer_intake_cancel);
2422 DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_cancel);
2423 DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_finish);
2424 DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_abort);
2425 
2426 #define DEFINE_BMAP_FREE_DEFERRED_EVENT DEFINE_PHYS_EXTENT_DEFERRED_EVENT
2427 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_bmap_free_defer);
2428 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_bmap_free_deferred);
2429 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_agfl_free_defer);
2430 DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_agfl_free_deferred);
2431 
2432 /* rmap tracepoints */
2433 DECLARE_EVENT_CLASS(xfs_rmap_class,
2434 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2435 		 xfs_agblock_t agbno, xfs_extlen_t len, bool unwritten,
2436 		 struct xfs_owner_info *oinfo),
2437 	TP_ARGS(mp, agno, agbno, len, unwritten, oinfo),
2438 	TP_STRUCT__entry(
2439 		__field(dev_t, dev)
2440 		__field(xfs_agnumber_t, agno)
2441 		__field(xfs_agblock_t, agbno)
2442 		__field(xfs_extlen_t, len)
2443 		__field(uint64_t, owner)
2444 		__field(uint64_t, offset)
2445 		__field(unsigned long, flags)
2446 	),
2447 	TP_fast_assign(
2448 		__entry->dev = mp->m_super->s_dev;
2449 		__entry->agno = agno;
2450 		__entry->agbno = agbno;
2451 		__entry->len = len;
2452 		__entry->owner = oinfo->oi_owner;
2453 		__entry->offset = oinfo->oi_offset;
2454 		__entry->flags = oinfo->oi_flags;
2455 		if (unwritten)
2456 			__entry->flags |= XFS_RMAP_UNWRITTEN;
2457 	),
2458 	TP_printk("dev %d:%d agno %u agbno %u len %u owner %lld offset %llu flags 0x%lx",
2459 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2460 		  __entry->agno,
2461 		  __entry->agbno,
2462 		  __entry->len,
2463 		  __entry->owner,
2464 		  __entry->offset,
2465 		  __entry->flags)
2466 );
2467 #define DEFINE_RMAP_EVENT(name) \
2468 DEFINE_EVENT(xfs_rmap_class, name, \
2469 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2470 		 xfs_agblock_t agbno, xfs_extlen_t len, bool unwritten, \
2471 		 struct xfs_owner_info *oinfo), \
2472 	TP_ARGS(mp, agno, agbno, len, unwritten, oinfo))
2473 
2474 /* simple AG-based error/%ip tracepoint class */
2475 DECLARE_EVENT_CLASS(xfs_ag_error_class,
2476 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error,
2477 		 unsigned long caller_ip),
2478 	TP_ARGS(mp, agno, error, caller_ip),
2479 	TP_STRUCT__entry(
2480 		__field(dev_t, dev)
2481 		__field(xfs_agnumber_t, agno)
2482 		__field(int, error)
2483 		__field(unsigned long, caller_ip)
2484 	),
2485 	TP_fast_assign(
2486 		__entry->dev = mp->m_super->s_dev;
2487 		__entry->agno = agno;
2488 		__entry->error = error;
2489 		__entry->caller_ip = caller_ip;
2490 	),
2491 	TP_printk("dev %d:%d agno %u error %d caller %pS",
2492 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2493 		  __entry->agno,
2494 		  __entry->error,
2495 		  (char *)__entry->caller_ip)
2496 );
2497 
2498 #define DEFINE_AG_ERROR_EVENT(name) \
2499 DEFINE_EVENT(xfs_ag_error_class, name, \
2500 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error, \
2501 		 unsigned long caller_ip), \
2502 	TP_ARGS(mp, agno, error, caller_ip))
2503 
2504 DEFINE_RMAP_EVENT(xfs_rmap_unmap);
2505 DEFINE_RMAP_EVENT(xfs_rmap_unmap_done);
2506 DEFINE_AG_ERROR_EVENT(xfs_rmap_unmap_error);
2507 DEFINE_RMAP_EVENT(xfs_rmap_map);
2508 DEFINE_RMAP_EVENT(xfs_rmap_map_done);
2509 DEFINE_AG_ERROR_EVENT(xfs_rmap_map_error);
2510 DEFINE_RMAP_EVENT(xfs_rmap_convert);
2511 DEFINE_RMAP_EVENT(xfs_rmap_convert_done);
2512 DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_error);
2513 DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_state);
2514 
2515 DECLARE_EVENT_CLASS(xfs_rmapbt_class,
2516 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2517 		 xfs_agblock_t agbno, xfs_extlen_t len,
2518 		 uint64_t owner, uint64_t offset, unsigned int flags),
2519 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
2520 	TP_STRUCT__entry(
2521 		__field(dev_t, dev)
2522 		__field(xfs_agnumber_t, agno)
2523 		__field(xfs_agblock_t, agbno)
2524 		__field(xfs_extlen_t, len)
2525 		__field(uint64_t, owner)
2526 		__field(uint64_t, offset)
2527 		__field(unsigned int, flags)
2528 	),
2529 	TP_fast_assign(
2530 		__entry->dev = mp->m_super->s_dev;
2531 		__entry->agno = agno;
2532 		__entry->agbno = agbno;
2533 		__entry->len = len;
2534 		__entry->owner = owner;
2535 		__entry->offset = offset;
2536 		__entry->flags = flags;
2537 	),
2538 	TP_printk("dev %d:%d agno %u agbno %u len %u owner %lld offset %llu flags 0x%x",
2539 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2540 		  __entry->agno,
2541 		  __entry->agbno,
2542 		  __entry->len,
2543 		  __entry->owner,
2544 		  __entry->offset,
2545 		  __entry->flags)
2546 );
2547 #define DEFINE_RMAPBT_EVENT(name) \
2548 DEFINE_EVENT(xfs_rmapbt_class, name, \
2549 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2550 		 xfs_agblock_t agbno, xfs_extlen_t len, \
2551 		 uint64_t owner, uint64_t offset, unsigned int flags), \
2552 	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
2553 
2554 #define DEFINE_RMAP_DEFERRED_EVENT DEFINE_MAP_EXTENT_DEFERRED_EVENT
2555 DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_defer);
2556 DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_deferred);
2557 
2558 DEFINE_BUSY_EVENT(xfs_rmapbt_alloc_block);
2559 DEFINE_BUSY_EVENT(xfs_rmapbt_free_block);
2560 DEFINE_RMAPBT_EVENT(xfs_rmap_update);
2561 DEFINE_RMAPBT_EVENT(xfs_rmap_insert);
2562 DEFINE_RMAPBT_EVENT(xfs_rmap_delete);
2563 DEFINE_AG_ERROR_EVENT(xfs_rmap_insert_error);
2564 DEFINE_AG_ERROR_EVENT(xfs_rmap_delete_error);
2565 DEFINE_AG_ERROR_EVENT(xfs_rmap_update_error);
2566 
2567 DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_candidate);
2568 DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_query);
2569 DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_candidate);
2570 DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range);
2571 DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_result);
2572 DEFINE_RMAPBT_EVENT(xfs_rmap_find_right_neighbor_result);
2573 DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_result);
2574 
2575 /* deferred bmbt updates */
2576 #define DEFINE_BMAP_DEFERRED_EVENT	DEFINE_RMAP_DEFERRED_EVENT
2577 DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_defer);
2578 DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_deferred);
2579 
2580 /* per-AG reservation */
2581 DECLARE_EVENT_CLASS(xfs_ag_resv_class,
2582 	TP_PROTO(struct xfs_perag *pag, enum xfs_ag_resv_type resv,
2583 		 xfs_extlen_t len),
2584 	TP_ARGS(pag, resv, len),
2585 	TP_STRUCT__entry(
2586 		__field(dev_t, dev)
2587 		__field(xfs_agnumber_t, agno)
2588 		__field(int, resv)
2589 		__field(xfs_extlen_t, freeblks)
2590 		__field(xfs_extlen_t, flcount)
2591 		__field(xfs_extlen_t, reserved)
2592 		__field(xfs_extlen_t, asked)
2593 		__field(xfs_extlen_t, len)
2594 	),
2595 	TP_fast_assign(
2596 		struct xfs_ag_resv	*r = xfs_perag_resv(pag, resv);
2597 
2598 		__entry->dev = pag->pag_mount->m_super->s_dev;
2599 		__entry->agno = pag->pag_agno;
2600 		__entry->resv = resv;
2601 		__entry->freeblks = pag->pagf_freeblks;
2602 		__entry->flcount = pag->pagf_flcount;
2603 		__entry->reserved = r ? r->ar_reserved : 0;
2604 		__entry->asked = r ? r->ar_asked : 0;
2605 		__entry->len = len;
2606 	),
2607 	TP_printk("dev %d:%d agno %u resv %d freeblks %u flcount %u "
2608 		  "resv %u ask %u len %u",
2609 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2610 		  __entry->agno,
2611 		  __entry->resv,
2612 		  __entry->freeblks,
2613 		  __entry->flcount,
2614 		  __entry->reserved,
2615 		  __entry->asked,
2616 		  __entry->len)
2617 )
2618 #define DEFINE_AG_RESV_EVENT(name) \
2619 DEFINE_EVENT(xfs_ag_resv_class, name, \
2620 	TP_PROTO(struct xfs_perag *pag, enum xfs_ag_resv_type type, \
2621 		 xfs_extlen_t len), \
2622 	TP_ARGS(pag, type, len))
2623 
2624 /* per-AG reservation tracepoints */
2625 DEFINE_AG_RESV_EVENT(xfs_ag_resv_init);
2626 DEFINE_AG_RESV_EVENT(xfs_ag_resv_free);
2627 DEFINE_AG_RESV_EVENT(xfs_ag_resv_alloc_extent);
2628 DEFINE_AG_RESV_EVENT(xfs_ag_resv_free_extent);
2629 DEFINE_AG_RESV_EVENT(xfs_ag_resv_critical);
2630 DEFINE_AG_RESV_EVENT(xfs_ag_resv_needed);
2631 
2632 DEFINE_AG_ERROR_EVENT(xfs_ag_resv_free_error);
2633 DEFINE_AG_ERROR_EVENT(xfs_ag_resv_init_error);
2634 
2635 /* refcount tracepoint classes */
2636 
2637 /* reuse the discard trace class for agbno/aglen-based traces */
2638 #define DEFINE_AG_EXTENT_EVENT(name) DEFINE_DISCARD_EVENT(name)
2639 
2640 /* ag btree lookup tracepoint class */
2641 #define XFS_AG_BTREE_CMP_FORMAT_STR \
2642 	{ XFS_LOOKUP_EQ,	"eq" }, \
2643 	{ XFS_LOOKUP_LE,	"le" }, \
2644 	{ XFS_LOOKUP_GE,	"ge" }
2645 DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class,
2646 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2647 		 xfs_agblock_t agbno, xfs_lookup_t dir),
2648 	TP_ARGS(mp, agno, agbno, dir),
2649 	TP_STRUCT__entry(
2650 		__field(dev_t, dev)
2651 		__field(xfs_agnumber_t, agno)
2652 		__field(xfs_agblock_t, agbno)
2653 		__field(xfs_lookup_t, dir)
2654 	),
2655 	TP_fast_assign(
2656 		__entry->dev = mp->m_super->s_dev;
2657 		__entry->agno = agno;
2658 		__entry->agbno = agbno;
2659 		__entry->dir = dir;
2660 	),
2661 	TP_printk("dev %d:%d agno %u agbno %u cmp %s(%d)",
2662 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2663 		  __entry->agno,
2664 		  __entry->agbno,
2665 		  __print_symbolic(__entry->dir, XFS_AG_BTREE_CMP_FORMAT_STR),
2666 		  __entry->dir)
2667 )
2668 
2669 #define DEFINE_AG_BTREE_LOOKUP_EVENT(name) \
2670 DEFINE_EVENT(xfs_ag_btree_lookup_class, name, \
2671 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2672 		 xfs_agblock_t agbno, xfs_lookup_t dir), \
2673 	TP_ARGS(mp, agno, agbno, dir))
2674 
2675 /* single-rcext tracepoint class */
2676 DECLARE_EVENT_CLASS(xfs_refcount_extent_class,
2677 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2678 		 struct xfs_refcount_irec *irec),
2679 	TP_ARGS(mp, agno, irec),
2680 	TP_STRUCT__entry(
2681 		__field(dev_t, dev)
2682 		__field(xfs_agnumber_t, agno)
2683 		__field(xfs_agblock_t, startblock)
2684 		__field(xfs_extlen_t, blockcount)
2685 		__field(xfs_nlink_t, refcount)
2686 	),
2687 	TP_fast_assign(
2688 		__entry->dev = mp->m_super->s_dev;
2689 		__entry->agno = agno;
2690 		__entry->startblock = irec->rc_startblock;
2691 		__entry->blockcount = irec->rc_blockcount;
2692 		__entry->refcount = irec->rc_refcount;
2693 	),
2694 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u",
2695 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2696 		  __entry->agno,
2697 		  __entry->startblock,
2698 		  __entry->blockcount,
2699 		  __entry->refcount)
2700 )
2701 
2702 #define DEFINE_REFCOUNT_EXTENT_EVENT(name) \
2703 DEFINE_EVENT(xfs_refcount_extent_class, name, \
2704 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2705 		 struct xfs_refcount_irec *irec), \
2706 	TP_ARGS(mp, agno, irec))
2707 
2708 /* single-rcext and an agbno tracepoint class */
2709 DECLARE_EVENT_CLASS(xfs_refcount_extent_at_class,
2710 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2711 		 struct xfs_refcount_irec *irec, xfs_agblock_t agbno),
2712 	TP_ARGS(mp, agno, irec, agbno),
2713 	TP_STRUCT__entry(
2714 		__field(dev_t, dev)
2715 		__field(xfs_agnumber_t, agno)
2716 		__field(xfs_agblock_t, startblock)
2717 		__field(xfs_extlen_t, blockcount)
2718 		__field(xfs_nlink_t, refcount)
2719 		__field(xfs_agblock_t, agbno)
2720 	),
2721 	TP_fast_assign(
2722 		__entry->dev = mp->m_super->s_dev;
2723 		__entry->agno = agno;
2724 		__entry->startblock = irec->rc_startblock;
2725 		__entry->blockcount = irec->rc_blockcount;
2726 		__entry->refcount = irec->rc_refcount;
2727 		__entry->agbno = agbno;
2728 	),
2729 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u @ agbno %u",
2730 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2731 		  __entry->agno,
2732 		  __entry->startblock,
2733 		  __entry->blockcount,
2734 		  __entry->refcount,
2735 		  __entry->agbno)
2736 )
2737 
2738 #define DEFINE_REFCOUNT_EXTENT_AT_EVENT(name) \
2739 DEFINE_EVENT(xfs_refcount_extent_at_class, name, \
2740 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2741 		 struct xfs_refcount_irec *irec, xfs_agblock_t agbno), \
2742 	TP_ARGS(mp, agno, irec, agbno))
2743 
2744 /* double-rcext tracepoint class */
2745 DECLARE_EVENT_CLASS(xfs_refcount_double_extent_class,
2746 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2747 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2),
2748 	TP_ARGS(mp, agno, i1, i2),
2749 	TP_STRUCT__entry(
2750 		__field(dev_t, dev)
2751 		__field(xfs_agnumber_t, agno)
2752 		__field(xfs_agblock_t, i1_startblock)
2753 		__field(xfs_extlen_t, i1_blockcount)
2754 		__field(xfs_nlink_t, i1_refcount)
2755 		__field(xfs_agblock_t, i2_startblock)
2756 		__field(xfs_extlen_t, i2_blockcount)
2757 		__field(xfs_nlink_t, i2_refcount)
2758 	),
2759 	TP_fast_assign(
2760 		__entry->dev = mp->m_super->s_dev;
2761 		__entry->agno = agno;
2762 		__entry->i1_startblock = i1->rc_startblock;
2763 		__entry->i1_blockcount = i1->rc_blockcount;
2764 		__entry->i1_refcount = i1->rc_refcount;
2765 		__entry->i2_startblock = i2->rc_startblock;
2766 		__entry->i2_blockcount = i2->rc_blockcount;
2767 		__entry->i2_refcount = i2->rc_refcount;
2768 	),
2769 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u -- "
2770 		  "agbno %u len %u refcount %u",
2771 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2772 		  __entry->agno,
2773 		  __entry->i1_startblock,
2774 		  __entry->i1_blockcount,
2775 		  __entry->i1_refcount,
2776 		  __entry->i2_startblock,
2777 		  __entry->i2_blockcount,
2778 		  __entry->i2_refcount)
2779 )
2780 
2781 #define DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(name) \
2782 DEFINE_EVENT(xfs_refcount_double_extent_class, name, \
2783 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2784 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2), \
2785 	TP_ARGS(mp, agno, i1, i2))
2786 
2787 /* double-rcext and an agbno tracepoint class */
2788 DECLARE_EVENT_CLASS(xfs_refcount_double_extent_at_class,
2789 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2790 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2,
2791 		 xfs_agblock_t agbno),
2792 	TP_ARGS(mp, agno, i1, i2, agbno),
2793 	TP_STRUCT__entry(
2794 		__field(dev_t, dev)
2795 		__field(xfs_agnumber_t, agno)
2796 		__field(xfs_agblock_t, i1_startblock)
2797 		__field(xfs_extlen_t, i1_blockcount)
2798 		__field(xfs_nlink_t, i1_refcount)
2799 		__field(xfs_agblock_t, i2_startblock)
2800 		__field(xfs_extlen_t, i2_blockcount)
2801 		__field(xfs_nlink_t, i2_refcount)
2802 		__field(xfs_agblock_t, agbno)
2803 	),
2804 	TP_fast_assign(
2805 		__entry->dev = mp->m_super->s_dev;
2806 		__entry->agno = agno;
2807 		__entry->i1_startblock = i1->rc_startblock;
2808 		__entry->i1_blockcount = i1->rc_blockcount;
2809 		__entry->i1_refcount = i1->rc_refcount;
2810 		__entry->i2_startblock = i2->rc_startblock;
2811 		__entry->i2_blockcount = i2->rc_blockcount;
2812 		__entry->i2_refcount = i2->rc_refcount;
2813 		__entry->agbno = agbno;
2814 	),
2815 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u -- "
2816 		  "agbno %u len %u refcount %u @ agbno %u",
2817 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2818 		  __entry->agno,
2819 		  __entry->i1_startblock,
2820 		  __entry->i1_blockcount,
2821 		  __entry->i1_refcount,
2822 		  __entry->i2_startblock,
2823 		  __entry->i2_blockcount,
2824 		  __entry->i2_refcount,
2825 		  __entry->agbno)
2826 )
2827 
2828 #define DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(name) \
2829 DEFINE_EVENT(xfs_refcount_double_extent_at_class, name, \
2830 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2831 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \
2832 		 xfs_agblock_t agbno), \
2833 	TP_ARGS(mp, agno, i1, i2, agbno))
2834 
2835 /* triple-rcext tracepoint class */
2836 DECLARE_EVENT_CLASS(xfs_refcount_triple_extent_class,
2837 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2838 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2,
2839 		 struct xfs_refcount_irec *i3),
2840 	TP_ARGS(mp, agno, i1, i2, i3),
2841 	TP_STRUCT__entry(
2842 		__field(dev_t, dev)
2843 		__field(xfs_agnumber_t, agno)
2844 		__field(xfs_agblock_t, i1_startblock)
2845 		__field(xfs_extlen_t, i1_blockcount)
2846 		__field(xfs_nlink_t, i1_refcount)
2847 		__field(xfs_agblock_t, i2_startblock)
2848 		__field(xfs_extlen_t, i2_blockcount)
2849 		__field(xfs_nlink_t, i2_refcount)
2850 		__field(xfs_agblock_t, i3_startblock)
2851 		__field(xfs_extlen_t, i3_blockcount)
2852 		__field(xfs_nlink_t, i3_refcount)
2853 	),
2854 	TP_fast_assign(
2855 		__entry->dev = mp->m_super->s_dev;
2856 		__entry->agno = agno;
2857 		__entry->i1_startblock = i1->rc_startblock;
2858 		__entry->i1_blockcount = i1->rc_blockcount;
2859 		__entry->i1_refcount = i1->rc_refcount;
2860 		__entry->i2_startblock = i2->rc_startblock;
2861 		__entry->i2_blockcount = i2->rc_blockcount;
2862 		__entry->i2_refcount = i2->rc_refcount;
2863 		__entry->i3_startblock = i3->rc_startblock;
2864 		__entry->i3_blockcount = i3->rc_blockcount;
2865 		__entry->i3_refcount = i3->rc_refcount;
2866 	),
2867 	TP_printk("dev %d:%d agno %u agbno %u len %u refcount %u -- "
2868 		  "agbno %u len %u refcount %u -- "
2869 		  "agbno %u len %u refcount %u",
2870 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2871 		  __entry->agno,
2872 		  __entry->i1_startblock,
2873 		  __entry->i1_blockcount,
2874 		  __entry->i1_refcount,
2875 		  __entry->i2_startblock,
2876 		  __entry->i2_blockcount,
2877 		  __entry->i2_refcount,
2878 		  __entry->i3_startblock,
2879 		  __entry->i3_blockcount,
2880 		  __entry->i3_refcount)
2881 );
2882 
2883 #define DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(name) \
2884 DEFINE_EVENT(xfs_refcount_triple_extent_class, name, \
2885 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2886 		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \
2887 		 struct xfs_refcount_irec *i3), \
2888 	TP_ARGS(mp, agno, i1, i2, i3))
2889 
2890 /* refcount btree tracepoints */
2891 DEFINE_BUSY_EVENT(xfs_refcountbt_alloc_block);
2892 DEFINE_BUSY_EVENT(xfs_refcountbt_free_block);
2893 DEFINE_AG_BTREE_LOOKUP_EVENT(xfs_refcount_lookup);
2894 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get);
2895 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_update);
2896 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_insert);
2897 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_delete);
2898 DEFINE_AG_ERROR_EVENT(xfs_refcount_insert_error);
2899 DEFINE_AG_ERROR_EVENT(xfs_refcount_delete_error);
2900 DEFINE_AG_ERROR_EVENT(xfs_refcount_update_error);
2901 
2902 /* refcount adjustment tracepoints */
2903 DEFINE_AG_EXTENT_EVENT(xfs_refcount_increase);
2904 DEFINE_AG_EXTENT_EVENT(xfs_refcount_decrease);
2905 DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_increase);
2906 DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_decrease);
2907 DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(xfs_refcount_merge_center_extents);
2908 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_modify_extent);
2909 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_recover_extent);
2910 DEFINE_REFCOUNT_EXTENT_AT_EVENT(xfs_refcount_split_extent);
2911 DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_left_extent);
2912 DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_right_extent);
2913 DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_left_extent);
2914 DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_right_extent);
2915 DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_error);
2916 DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_cow_error);
2917 DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_center_extents_error);
2918 DEFINE_AG_ERROR_EVENT(xfs_refcount_modify_extent_error);
2919 DEFINE_AG_ERROR_EVENT(xfs_refcount_split_extent_error);
2920 DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_left_extent_error);
2921 DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_right_extent_error);
2922 DEFINE_AG_ERROR_EVENT(xfs_refcount_find_left_extent_error);
2923 DEFINE_AG_ERROR_EVENT(xfs_refcount_find_right_extent_error);
2924 
2925 /* reflink helpers */
2926 DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared);
2927 DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared_result);
2928 DEFINE_AG_ERROR_EVENT(xfs_refcount_find_shared_error);
2929 #define DEFINE_REFCOUNT_DEFERRED_EVENT DEFINE_PHYS_EXTENT_DEFERRED_EVENT
2930 DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_defer);
2931 DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_deferred);
2932 
2933 TRACE_EVENT(xfs_refcount_finish_one_leftover,
2934 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2935 		 int type, xfs_agblock_t agbno, xfs_extlen_t len,
2936 		 xfs_agblock_t new_agbno, xfs_extlen_t new_len),
2937 	TP_ARGS(mp, agno, type, agbno, len, new_agbno, new_len),
2938 	TP_STRUCT__entry(
2939 		__field(dev_t, dev)
2940 		__field(xfs_agnumber_t, agno)
2941 		__field(int, type)
2942 		__field(xfs_agblock_t, agbno)
2943 		__field(xfs_extlen_t, len)
2944 		__field(xfs_agblock_t, new_agbno)
2945 		__field(xfs_extlen_t, new_len)
2946 	),
2947 	TP_fast_assign(
2948 		__entry->dev = mp->m_super->s_dev;
2949 		__entry->agno = agno;
2950 		__entry->type = type;
2951 		__entry->agbno = agbno;
2952 		__entry->len = len;
2953 		__entry->new_agbno = new_agbno;
2954 		__entry->new_len = new_len;
2955 	),
2956 	TP_printk("dev %d:%d type %d agno %u agbno %u len %u new_agbno %u new_len %u",
2957 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2958 		  __entry->type,
2959 		  __entry->agno,
2960 		  __entry->agbno,
2961 		  __entry->len,
2962 		  __entry->new_agbno,
2963 		  __entry->new_len)
2964 );
2965 
2966 /* simple inode-based error/%ip tracepoint class */
2967 DECLARE_EVENT_CLASS(xfs_inode_error_class,
2968 	TP_PROTO(struct xfs_inode *ip, int error, unsigned long caller_ip),
2969 	TP_ARGS(ip, error, caller_ip),
2970 	TP_STRUCT__entry(
2971 		__field(dev_t, dev)
2972 		__field(xfs_ino_t, ino)
2973 		__field(int, error)
2974 		__field(unsigned long, caller_ip)
2975 	),
2976 	TP_fast_assign(
2977 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
2978 		__entry->ino = ip->i_ino;
2979 		__entry->error = error;
2980 		__entry->caller_ip = caller_ip;
2981 	),
2982 	TP_printk("dev %d:%d ino %llx error %d caller %pS",
2983 		  MAJOR(__entry->dev), MINOR(__entry->dev),
2984 		  __entry->ino,
2985 		  __entry->error,
2986 		  (char *)__entry->caller_ip)
2987 );
2988 
2989 #define DEFINE_INODE_ERROR_EVENT(name) \
2990 DEFINE_EVENT(xfs_inode_error_class, name, \
2991 	TP_PROTO(struct xfs_inode *ip, int error, \
2992 		 unsigned long caller_ip), \
2993 	TP_ARGS(ip, error, caller_ip))
2994 
2995 /* reflink tracepoint classes */
2996 
2997 /* two-file io tracepoint class */
2998 DECLARE_EVENT_CLASS(xfs_double_io_class,
2999 	TP_PROTO(struct xfs_inode *src, xfs_off_t soffset, xfs_off_t len,
3000 		 struct xfs_inode *dest, xfs_off_t doffset),
3001 	TP_ARGS(src, soffset, len, dest, doffset),
3002 	TP_STRUCT__entry(
3003 		__field(dev_t, dev)
3004 		__field(xfs_ino_t, src_ino)
3005 		__field(loff_t, src_isize)
3006 		__field(loff_t, src_disize)
3007 		__field(loff_t, src_offset)
3008 		__field(size_t, len)
3009 		__field(xfs_ino_t, dest_ino)
3010 		__field(loff_t, dest_isize)
3011 		__field(loff_t, dest_disize)
3012 		__field(loff_t, dest_offset)
3013 	),
3014 	TP_fast_assign(
3015 		__entry->dev = VFS_I(src)->i_sb->s_dev;
3016 		__entry->src_ino = src->i_ino;
3017 		__entry->src_isize = VFS_I(src)->i_size;
3018 		__entry->src_disize = src->i_d.di_size;
3019 		__entry->src_offset = soffset;
3020 		__entry->len = len;
3021 		__entry->dest_ino = dest->i_ino;
3022 		__entry->dest_isize = VFS_I(dest)->i_size;
3023 		__entry->dest_disize = dest->i_d.di_size;
3024 		__entry->dest_offset = doffset;
3025 	),
3026 	TP_printk("dev %d:%d count %zd "
3027 		  "ino 0x%llx isize 0x%llx disize 0x%llx offset 0x%llx -> "
3028 		  "ino 0x%llx isize 0x%llx disize 0x%llx offset 0x%llx",
3029 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3030 		  __entry->len,
3031 		  __entry->src_ino,
3032 		  __entry->src_isize,
3033 		  __entry->src_disize,
3034 		  __entry->src_offset,
3035 		  __entry->dest_ino,
3036 		  __entry->dest_isize,
3037 		  __entry->dest_disize,
3038 		  __entry->dest_offset)
3039 )
3040 
3041 #define DEFINE_DOUBLE_IO_EVENT(name)	\
3042 DEFINE_EVENT(xfs_double_io_class, name,	\
3043 	TP_PROTO(struct xfs_inode *src, xfs_off_t soffset, xfs_off_t len, \
3044 		 struct xfs_inode *dest, xfs_off_t doffset), \
3045 	TP_ARGS(src, soffset, len, dest, doffset))
3046 
3047 /* inode/irec events */
3048 DECLARE_EVENT_CLASS(xfs_inode_irec_class,
3049 	TP_PROTO(struct xfs_inode *ip, struct xfs_bmbt_irec *irec),
3050 	TP_ARGS(ip, irec),
3051 	TP_STRUCT__entry(
3052 		__field(dev_t, dev)
3053 		__field(xfs_ino_t, ino)
3054 		__field(xfs_fileoff_t, lblk)
3055 		__field(xfs_extlen_t, len)
3056 		__field(xfs_fsblock_t, pblk)
3057 		__field(int, state)
3058 	),
3059 	TP_fast_assign(
3060 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3061 		__entry->ino = ip->i_ino;
3062 		__entry->lblk = irec->br_startoff;
3063 		__entry->len = irec->br_blockcount;
3064 		__entry->pblk = irec->br_startblock;
3065 		__entry->state = irec->br_state;
3066 	),
3067 	TP_printk("dev %d:%d ino 0x%llx lblk 0x%llx len 0x%x pblk %llu st %d",
3068 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3069 		  __entry->ino,
3070 		  __entry->lblk,
3071 		  __entry->len,
3072 		  __entry->pblk,
3073 		  __entry->state)
3074 );
3075 #define DEFINE_INODE_IREC_EVENT(name) \
3076 DEFINE_EVENT(xfs_inode_irec_class, name, \
3077 	TP_PROTO(struct xfs_inode *ip, struct xfs_bmbt_irec *irec), \
3078 	TP_ARGS(ip, irec))
3079 
3080 /* refcount/reflink tracepoint definitions */
3081 
3082 /* reflink tracepoints */
3083 DEFINE_INODE_EVENT(xfs_reflink_set_inode_flag);
3084 DEFINE_INODE_EVENT(xfs_reflink_unset_inode_flag);
3085 DEFINE_ITRUNC_EVENT(xfs_reflink_update_inode_size);
3086 DEFINE_IOMAP_EVENT(xfs_reflink_remap_imap);
3087 TRACE_EVENT(xfs_reflink_remap_blocks_loop,
3088 	TP_PROTO(struct xfs_inode *src, xfs_fileoff_t soffset,
3089 		 xfs_filblks_t len, struct xfs_inode *dest,
3090 		 xfs_fileoff_t doffset),
3091 	TP_ARGS(src, soffset, len, dest, doffset),
3092 	TP_STRUCT__entry(
3093 		__field(dev_t, dev)
3094 		__field(xfs_ino_t, src_ino)
3095 		__field(xfs_fileoff_t, src_lblk)
3096 		__field(xfs_filblks_t, len)
3097 		__field(xfs_ino_t, dest_ino)
3098 		__field(xfs_fileoff_t, dest_lblk)
3099 	),
3100 	TP_fast_assign(
3101 		__entry->dev = VFS_I(src)->i_sb->s_dev;
3102 		__entry->src_ino = src->i_ino;
3103 		__entry->src_lblk = soffset;
3104 		__entry->len = len;
3105 		__entry->dest_ino = dest->i_ino;
3106 		__entry->dest_lblk = doffset;
3107 	),
3108 	TP_printk("dev %d:%d len 0x%llx "
3109 		  "ino 0x%llx offset 0x%llx blocks -> "
3110 		  "ino 0x%llx offset 0x%llx blocks",
3111 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3112 		  __entry->len,
3113 		  __entry->src_ino,
3114 		  __entry->src_lblk,
3115 		  __entry->dest_ino,
3116 		  __entry->dest_lblk)
3117 );
3118 TRACE_EVENT(xfs_reflink_punch_range,
3119 	TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t lblk,
3120 		 xfs_extlen_t len),
3121 	TP_ARGS(ip, lblk, len),
3122 	TP_STRUCT__entry(
3123 		__field(dev_t, dev)
3124 		__field(xfs_ino_t, ino)
3125 		__field(xfs_fileoff_t, lblk)
3126 		__field(xfs_extlen_t, len)
3127 	),
3128 	TP_fast_assign(
3129 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3130 		__entry->ino = ip->i_ino;
3131 		__entry->lblk = lblk;
3132 		__entry->len = len;
3133 	),
3134 	TP_printk("dev %d:%d ino 0x%llx lblk 0x%llx len 0x%x",
3135 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3136 		  __entry->ino,
3137 		  __entry->lblk,
3138 		  __entry->len)
3139 );
3140 TRACE_EVENT(xfs_reflink_remap,
3141 	TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t lblk,
3142 		 xfs_extlen_t len, xfs_fsblock_t new_pblk),
3143 	TP_ARGS(ip, lblk, len, new_pblk),
3144 	TP_STRUCT__entry(
3145 		__field(dev_t, dev)
3146 		__field(xfs_ino_t, ino)
3147 		__field(xfs_fileoff_t, lblk)
3148 		__field(xfs_extlen_t, len)
3149 		__field(xfs_fsblock_t, new_pblk)
3150 	),
3151 	TP_fast_assign(
3152 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3153 		__entry->ino = ip->i_ino;
3154 		__entry->lblk = lblk;
3155 		__entry->len = len;
3156 		__entry->new_pblk = new_pblk;
3157 	),
3158 	TP_printk("dev %d:%d ino 0x%llx lblk 0x%llx len 0x%x new_pblk %llu",
3159 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3160 		  __entry->ino,
3161 		  __entry->lblk,
3162 		  __entry->len,
3163 		  __entry->new_pblk)
3164 );
3165 DEFINE_DOUBLE_IO_EVENT(xfs_reflink_remap_range);
3166 DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_range_error);
3167 DEFINE_INODE_ERROR_EVENT(xfs_reflink_set_inode_flag_error);
3168 DEFINE_INODE_ERROR_EVENT(xfs_reflink_update_inode_size_error);
3169 DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_blocks_error);
3170 DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_extent_error);
3171 
3172 /* dedupe tracepoints */
3173 DEFINE_DOUBLE_IO_EVENT(xfs_reflink_compare_extents);
3174 DEFINE_INODE_ERROR_EVENT(xfs_reflink_compare_extents_error);
3175 
3176 /* ioctl tracepoints */
3177 TRACE_EVENT(xfs_ioctl_clone,
3178 	TP_PROTO(struct inode *src, struct inode *dest),
3179 	TP_ARGS(src, dest),
3180 	TP_STRUCT__entry(
3181 		__field(dev_t, dev)
3182 		__field(unsigned long, src_ino)
3183 		__field(loff_t, src_isize)
3184 		__field(unsigned long, dest_ino)
3185 		__field(loff_t, dest_isize)
3186 	),
3187 	TP_fast_assign(
3188 		__entry->dev = src->i_sb->s_dev;
3189 		__entry->src_ino = src->i_ino;
3190 		__entry->src_isize = i_size_read(src);
3191 		__entry->dest_ino = dest->i_ino;
3192 		__entry->dest_isize = i_size_read(dest);
3193 	),
3194 	TP_printk("dev %d:%d "
3195 		  "ino 0x%lx isize 0x%llx -> "
3196 		  "ino 0x%lx isize 0x%llx",
3197 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3198 		  __entry->src_ino,
3199 		  __entry->src_isize,
3200 		  __entry->dest_ino,
3201 		  __entry->dest_isize)
3202 );
3203 
3204 /* unshare tracepoints */
3205 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_unshare);
3206 DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);
3207 
3208 /* copy on write */
3209 DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_around_shared);
3210 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_alloc);
3211 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found);
3212 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
3213 DEFINE_INODE_IREC_EVENT(xfs_reflink_convert_cow);
3214 
3215 DEFINE_RW_EVENT(xfs_reflink_reserve_cow);
3216 
3217 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_bounce_dio_write);
3218 DEFINE_IOMAP_EVENT(xfs_reflink_find_cow_mapping);
3219 DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_irec);
3220 
3221 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_cancel_cow_range);
3222 DEFINE_SIMPLE_IO_EVENT(xfs_reflink_end_cow);
3223 DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap);
3224 
3225 DEFINE_INODE_ERROR_EVENT(xfs_reflink_cancel_cow_range_error);
3226 DEFINE_INODE_ERROR_EVENT(xfs_reflink_end_cow_error);
3227 
3228 
3229 DEFINE_INODE_IREC_EVENT(xfs_reflink_cancel_cow);
3230 
3231 /* rmap swapext tracepoints */
3232 DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap);
3233 DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap_piece);
3234 DEFINE_INODE_ERROR_EVENT(xfs_swap_extent_rmap_error);
3235 
3236 /* fsmap traces */
3237 DECLARE_EVENT_CLASS(xfs_fsmap_class,
3238 	TP_PROTO(struct xfs_mount *mp, u32 keydev, xfs_agnumber_t agno,
3239 		 struct xfs_rmap_irec *rmap),
3240 	TP_ARGS(mp, keydev, agno, rmap),
3241 	TP_STRUCT__entry(
3242 		__field(dev_t, dev)
3243 		__field(dev_t, keydev)
3244 		__field(xfs_agnumber_t, agno)
3245 		__field(xfs_fsblock_t, bno)
3246 		__field(xfs_filblks_t, len)
3247 		__field(uint64_t, owner)
3248 		__field(uint64_t, offset)
3249 		__field(unsigned int, flags)
3250 	),
3251 	TP_fast_assign(
3252 		__entry->dev = mp->m_super->s_dev;
3253 		__entry->keydev = new_decode_dev(keydev);
3254 		__entry->agno = agno;
3255 		__entry->bno = rmap->rm_startblock;
3256 		__entry->len = rmap->rm_blockcount;
3257 		__entry->owner = rmap->rm_owner;
3258 		__entry->offset = rmap->rm_offset;
3259 		__entry->flags = rmap->rm_flags;
3260 	),
3261 	TP_printk("dev %d:%d keydev %d:%d agno %u bno %llu len %llu owner %lld offset %llu flags 0x%x",
3262 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3263 		  MAJOR(__entry->keydev), MINOR(__entry->keydev),
3264 		  __entry->agno,
3265 		  __entry->bno,
3266 		  __entry->len,
3267 		  __entry->owner,
3268 		  __entry->offset,
3269 		  __entry->flags)
3270 )
3271 #define DEFINE_FSMAP_EVENT(name) \
3272 DEFINE_EVENT(xfs_fsmap_class, name, \
3273 	TP_PROTO(struct xfs_mount *mp, u32 keydev, xfs_agnumber_t agno, \
3274 		 struct xfs_rmap_irec *rmap), \
3275 	TP_ARGS(mp, keydev, agno, rmap))
3276 DEFINE_FSMAP_EVENT(xfs_fsmap_low_key);
3277 DEFINE_FSMAP_EVENT(xfs_fsmap_high_key);
3278 DEFINE_FSMAP_EVENT(xfs_fsmap_mapping);
3279 
3280 DECLARE_EVENT_CLASS(xfs_getfsmap_class,
3281 	TP_PROTO(struct xfs_mount *mp, struct xfs_fsmap *fsmap),
3282 	TP_ARGS(mp, fsmap),
3283 	TP_STRUCT__entry(
3284 		__field(dev_t, dev)
3285 		__field(dev_t, keydev)
3286 		__field(xfs_daddr_t, block)
3287 		__field(xfs_daddr_t, len)
3288 		__field(uint64_t, owner)
3289 		__field(uint64_t, offset)
3290 		__field(uint64_t, flags)
3291 	),
3292 	TP_fast_assign(
3293 		__entry->dev = mp->m_super->s_dev;
3294 		__entry->keydev = new_decode_dev(fsmap->fmr_device);
3295 		__entry->block = fsmap->fmr_physical;
3296 		__entry->len = fsmap->fmr_length;
3297 		__entry->owner = fsmap->fmr_owner;
3298 		__entry->offset = fsmap->fmr_offset;
3299 		__entry->flags = fsmap->fmr_flags;
3300 	),
3301 	TP_printk("dev %d:%d keydev %d:%d block %llu len %llu owner %lld offset %llu flags 0x%llx",
3302 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3303 		  MAJOR(__entry->keydev), MINOR(__entry->keydev),
3304 		  __entry->block,
3305 		  __entry->len,
3306 		  __entry->owner,
3307 		  __entry->offset,
3308 		  __entry->flags)
3309 )
3310 #define DEFINE_GETFSMAP_EVENT(name) \
3311 DEFINE_EVENT(xfs_getfsmap_class, name, \
3312 	TP_PROTO(struct xfs_mount *mp, struct xfs_fsmap *fsmap), \
3313 	TP_ARGS(mp, fsmap))
3314 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_low_key);
3315 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_high_key);
3316 DEFINE_GETFSMAP_EVENT(xfs_getfsmap_mapping);
3317 
3318 TRACE_EVENT(xfs_trans_resv_calc,
3319 	TP_PROTO(struct xfs_mount *mp, unsigned int type,
3320 		 struct xfs_trans_res *res),
3321 	TP_ARGS(mp, type, res),
3322 	TP_STRUCT__entry(
3323 		__field(dev_t, dev)
3324 		__field(int, type)
3325 		__field(uint, logres)
3326 		__field(int, logcount)
3327 		__field(int, logflags)
3328 	),
3329 	TP_fast_assign(
3330 		__entry->dev = mp->m_super->s_dev;
3331 		__entry->type = type;
3332 		__entry->logres = res->tr_logres;
3333 		__entry->logcount = res->tr_logcount;
3334 		__entry->logflags = res->tr_logflags;
3335 	),
3336 	TP_printk("dev %d:%d type %d logres %u logcount %d flags 0x%x",
3337 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3338 		  __entry->type,
3339 		  __entry->logres,
3340 		  __entry->logcount,
3341 		  __entry->logflags)
3342 );
3343 
3344 DECLARE_EVENT_CLASS(xfs_trans_class,
3345 	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
3346 	TP_ARGS(tp, caller_ip),
3347 	TP_STRUCT__entry(
3348 		__field(dev_t, dev)
3349 		__field(uint32_t, tid)
3350 		__field(uint32_t, flags)
3351 		__field(unsigned long, caller_ip)
3352 	),
3353 	TP_fast_assign(
3354 		__entry->dev = tp->t_mountp->m_super->s_dev;
3355 		__entry->tid = 0;
3356 		if (tp->t_ticket)
3357 			__entry->tid = tp->t_ticket->t_tid;
3358 		__entry->flags = tp->t_flags;
3359 		__entry->caller_ip = caller_ip;
3360 	),
3361 	TP_printk("dev %d:%d trans %x flags 0x%x caller %pS",
3362 		  MAJOR(__entry->dev), MINOR(__entry->dev),
3363 		  __entry->tid,
3364 		  __entry->flags,
3365 		  (char *)__entry->caller_ip)
3366 )
3367 
3368 #define DEFINE_TRANS_EVENT(name) \
3369 DEFINE_EVENT(xfs_trans_class, name, \
3370 	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip), \
3371 	TP_ARGS(tp, caller_ip))
3372 DEFINE_TRANS_EVENT(xfs_trans_alloc);
3373 DEFINE_TRANS_EVENT(xfs_trans_cancel);
3374 DEFINE_TRANS_EVENT(xfs_trans_commit);
3375 DEFINE_TRANS_EVENT(xfs_trans_dup);
3376 DEFINE_TRANS_EVENT(xfs_trans_free);
3377 DEFINE_TRANS_EVENT(xfs_trans_roll);
3378 DEFINE_TRANS_EVENT(xfs_trans_add_item);
3379 DEFINE_TRANS_EVENT(xfs_trans_free_items);
3380 
3381 #endif /* _TRACE_XFS_H */
3382 
3383 #undef TRACE_INCLUDE_PATH
3384 #define TRACE_INCLUDE_PATH .
3385 #define TRACE_INCLUDE_FILE xfs_trace
3386 #include <trace/define_trace.h>
3387