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