xfs_trace.h revision f7b08163
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		  "offset %lld block %lld count %lld 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 bno 0x%llx nblks 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(size_t, buffer_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->buffer_length = BBTOB(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 bno 0x%llx len 0x%zx 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->buffer_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(size_t, buffer_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->buffer_length = BBTOB(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 bno 0x%llx len 0x%zx 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->buffer_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(size_t, 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 = BBTOB(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 bno 0x%llx len 0x%zx 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 size 0x%llx offset 0x%llx count 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 size 0x%llx offset 0x%llx count %zd "
1443		  "fork %s startoff 0x%llx startblock %lld blockcount 0x%llx",
1444		  MAJOR(__entry->dev), MINOR(__entry->dev),
1445		  __entry->ino,
1446		  __entry->size,
1447		  __entry->offset,
1448		  __entry->count,
1449		  __entry->whichfork == XFS_COW_FORK ? "cow" : "data",
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		  "offset 0x%llx count %zd",
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 size 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 size 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 bno, xfs_filblks_t len,
1562		 int flags, unsigned long caller_ip),
1563	TP_ARGS(ip, bno, 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, bno)
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->bno = bno;
1578		__entry->len = len;
1579		__entry->caller_ip = caller_ip;
1580		__entry->flags = flags;
1581	),
1582	TP_printk("dev %d:%d ino 0x%llx size 0x%llx bno 0x%llx len 0x%llx"
1583		  "flags %s caller %pS",
1584		  MAJOR(__entry->dev), MINOR(__entry->dev),
1585		  __entry->ino,
1586		  __entry->size,
1587		  __entry->bno,
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 len %u",
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 len %u found_agbno 0x%x tlen %u",
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 len %u 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 len 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, fork offset %d",
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 blkno 0x%llx, len %u, 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, blkno 0x%llx, len %d, 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 count %u isize %u length %u "
2373		  "gen %u", MAJOR(__entry->dev), MINOR(__entry->dev),
2374		  __entry->agno, __entry->agbno, __entry->count, __entry->isize,
2375		  __entry->length, __entry->gen)
2376)
2377#define DEFINE_LOG_RECOVER_ICREATE_ITEM(name) \
2378DEFINE_EVENT(xfs_log_recover_icreate_item_class, name, \
2379	TP_PROTO(struct xlog *log, struct xfs_icreate_log *in_f), \
2380	TP_ARGS(log, in_f))
2381
2382DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_cancel);
2383DEFINE_LOG_RECOVER_ICREATE_ITEM(xfs_log_recover_icreate_recover);
2384
2385DECLARE_EVENT_CLASS(xfs_discard_class,
2386	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2387		 xfs_agblock_t agbno, xfs_extlen_t len),
2388	TP_ARGS(mp, agno, agbno, len),
2389	TP_STRUCT__entry(
2390		__field(dev_t, dev)
2391		__field(xfs_agnumber_t, agno)
2392		__field(xfs_agblock_t, agbno)
2393		__field(xfs_extlen_t, len)
2394	),
2395	TP_fast_assign(
2396		__entry->dev = mp->m_super->s_dev;
2397		__entry->agno = agno;
2398		__entry->agbno = agbno;
2399		__entry->len = len;
2400	),
2401	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u",
2402		  MAJOR(__entry->dev), MINOR(__entry->dev),
2403		  __entry->agno,
2404		  __entry->agbno,
2405		  __entry->len)
2406)
2407
2408#define DEFINE_DISCARD_EVENT(name) \
2409DEFINE_EVENT(xfs_discard_class, name, \
2410	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2411		 xfs_agblock_t agbno, xfs_extlen_t len), \
2412	TP_ARGS(mp, agno, agbno, len))
2413DEFINE_DISCARD_EVENT(xfs_discard_extent);
2414DEFINE_DISCARD_EVENT(xfs_discard_toosmall);
2415DEFINE_DISCARD_EVENT(xfs_discard_exclude);
2416DEFINE_DISCARD_EVENT(xfs_discard_busy);
2417
2418/* btree cursor events */
2419TRACE_DEFINE_ENUM(XFS_BTNUM_BNOi);
2420TRACE_DEFINE_ENUM(XFS_BTNUM_CNTi);
2421TRACE_DEFINE_ENUM(XFS_BTNUM_BMAPi);
2422TRACE_DEFINE_ENUM(XFS_BTNUM_INOi);
2423TRACE_DEFINE_ENUM(XFS_BTNUM_FINOi);
2424TRACE_DEFINE_ENUM(XFS_BTNUM_RMAPi);
2425TRACE_DEFINE_ENUM(XFS_BTNUM_REFCi);
2426
2427DECLARE_EVENT_CLASS(xfs_btree_cur_class,
2428	TP_PROTO(struct xfs_btree_cur *cur, int level, struct xfs_buf *bp),
2429	TP_ARGS(cur, level, bp),
2430	TP_STRUCT__entry(
2431		__field(dev_t, dev)
2432		__field(xfs_btnum_t, btnum)
2433		__field(int, level)
2434		__field(int, nlevels)
2435		__field(int, ptr)
2436		__field(xfs_daddr_t, daddr)
2437	),
2438	TP_fast_assign(
2439		__entry->dev = cur->bc_mp->m_super->s_dev;
2440		__entry->btnum = cur->bc_btnum;
2441		__entry->level = level;
2442		__entry->nlevels = cur->bc_nlevels;
2443		__entry->ptr = cur->bc_ptrs[level];
2444		__entry->daddr = bp ? bp->b_bn : -1;
2445	),
2446	TP_printk("dev %d:%d btree %s level %d/%d ptr %d daddr 0x%llx",
2447		  MAJOR(__entry->dev), MINOR(__entry->dev),
2448		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
2449		  __entry->level,
2450		  __entry->nlevels,
2451		  __entry->ptr,
2452		  (unsigned long long)__entry->daddr)
2453)
2454
2455#define DEFINE_BTREE_CUR_EVENT(name) \
2456DEFINE_EVENT(xfs_btree_cur_class, name, \
2457	TP_PROTO(struct xfs_btree_cur *cur, int level, struct xfs_buf *bp), \
2458	TP_ARGS(cur, level, bp))
2459DEFINE_BTREE_CUR_EVENT(xfs_btree_updkeys);
2460DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range);
2461
2462/* deferred ops */
2463struct xfs_defer_pending;
2464
2465DECLARE_EVENT_CLASS(xfs_defer_class,
2466	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
2467	TP_ARGS(tp, caller_ip),
2468	TP_STRUCT__entry(
2469		__field(dev_t, dev)
2470		__field(struct xfs_trans *, tp)
2471		__field(char, committed)
2472		__field(unsigned long, caller_ip)
2473	),
2474	TP_fast_assign(
2475		__entry->dev = tp->t_mountp->m_super->s_dev;
2476		__entry->tp = tp;
2477		__entry->caller_ip = caller_ip;
2478	),
2479	TP_printk("dev %d:%d tp %p caller %pS",
2480		  MAJOR(__entry->dev), MINOR(__entry->dev),
2481		  __entry->tp,
2482		  (char *)__entry->caller_ip)
2483)
2484#define DEFINE_DEFER_EVENT(name) \
2485DEFINE_EVENT(xfs_defer_class, name, \
2486	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip), \
2487	TP_ARGS(tp, caller_ip))
2488
2489DECLARE_EVENT_CLASS(xfs_defer_error_class,
2490	TP_PROTO(struct xfs_trans *tp, int error),
2491	TP_ARGS(tp, error),
2492	TP_STRUCT__entry(
2493		__field(dev_t, dev)
2494		__field(struct xfs_trans *, tp)
2495		__field(char, committed)
2496		__field(int, error)
2497	),
2498	TP_fast_assign(
2499		__entry->dev = tp->t_mountp->m_super->s_dev;
2500		__entry->tp = tp;
2501		__entry->error = error;
2502	),
2503	TP_printk("dev %d:%d tp %p err %d",
2504		  MAJOR(__entry->dev), MINOR(__entry->dev),
2505		  __entry->tp,
2506		  __entry->error)
2507)
2508#define DEFINE_DEFER_ERROR_EVENT(name) \
2509DEFINE_EVENT(xfs_defer_error_class, name, \
2510	TP_PROTO(struct xfs_trans *tp, int error), \
2511	TP_ARGS(tp, error))
2512
2513DECLARE_EVENT_CLASS(xfs_defer_pending_class,
2514	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp),
2515	TP_ARGS(mp, dfp),
2516	TP_STRUCT__entry(
2517		__field(dev_t, dev)
2518		__field(int, type)
2519		__field(void *, intent)
2520		__field(char, committed)
2521		__field(int, nr)
2522	),
2523	TP_fast_assign(
2524		__entry->dev = mp ? mp->m_super->s_dev : 0;
2525		__entry->type = dfp->dfp_type;
2526		__entry->intent = dfp->dfp_intent;
2527		__entry->committed = dfp->dfp_done != NULL;
2528		__entry->nr = dfp->dfp_count;
2529	),
2530	TP_printk("dev %d:%d optype %d intent %p committed %d nr %d",
2531		  MAJOR(__entry->dev), MINOR(__entry->dev),
2532		  __entry->type,
2533		  __entry->intent,
2534		  __entry->committed,
2535		  __entry->nr)
2536)
2537#define DEFINE_DEFER_PENDING_EVENT(name) \
2538DEFINE_EVENT(xfs_defer_pending_class, name, \
2539	TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp), \
2540	TP_ARGS(mp, dfp))
2541
2542DECLARE_EVENT_CLASS(xfs_phys_extent_deferred_class,
2543	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2544		 int type, xfs_agblock_t agbno, xfs_extlen_t len),
2545	TP_ARGS(mp, agno, type, agbno, len),
2546	TP_STRUCT__entry(
2547		__field(dev_t, dev)
2548		__field(xfs_agnumber_t, agno)
2549		__field(int, type)
2550		__field(xfs_agblock_t, agbno)
2551		__field(xfs_extlen_t, len)
2552	),
2553	TP_fast_assign(
2554		__entry->dev = mp->m_super->s_dev;
2555		__entry->agno = agno;
2556		__entry->type = type;
2557		__entry->agbno = agbno;
2558		__entry->len = len;
2559	),
2560	TP_printk("dev %d:%d op %d agno 0x%x agbno 0x%x len %u",
2561		  MAJOR(__entry->dev), MINOR(__entry->dev),
2562		  __entry->type,
2563		  __entry->agno,
2564		  __entry->agbno,
2565		  __entry->len)
2566);
2567#define DEFINE_PHYS_EXTENT_DEFERRED_EVENT(name) \
2568DEFINE_EVENT(xfs_phys_extent_deferred_class, name, \
2569	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2570		 int type, \
2571		 xfs_agblock_t bno, \
2572		 xfs_extlen_t len), \
2573	TP_ARGS(mp, agno, type, bno, len))
2574
2575DECLARE_EVENT_CLASS(xfs_map_extent_deferred_class,
2576	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2577		 int op,
2578		 xfs_agblock_t agbno,
2579		 xfs_ino_t ino,
2580		 int whichfork,
2581		 xfs_fileoff_t offset,
2582		 xfs_filblks_t len,
2583		 xfs_exntst_t state),
2584	TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state),
2585	TP_STRUCT__entry(
2586		__field(dev_t, dev)
2587		__field(xfs_agnumber_t, agno)
2588		__field(xfs_ino_t, ino)
2589		__field(xfs_agblock_t, agbno)
2590		__field(int, whichfork)
2591		__field(xfs_fileoff_t, l_loff)
2592		__field(xfs_filblks_t, l_len)
2593		__field(xfs_exntst_t, l_state)
2594		__field(int, op)
2595	),
2596	TP_fast_assign(
2597		__entry->dev = mp->m_super->s_dev;
2598		__entry->agno = agno;
2599		__entry->ino = ino;
2600		__entry->agbno = agbno;
2601		__entry->whichfork = whichfork;
2602		__entry->l_loff = offset;
2603		__entry->l_len = len;
2604		__entry->l_state = state;
2605		__entry->op = op;
2606	),
2607	TP_printk("dev %d:%d op %d agno 0x%x agbno 0x%x owner %lld %s offset %llu len %llu state %d",
2608		  MAJOR(__entry->dev), MINOR(__entry->dev),
2609		  __entry->op,
2610		  __entry->agno,
2611		  __entry->agbno,
2612		  __entry->ino,
2613		  __entry->whichfork == XFS_ATTR_FORK ? "attr" : "data",
2614		  __entry->l_loff,
2615		  __entry->l_len,
2616		  __entry->l_state)
2617);
2618#define DEFINE_MAP_EXTENT_DEFERRED_EVENT(name) \
2619DEFINE_EVENT(xfs_map_extent_deferred_class, name, \
2620	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2621		 int op, \
2622		 xfs_agblock_t agbno, \
2623		 xfs_ino_t ino, \
2624		 int whichfork, \
2625		 xfs_fileoff_t offset, \
2626		 xfs_filblks_t len, \
2627		 xfs_exntst_t state), \
2628	TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state))
2629
2630DEFINE_DEFER_EVENT(xfs_defer_cancel);
2631DEFINE_DEFER_EVENT(xfs_defer_trans_roll);
2632DEFINE_DEFER_EVENT(xfs_defer_trans_abort);
2633DEFINE_DEFER_EVENT(xfs_defer_finish);
2634DEFINE_DEFER_EVENT(xfs_defer_finish_done);
2635
2636DEFINE_DEFER_ERROR_EVENT(xfs_defer_trans_roll_error);
2637DEFINE_DEFER_ERROR_EVENT(xfs_defer_finish_error);
2638
2639DEFINE_DEFER_PENDING_EVENT(xfs_defer_create_intent);
2640DEFINE_DEFER_PENDING_EVENT(xfs_defer_cancel_list);
2641DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_finish);
2642DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_abort);
2643DEFINE_DEFER_PENDING_EVENT(xfs_defer_relog_intent);
2644
2645#define DEFINE_BMAP_FREE_DEFERRED_EVENT DEFINE_PHYS_EXTENT_DEFERRED_EVENT
2646DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_bmap_free_defer);
2647DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_bmap_free_deferred);
2648DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_agfl_free_defer);
2649DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_agfl_free_deferred);
2650
2651/* rmap tracepoints */
2652DECLARE_EVENT_CLASS(xfs_rmap_class,
2653	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2654		 xfs_agblock_t agbno, xfs_extlen_t len, bool unwritten,
2655		 const struct xfs_owner_info *oinfo),
2656	TP_ARGS(mp, agno, agbno, len, unwritten, oinfo),
2657	TP_STRUCT__entry(
2658		__field(dev_t, dev)
2659		__field(xfs_agnumber_t, agno)
2660		__field(xfs_agblock_t, agbno)
2661		__field(xfs_extlen_t, len)
2662		__field(uint64_t, owner)
2663		__field(uint64_t, offset)
2664		__field(unsigned long, flags)
2665	),
2666	TP_fast_assign(
2667		__entry->dev = mp->m_super->s_dev;
2668		__entry->agno = agno;
2669		__entry->agbno = agbno;
2670		__entry->len = len;
2671		__entry->owner = oinfo->oi_owner;
2672		__entry->offset = oinfo->oi_offset;
2673		__entry->flags = oinfo->oi_flags;
2674		if (unwritten)
2675			__entry->flags |= XFS_RMAP_UNWRITTEN;
2676	),
2677	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u owner %lld offset %llu flags 0x%lx",
2678		  MAJOR(__entry->dev), MINOR(__entry->dev),
2679		  __entry->agno,
2680		  __entry->agbno,
2681		  __entry->len,
2682		  __entry->owner,
2683		  __entry->offset,
2684		  __entry->flags)
2685);
2686#define DEFINE_RMAP_EVENT(name) \
2687DEFINE_EVENT(xfs_rmap_class, name, \
2688	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2689		 xfs_agblock_t agbno, xfs_extlen_t len, bool unwritten, \
2690		 const struct xfs_owner_info *oinfo), \
2691	TP_ARGS(mp, agno, agbno, len, unwritten, oinfo))
2692
2693/* simple AG-based error/%ip tracepoint class */
2694DECLARE_EVENT_CLASS(xfs_ag_error_class,
2695	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error,
2696		 unsigned long caller_ip),
2697	TP_ARGS(mp, agno, error, caller_ip),
2698	TP_STRUCT__entry(
2699		__field(dev_t, dev)
2700		__field(xfs_agnumber_t, agno)
2701		__field(int, error)
2702		__field(unsigned long, caller_ip)
2703	),
2704	TP_fast_assign(
2705		__entry->dev = mp->m_super->s_dev;
2706		__entry->agno = agno;
2707		__entry->error = error;
2708		__entry->caller_ip = caller_ip;
2709	),
2710	TP_printk("dev %d:%d agno 0x%x error %d caller %pS",
2711		  MAJOR(__entry->dev), MINOR(__entry->dev),
2712		  __entry->agno,
2713		  __entry->error,
2714		  (char *)__entry->caller_ip)
2715);
2716
2717#define DEFINE_AG_ERROR_EVENT(name) \
2718DEFINE_EVENT(xfs_ag_error_class, name, \
2719	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int error, \
2720		 unsigned long caller_ip), \
2721	TP_ARGS(mp, agno, error, caller_ip))
2722
2723DEFINE_RMAP_EVENT(xfs_rmap_unmap);
2724DEFINE_RMAP_EVENT(xfs_rmap_unmap_done);
2725DEFINE_AG_ERROR_EVENT(xfs_rmap_unmap_error);
2726DEFINE_RMAP_EVENT(xfs_rmap_map);
2727DEFINE_RMAP_EVENT(xfs_rmap_map_done);
2728DEFINE_AG_ERROR_EVENT(xfs_rmap_map_error);
2729DEFINE_RMAP_EVENT(xfs_rmap_convert);
2730DEFINE_RMAP_EVENT(xfs_rmap_convert_done);
2731DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_error);
2732DEFINE_AG_ERROR_EVENT(xfs_rmap_convert_state);
2733
2734DECLARE_EVENT_CLASS(xfs_rmapbt_class,
2735	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2736		 xfs_agblock_t agbno, xfs_extlen_t len,
2737		 uint64_t owner, uint64_t offset, unsigned int flags),
2738	TP_ARGS(mp, agno, agbno, len, owner, offset, flags),
2739	TP_STRUCT__entry(
2740		__field(dev_t, dev)
2741		__field(xfs_agnumber_t, agno)
2742		__field(xfs_agblock_t, agbno)
2743		__field(xfs_extlen_t, len)
2744		__field(uint64_t, owner)
2745		__field(uint64_t, offset)
2746		__field(unsigned int, flags)
2747	),
2748	TP_fast_assign(
2749		__entry->dev = mp->m_super->s_dev;
2750		__entry->agno = agno;
2751		__entry->agbno = agbno;
2752		__entry->len = len;
2753		__entry->owner = owner;
2754		__entry->offset = offset;
2755		__entry->flags = flags;
2756	),
2757	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u owner %lld offset %llu flags 0x%x",
2758		  MAJOR(__entry->dev), MINOR(__entry->dev),
2759		  __entry->agno,
2760		  __entry->agbno,
2761		  __entry->len,
2762		  __entry->owner,
2763		  __entry->offset,
2764		  __entry->flags)
2765);
2766#define DEFINE_RMAPBT_EVENT(name) \
2767DEFINE_EVENT(xfs_rmapbt_class, name, \
2768	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2769		 xfs_agblock_t agbno, xfs_extlen_t len, \
2770		 uint64_t owner, uint64_t offset, unsigned int flags), \
2771	TP_ARGS(mp, agno, agbno, len, owner, offset, flags))
2772
2773#define DEFINE_RMAP_DEFERRED_EVENT DEFINE_MAP_EXTENT_DEFERRED_EVENT
2774DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_defer);
2775DEFINE_RMAP_DEFERRED_EVENT(xfs_rmap_deferred);
2776
2777DEFINE_BUSY_EVENT(xfs_rmapbt_alloc_block);
2778DEFINE_BUSY_EVENT(xfs_rmapbt_free_block);
2779DEFINE_RMAPBT_EVENT(xfs_rmap_update);
2780DEFINE_RMAPBT_EVENT(xfs_rmap_insert);
2781DEFINE_RMAPBT_EVENT(xfs_rmap_delete);
2782DEFINE_AG_ERROR_EVENT(xfs_rmap_insert_error);
2783DEFINE_AG_ERROR_EVENT(xfs_rmap_delete_error);
2784DEFINE_AG_ERROR_EVENT(xfs_rmap_update_error);
2785
2786DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_candidate);
2787DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_query);
2788DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_candidate);
2789DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range);
2790DEFINE_RMAPBT_EVENT(xfs_rmap_lookup_le_range_result);
2791DEFINE_RMAPBT_EVENT(xfs_rmap_find_right_neighbor_result);
2792DEFINE_RMAPBT_EVENT(xfs_rmap_find_left_neighbor_result);
2793
2794/* deferred bmbt updates */
2795#define DEFINE_BMAP_DEFERRED_EVENT	DEFINE_RMAP_DEFERRED_EVENT
2796DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_defer);
2797DEFINE_BMAP_DEFERRED_EVENT(xfs_bmap_deferred);
2798
2799/* per-AG reservation */
2800DECLARE_EVENT_CLASS(xfs_ag_resv_class,
2801	TP_PROTO(struct xfs_perag *pag, enum xfs_ag_resv_type resv,
2802		 xfs_extlen_t len),
2803	TP_ARGS(pag, resv, len),
2804	TP_STRUCT__entry(
2805		__field(dev_t, dev)
2806		__field(xfs_agnumber_t, agno)
2807		__field(int, resv)
2808		__field(xfs_extlen_t, freeblks)
2809		__field(xfs_extlen_t, flcount)
2810		__field(xfs_extlen_t, reserved)
2811		__field(xfs_extlen_t, asked)
2812		__field(xfs_extlen_t, len)
2813	),
2814	TP_fast_assign(
2815		struct xfs_ag_resv	*r = xfs_perag_resv(pag, resv);
2816
2817		__entry->dev = pag->pag_mount->m_super->s_dev;
2818		__entry->agno = pag->pag_agno;
2819		__entry->resv = resv;
2820		__entry->freeblks = pag->pagf_freeblks;
2821		__entry->flcount = pag->pagf_flcount;
2822		__entry->reserved = r ? r->ar_reserved : 0;
2823		__entry->asked = r ? r->ar_asked : 0;
2824		__entry->len = len;
2825	),
2826	TP_printk("dev %d:%d agno 0x%x resv %d freeblks %u flcount %u "
2827		  "resv %u ask %u len %u",
2828		  MAJOR(__entry->dev), MINOR(__entry->dev),
2829		  __entry->agno,
2830		  __entry->resv,
2831		  __entry->freeblks,
2832		  __entry->flcount,
2833		  __entry->reserved,
2834		  __entry->asked,
2835		  __entry->len)
2836)
2837#define DEFINE_AG_RESV_EVENT(name) \
2838DEFINE_EVENT(xfs_ag_resv_class, name, \
2839	TP_PROTO(struct xfs_perag *pag, enum xfs_ag_resv_type type, \
2840		 xfs_extlen_t len), \
2841	TP_ARGS(pag, type, len))
2842
2843/* per-AG reservation tracepoints */
2844DEFINE_AG_RESV_EVENT(xfs_ag_resv_init);
2845DEFINE_AG_RESV_EVENT(xfs_ag_resv_free);
2846DEFINE_AG_RESV_EVENT(xfs_ag_resv_alloc_extent);
2847DEFINE_AG_RESV_EVENT(xfs_ag_resv_free_extent);
2848DEFINE_AG_RESV_EVENT(xfs_ag_resv_critical);
2849DEFINE_AG_RESV_EVENT(xfs_ag_resv_needed);
2850
2851DEFINE_AG_ERROR_EVENT(xfs_ag_resv_free_error);
2852DEFINE_AG_ERROR_EVENT(xfs_ag_resv_init_error);
2853
2854/* refcount tracepoint classes */
2855
2856/* reuse the discard trace class for agbno/aglen-based traces */
2857#define DEFINE_AG_EXTENT_EVENT(name) DEFINE_DISCARD_EVENT(name)
2858
2859/* ag btree lookup tracepoint class */
2860TRACE_DEFINE_ENUM(XFS_LOOKUP_EQi);
2861TRACE_DEFINE_ENUM(XFS_LOOKUP_LEi);
2862TRACE_DEFINE_ENUM(XFS_LOOKUP_GEi);
2863DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class,
2864	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2865		 xfs_agblock_t agbno, xfs_lookup_t dir),
2866	TP_ARGS(mp, agno, agbno, dir),
2867	TP_STRUCT__entry(
2868		__field(dev_t, dev)
2869		__field(xfs_agnumber_t, agno)
2870		__field(xfs_agblock_t, agbno)
2871		__field(xfs_lookup_t, dir)
2872	),
2873	TP_fast_assign(
2874		__entry->dev = mp->m_super->s_dev;
2875		__entry->agno = agno;
2876		__entry->agbno = agbno;
2877		__entry->dir = dir;
2878	),
2879	TP_printk("dev %d:%d agno 0x%x agbno 0x%x cmp %s(%d)",
2880		  MAJOR(__entry->dev), MINOR(__entry->dev),
2881		  __entry->agno,
2882		  __entry->agbno,
2883		  __print_symbolic(__entry->dir, XFS_AG_BTREE_CMP_FORMAT_STR),
2884		  __entry->dir)
2885)
2886
2887#define DEFINE_AG_BTREE_LOOKUP_EVENT(name) \
2888DEFINE_EVENT(xfs_ag_btree_lookup_class, name, \
2889	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2890		 xfs_agblock_t agbno, xfs_lookup_t dir), \
2891	TP_ARGS(mp, agno, agbno, dir))
2892
2893/* single-rcext tracepoint class */
2894DECLARE_EVENT_CLASS(xfs_refcount_extent_class,
2895	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2896		 struct xfs_refcount_irec *irec),
2897	TP_ARGS(mp, agno, irec),
2898	TP_STRUCT__entry(
2899		__field(dev_t, dev)
2900		__field(xfs_agnumber_t, agno)
2901		__field(xfs_agblock_t, startblock)
2902		__field(xfs_extlen_t, blockcount)
2903		__field(xfs_nlink_t, refcount)
2904	),
2905	TP_fast_assign(
2906		__entry->dev = mp->m_super->s_dev;
2907		__entry->agno = agno;
2908		__entry->startblock = irec->rc_startblock;
2909		__entry->blockcount = irec->rc_blockcount;
2910		__entry->refcount = irec->rc_refcount;
2911	),
2912	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u refcount %u",
2913		  MAJOR(__entry->dev), MINOR(__entry->dev),
2914		  __entry->agno,
2915		  __entry->startblock,
2916		  __entry->blockcount,
2917		  __entry->refcount)
2918)
2919
2920#define DEFINE_REFCOUNT_EXTENT_EVENT(name) \
2921DEFINE_EVENT(xfs_refcount_extent_class, name, \
2922	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2923		 struct xfs_refcount_irec *irec), \
2924	TP_ARGS(mp, agno, irec))
2925
2926/* single-rcext and an agbno tracepoint class */
2927DECLARE_EVENT_CLASS(xfs_refcount_extent_at_class,
2928	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2929		 struct xfs_refcount_irec *irec, xfs_agblock_t agbno),
2930	TP_ARGS(mp, agno, irec, agbno),
2931	TP_STRUCT__entry(
2932		__field(dev_t, dev)
2933		__field(xfs_agnumber_t, agno)
2934		__field(xfs_agblock_t, startblock)
2935		__field(xfs_extlen_t, blockcount)
2936		__field(xfs_nlink_t, refcount)
2937		__field(xfs_agblock_t, agbno)
2938	),
2939	TP_fast_assign(
2940		__entry->dev = mp->m_super->s_dev;
2941		__entry->agno = agno;
2942		__entry->startblock = irec->rc_startblock;
2943		__entry->blockcount = irec->rc_blockcount;
2944		__entry->refcount = irec->rc_refcount;
2945		__entry->agbno = agbno;
2946	),
2947	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u refcount %u @ agbno 0x%x",
2948		  MAJOR(__entry->dev), MINOR(__entry->dev),
2949		  __entry->agno,
2950		  __entry->startblock,
2951		  __entry->blockcount,
2952		  __entry->refcount,
2953		  __entry->agbno)
2954)
2955
2956#define DEFINE_REFCOUNT_EXTENT_AT_EVENT(name) \
2957DEFINE_EVENT(xfs_refcount_extent_at_class, name, \
2958	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
2959		 struct xfs_refcount_irec *irec, xfs_agblock_t agbno), \
2960	TP_ARGS(mp, agno, irec, agbno))
2961
2962/* double-rcext tracepoint class */
2963DECLARE_EVENT_CLASS(xfs_refcount_double_extent_class,
2964	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
2965		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2),
2966	TP_ARGS(mp, agno, i1, i2),
2967	TP_STRUCT__entry(
2968		__field(dev_t, dev)
2969		__field(xfs_agnumber_t, agno)
2970		__field(xfs_agblock_t, i1_startblock)
2971		__field(xfs_extlen_t, i1_blockcount)
2972		__field(xfs_nlink_t, i1_refcount)
2973		__field(xfs_agblock_t, i2_startblock)
2974		__field(xfs_extlen_t, i2_blockcount)
2975		__field(xfs_nlink_t, i2_refcount)
2976	),
2977	TP_fast_assign(
2978		__entry->dev = mp->m_super->s_dev;
2979		__entry->agno = agno;
2980		__entry->i1_startblock = i1->rc_startblock;
2981		__entry->i1_blockcount = i1->rc_blockcount;
2982		__entry->i1_refcount = i1->rc_refcount;
2983		__entry->i2_startblock = i2->rc_startblock;
2984		__entry->i2_blockcount = i2->rc_blockcount;
2985		__entry->i2_refcount = i2->rc_refcount;
2986	),
2987	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u refcount %u -- "
2988		  "agbno 0x%x len %u refcount %u",
2989		  MAJOR(__entry->dev), MINOR(__entry->dev),
2990		  __entry->agno,
2991		  __entry->i1_startblock,
2992		  __entry->i1_blockcount,
2993		  __entry->i1_refcount,
2994		  __entry->i2_startblock,
2995		  __entry->i2_blockcount,
2996		  __entry->i2_refcount)
2997)
2998
2999#define DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(name) \
3000DEFINE_EVENT(xfs_refcount_double_extent_class, name, \
3001	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3002		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2), \
3003	TP_ARGS(mp, agno, i1, i2))
3004
3005/* double-rcext and an agbno tracepoint class */
3006DECLARE_EVENT_CLASS(xfs_refcount_double_extent_at_class,
3007	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3008		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2,
3009		 xfs_agblock_t agbno),
3010	TP_ARGS(mp, agno, i1, i2, agbno),
3011	TP_STRUCT__entry(
3012		__field(dev_t, dev)
3013		__field(xfs_agnumber_t, agno)
3014		__field(xfs_agblock_t, i1_startblock)
3015		__field(xfs_extlen_t, i1_blockcount)
3016		__field(xfs_nlink_t, i1_refcount)
3017		__field(xfs_agblock_t, i2_startblock)
3018		__field(xfs_extlen_t, i2_blockcount)
3019		__field(xfs_nlink_t, i2_refcount)
3020		__field(xfs_agblock_t, agbno)
3021	),
3022	TP_fast_assign(
3023		__entry->dev = mp->m_super->s_dev;
3024		__entry->agno = agno;
3025		__entry->i1_startblock = i1->rc_startblock;
3026		__entry->i1_blockcount = i1->rc_blockcount;
3027		__entry->i1_refcount = i1->rc_refcount;
3028		__entry->i2_startblock = i2->rc_startblock;
3029		__entry->i2_blockcount = i2->rc_blockcount;
3030		__entry->i2_refcount = i2->rc_refcount;
3031		__entry->agbno = agbno;
3032	),
3033	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u refcount %u -- "
3034		  "agbno 0x%x len %u refcount %u @ agbno 0x%x",
3035		  MAJOR(__entry->dev), MINOR(__entry->dev),
3036		  __entry->agno,
3037		  __entry->i1_startblock,
3038		  __entry->i1_blockcount,
3039		  __entry->i1_refcount,
3040		  __entry->i2_startblock,
3041		  __entry->i2_blockcount,
3042		  __entry->i2_refcount,
3043		  __entry->agbno)
3044)
3045
3046#define DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(name) \
3047DEFINE_EVENT(xfs_refcount_double_extent_at_class, name, \
3048	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3049		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \
3050		 xfs_agblock_t agbno), \
3051	TP_ARGS(mp, agno, i1, i2, agbno))
3052
3053/* triple-rcext tracepoint class */
3054DECLARE_EVENT_CLASS(xfs_refcount_triple_extent_class,
3055	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3056		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2,
3057		 struct xfs_refcount_irec *i3),
3058	TP_ARGS(mp, agno, i1, i2, i3),
3059	TP_STRUCT__entry(
3060		__field(dev_t, dev)
3061		__field(xfs_agnumber_t, agno)
3062		__field(xfs_agblock_t, i1_startblock)
3063		__field(xfs_extlen_t, i1_blockcount)
3064		__field(xfs_nlink_t, i1_refcount)
3065		__field(xfs_agblock_t, i2_startblock)
3066		__field(xfs_extlen_t, i2_blockcount)
3067		__field(xfs_nlink_t, i2_refcount)
3068		__field(xfs_agblock_t, i3_startblock)
3069		__field(xfs_extlen_t, i3_blockcount)
3070		__field(xfs_nlink_t, i3_refcount)
3071	),
3072	TP_fast_assign(
3073		__entry->dev = mp->m_super->s_dev;
3074		__entry->agno = agno;
3075		__entry->i1_startblock = i1->rc_startblock;
3076		__entry->i1_blockcount = i1->rc_blockcount;
3077		__entry->i1_refcount = i1->rc_refcount;
3078		__entry->i2_startblock = i2->rc_startblock;
3079		__entry->i2_blockcount = i2->rc_blockcount;
3080		__entry->i2_refcount = i2->rc_refcount;
3081		__entry->i3_startblock = i3->rc_startblock;
3082		__entry->i3_blockcount = i3->rc_blockcount;
3083		__entry->i3_refcount = i3->rc_refcount;
3084	),
3085	TP_printk("dev %d:%d agno 0x%x agbno 0x%x len %u refcount %u -- "
3086		  "agbno 0x%x len %u refcount %u -- "
3087		  "agbno 0x%x len %u refcount %u",
3088		  MAJOR(__entry->dev), MINOR(__entry->dev),
3089		  __entry->agno,
3090		  __entry->i1_startblock,
3091		  __entry->i1_blockcount,
3092		  __entry->i1_refcount,
3093		  __entry->i2_startblock,
3094		  __entry->i2_blockcount,
3095		  __entry->i2_refcount,
3096		  __entry->i3_startblock,
3097		  __entry->i3_blockcount,
3098		  __entry->i3_refcount)
3099);
3100
3101#define DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(name) \
3102DEFINE_EVENT(xfs_refcount_triple_extent_class, name, \
3103	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3104		 struct xfs_refcount_irec *i1, struct xfs_refcount_irec *i2, \
3105		 struct xfs_refcount_irec *i3), \
3106	TP_ARGS(mp, agno, i1, i2, i3))
3107
3108/* refcount btree tracepoints */
3109DEFINE_BUSY_EVENT(xfs_refcountbt_alloc_block);
3110DEFINE_BUSY_EVENT(xfs_refcountbt_free_block);
3111DEFINE_AG_BTREE_LOOKUP_EVENT(xfs_refcount_lookup);
3112DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get);
3113DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_update);
3114DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_insert);
3115DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_delete);
3116DEFINE_AG_ERROR_EVENT(xfs_refcount_insert_error);
3117DEFINE_AG_ERROR_EVENT(xfs_refcount_delete_error);
3118DEFINE_AG_ERROR_EVENT(xfs_refcount_update_error);
3119
3120/* refcount adjustment tracepoints */
3121DEFINE_AG_EXTENT_EVENT(xfs_refcount_increase);
3122DEFINE_AG_EXTENT_EVENT(xfs_refcount_decrease);
3123DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_increase);
3124DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_decrease);
3125DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(xfs_refcount_merge_center_extents);
3126DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_modify_extent);
3127DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_recover_extent);
3128DEFINE_REFCOUNT_EXTENT_AT_EVENT(xfs_refcount_split_extent);
3129DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_left_extent);
3130DEFINE_REFCOUNT_DOUBLE_EXTENT_EVENT(xfs_refcount_merge_right_extent);
3131DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_left_extent);
3132DEFINE_REFCOUNT_DOUBLE_EXTENT_AT_EVENT(xfs_refcount_find_right_extent);
3133DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_error);
3134DEFINE_AG_ERROR_EVENT(xfs_refcount_adjust_cow_error);
3135DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_center_extents_error);
3136DEFINE_AG_ERROR_EVENT(xfs_refcount_modify_extent_error);
3137DEFINE_AG_ERROR_EVENT(xfs_refcount_split_extent_error);
3138DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_left_extent_error);
3139DEFINE_AG_ERROR_EVENT(xfs_refcount_merge_right_extent_error);
3140DEFINE_AG_ERROR_EVENT(xfs_refcount_find_left_extent_error);
3141DEFINE_AG_ERROR_EVENT(xfs_refcount_find_right_extent_error);
3142
3143/* reflink helpers */
3144DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared);
3145DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared_result);
3146DEFINE_AG_ERROR_EVENT(xfs_refcount_find_shared_error);
3147#define DEFINE_REFCOUNT_DEFERRED_EVENT DEFINE_PHYS_EXTENT_DEFERRED_EVENT
3148DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_defer);
3149DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_deferred);
3150
3151TRACE_EVENT(xfs_refcount_finish_one_leftover,
3152	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3153		 int type, xfs_agblock_t agbno, xfs_extlen_t len,
3154		 xfs_agblock_t new_agbno, xfs_extlen_t new_len),
3155	TP_ARGS(mp, agno, type, agbno, len, new_agbno, new_len),
3156	TP_STRUCT__entry(
3157		__field(dev_t, dev)
3158		__field(xfs_agnumber_t, agno)
3159		__field(int, type)
3160		__field(xfs_agblock_t, agbno)
3161		__field(xfs_extlen_t, len)
3162		__field(xfs_agblock_t, new_agbno)
3163		__field(xfs_extlen_t, new_len)
3164	),
3165	TP_fast_assign(
3166		__entry->dev = mp->m_super->s_dev;
3167		__entry->agno = agno;
3168		__entry->type = type;
3169		__entry->agbno = agbno;
3170		__entry->len = len;
3171		__entry->new_agbno = new_agbno;
3172		__entry->new_len = new_len;
3173	),
3174	TP_printk("dev %d:%d type %d agno 0x%x agbno 0x%x len %u new_agbno 0x%x new_len %u",
3175		  MAJOR(__entry->dev), MINOR(__entry->dev),
3176		  __entry->type,
3177		  __entry->agno,
3178		  __entry->agbno,
3179		  __entry->len,
3180		  __entry->new_agbno,
3181		  __entry->new_len)
3182);
3183
3184/* simple inode-based error/%ip tracepoint class */
3185DECLARE_EVENT_CLASS(xfs_inode_error_class,
3186	TP_PROTO(struct xfs_inode *ip, int error, unsigned long caller_ip),
3187	TP_ARGS(ip, error, caller_ip),
3188	TP_STRUCT__entry(
3189		__field(dev_t, dev)
3190		__field(xfs_ino_t, ino)
3191		__field(int, error)
3192		__field(unsigned long, caller_ip)
3193	),
3194	TP_fast_assign(
3195		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3196		__entry->ino = ip->i_ino;
3197		__entry->error = error;
3198		__entry->caller_ip = caller_ip;
3199	),
3200	TP_printk("dev %d:%d ino 0x%llx error %d caller %pS",
3201		  MAJOR(__entry->dev), MINOR(__entry->dev),
3202		  __entry->ino,
3203		  __entry->error,
3204		  (char *)__entry->caller_ip)
3205);
3206
3207#define DEFINE_INODE_ERROR_EVENT(name) \
3208DEFINE_EVENT(xfs_inode_error_class, name, \
3209	TP_PROTO(struct xfs_inode *ip, int error, \
3210		 unsigned long caller_ip), \
3211	TP_ARGS(ip, error, caller_ip))
3212
3213/* reflink tracepoint classes */
3214
3215/* two-file io tracepoint class */
3216DECLARE_EVENT_CLASS(xfs_double_io_class,
3217	TP_PROTO(struct xfs_inode *src, xfs_off_t soffset, xfs_off_t len,
3218		 struct xfs_inode *dest, xfs_off_t doffset),
3219	TP_ARGS(src, soffset, len, dest, doffset),
3220	TP_STRUCT__entry(
3221		__field(dev_t, dev)
3222		__field(xfs_ino_t, src_ino)
3223		__field(loff_t, src_isize)
3224		__field(loff_t, src_disize)
3225		__field(loff_t, src_offset)
3226		__field(size_t, len)
3227		__field(xfs_ino_t, dest_ino)
3228		__field(loff_t, dest_isize)
3229		__field(loff_t, dest_disize)
3230		__field(loff_t, dest_offset)
3231	),
3232	TP_fast_assign(
3233		__entry->dev = VFS_I(src)->i_sb->s_dev;
3234		__entry->src_ino = src->i_ino;
3235		__entry->src_isize = VFS_I(src)->i_size;
3236		__entry->src_disize = src->i_disk_size;
3237		__entry->src_offset = soffset;
3238		__entry->len = len;
3239		__entry->dest_ino = dest->i_ino;
3240		__entry->dest_isize = VFS_I(dest)->i_size;
3241		__entry->dest_disize = dest->i_disk_size;
3242		__entry->dest_offset = doffset;
3243	),
3244	TP_printk("dev %d:%d count %zd "
3245		  "ino 0x%llx isize 0x%llx disize 0x%llx offset 0x%llx -> "
3246		  "ino 0x%llx isize 0x%llx disize 0x%llx offset 0x%llx",
3247		  MAJOR(__entry->dev), MINOR(__entry->dev),
3248		  __entry->len,
3249		  __entry->src_ino,
3250		  __entry->src_isize,
3251		  __entry->src_disize,
3252		  __entry->src_offset,
3253		  __entry->dest_ino,
3254		  __entry->dest_isize,
3255		  __entry->dest_disize,
3256		  __entry->dest_offset)
3257)
3258
3259#define DEFINE_DOUBLE_IO_EVENT(name)	\
3260DEFINE_EVENT(xfs_double_io_class, name,	\
3261	TP_PROTO(struct xfs_inode *src, xfs_off_t soffset, xfs_off_t len, \
3262		 struct xfs_inode *dest, xfs_off_t doffset), \
3263	TP_ARGS(src, soffset, len, dest, doffset))
3264
3265/* inode/irec events */
3266DECLARE_EVENT_CLASS(xfs_inode_irec_class,
3267	TP_PROTO(struct xfs_inode *ip, struct xfs_bmbt_irec *irec),
3268	TP_ARGS(ip, irec),
3269	TP_STRUCT__entry(
3270		__field(dev_t, dev)
3271		__field(xfs_ino_t, ino)
3272		__field(xfs_fileoff_t, lblk)
3273		__field(xfs_extlen_t, len)
3274		__field(xfs_fsblock_t, pblk)
3275		__field(int, state)
3276	),
3277	TP_fast_assign(
3278		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3279		__entry->ino = ip->i_ino;
3280		__entry->lblk = irec->br_startoff;
3281		__entry->len = irec->br_blockcount;
3282		__entry->pblk = irec->br_startblock;
3283		__entry->state = irec->br_state;
3284	),
3285	TP_printk("dev %d:%d ino 0x%llx lblk 0x%llx len 0x%x pblk %llu st %d",
3286		  MAJOR(__entry->dev), MINOR(__entry->dev),
3287		  __entry->ino,
3288		  __entry->lblk,
3289		  __entry->len,
3290		  __entry->pblk,
3291		  __entry->state)
3292);
3293#define DEFINE_INODE_IREC_EVENT(name) \
3294DEFINE_EVENT(xfs_inode_irec_class, name, \
3295	TP_PROTO(struct xfs_inode *ip, struct xfs_bmbt_irec *irec), \
3296	TP_ARGS(ip, irec))
3297
3298/* refcount/reflink tracepoint definitions */
3299
3300/* reflink tracepoints */
3301DEFINE_INODE_EVENT(xfs_reflink_set_inode_flag);
3302DEFINE_INODE_EVENT(xfs_reflink_unset_inode_flag);
3303DEFINE_ITRUNC_EVENT(xfs_reflink_update_inode_size);
3304TRACE_EVENT(xfs_reflink_remap_blocks,
3305	TP_PROTO(struct xfs_inode *src, xfs_fileoff_t soffset,
3306		 xfs_filblks_t len, struct xfs_inode *dest,
3307		 xfs_fileoff_t doffset),
3308	TP_ARGS(src, soffset, len, dest, doffset),
3309	TP_STRUCT__entry(
3310		__field(dev_t, dev)
3311		__field(xfs_ino_t, src_ino)
3312		__field(xfs_fileoff_t, src_lblk)
3313		__field(xfs_filblks_t, len)
3314		__field(xfs_ino_t, dest_ino)
3315		__field(xfs_fileoff_t, dest_lblk)
3316	),
3317	TP_fast_assign(
3318		__entry->dev = VFS_I(src)->i_sb->s_dev;
3319		__entry->src_ino = src->i_ino;
3320		__entry->src_lblk = soffset;
3321		__entry->len = len;
3322		__entry->dest_ino = dest->i_ino;
3323		__entry->dest_lblk = doffset;
3324	),
3325	TP_printk("dev %d:%d len 0x%llx "
3326		  "ino 0x%llx offset 0x%llx blocks -> "
3327		  "ino 0x%llx offset 0x%llx blocks",
3328		  MAJOR(__entry->dev), MINOR(__entry->dev),
3329		  __entry->len,
3330		  __entry->src_ino,
3331		  __entry->src_lblk,
3332		  __entry->dest_ino,
3333		  __entry->dest_lblk)
3334);
3335DEFINE_DOUBLE_IO_EVENT(xfs_reflink_remap_range);
3336DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_range_error);
3337DEFINE_INODE_ERROR_EVENT(xfs_reflink_set_inode_flag_error);
3338DEFINE_INODE_ERROR_EVENT(xfs_reflink_update_inode_size_error);
3339DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_blocks_error);
3340DEFINE_INODE_ERROR_EVENT(xfs_reflink_remap_extent_error);
3341DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_src);
3342DEFINE_INODE_IREC_EVENT(xfs_reflink_remap_extent_dest);
3343
3344/* dedupe tracepoints */
3345DEFINE_DOUBLE_IO_EVENT(xfs_reflink_compare_extents);
3346DEFINE_INODE_ERROR_EVENT(xfs_reflink_compare_extents_error);
3347
3348/* ioctl tracepoints */
3349TRACE_EVENT(xfs_ioctl_clone,
3350	TP_PROTO(struct inode *src, struct inode *dest),
3351	TP_ARGS(src, dest),
3352	TP_STRUCT__entry(
3353		__field(dev_t, dev)
3354		__field(unsigned long, src_ino)
3355		__field(loff_t, src_isize)
3356		__field(unsigned long, dest_ino)
3357		__field(loff_t, dest_isize)
3358	),
3359	TP_fast_assign(
3360		__entry->dev = src->i_sb->s_dev;
3361		__entry->src_ino = src->i_ino;
3362		__entry->src_isize = i_size_read(src);
3363		__entry->dest_ino = dest->i_ino;
3364		__entry->dest_isize = i_size_read(dest);
3365	),
3366	TP_printk("dev %d:%d "
3367		  "ino 0x%lx isize 0x%llx -> "
3368		  "ino 0x%lx isize 0x%llx",
3369		  MAJOR(__entry->dev), MINOR(__entry->dev),
3370		  __entry->src_ino,
3371		  __entry->src_isize,
3372		  __entry->dest_ino,
3373		  __entry->dest_isize)
3374);
3375
3376/* unshare tracepoints */
3377DEFINE_SIMPLE_IO_EVENT(xfs_reflink_unshare);
3378DEFINE_INODE_ERROR_EVENT(xfs_reflink_unshare_error);
3379
3380/* copy on write */
3381DEFINE_INODE_IREC_EVENT(xfs_reflink_trim_around_shared);
3382DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_found);
3383DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_enospc);
3384DEFINE_INODE_IREC_EVENT(xfs_reflink_convert_cow);
3385
3386DEFINE_SIMPLE_IO_EVENT(xfs_reflink_cancel_cow_range);
3387DEFINE_SIMPLE_IO_EVENT(xfs_reflink_end_cow);
3388DEFINE_INODE_IREC_EVENT(xfs_reflink_cow_remap);
3389
3390DEFINE_INODE_ERROR_EVENT(xfs_reflink_cancel_cow_range_error);
3391DEFINE_INODE_ERROR_EVENT(xfs_reflink_end_cow_error);
3392
3393
3394DEFINE_INODE_IREC_EVENT(xfs_reflink_cancel_cow);
3395
3396/* rmap swapext tracepoints */
3397DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap);
3398DEFINE_INODE_IREC_EVENT(xfs_swap_extent_rmap_remap_piece);
3399DEFINE_INODE_ERROR_EVENT(xfs_swap_extent_rmap_error);
3400
3401/* fsmap traces */
3402DECLARE_EVENT_CLASS(xfs_fsmap_class,
3403	TP_PROTO(struct xfs_mount *mp, u32 keydev, xfs_agnumber_t agno,
3404		 const struct xfs_rmap_irec *rmap),
3405	TP_ARGS(mp, keydev, agno, rmap),
3406	TP_STRUCT__entry(
3407		__field(dev_t, dev)
3408		__field(dev_t, keydev)
3409		__field(xfs_agnumber_t, agno)
3410		__field(xfs_fsblock_t, bno)
3411		__field(xfs_filblks_t, len)
3412		__field(uint64_t, owner)
3413		__field(uint64_t, offset)
3414		__field(unsigned int, flags)
3415	),
3416	TP_fast_assign(
3417		__entry->dev = mp->m_super->s_dev;
3418		__entry->keydev = new_decode_dev(keydev);
3419		__entry->agno = agno;
3420		__entry->bno = rmap->rm_startblock;
3421		__entry->len = rmap->rm_blockcount;
3422		__entry->owner = rmap->rm_owner;
3423		__entry->offset = rmap->rm_offset;
3424		__entry->flags = rmap->rm_flags;
3425	),
3426	TP_printk("dev %d:%d keydev %d:%d agno 0x%x bno %llu len %llu owner %lld offset %llu flags 0x%x",
3427		  MAJOR(__entry->dev), MINOR(__entry->dev),
3428		  MAJOR(__entry->keydev), MINOR(__entry->keydev),
3429		  __entry->agno,
3430		  __entry->bno,
3431		  __entry->len,
3432		  __entry->owner,
3433		  __entry->offset,
3434		  __entry->flags)
3435)
3436#define DEFINE_FSMAP_EVENT(name) \
3437DEFINE_EVENT(xfs_fsmap_class, name, \
3438	TP_PROTO(struct xfs_mount *mp, u32 keydev, xfs_agnumber_t agno, \
3439		 const struct xfs_rmap_irec *rmap), \
3440	TP_ARGS(mp, keydev, agno, rmap))
3441DEFINE_FSMAP_EVENT(xfs_fsmap_low_key);
3442DEFINE_FSMAP_EVENT(xfs_fsmap_high_key);
3443DEFINE_FSMAP_EVENT(xfs_fsmap_mapping);
3444
3445DECLARE_EVENT_CLASS(xfs_getfsmap_class,
3446	TP_PROTO(struct xfs_mount *mp, struct xfs_fsmap *fsmap),
3447	TP_ARGS(mp, fsmap),
3448	TP_STRUCT__entry(
3449		__field(dev_t, dev)
3450		__field(dev_t, keydev)
3451		__field(xfs_daddr_t, block)
3452		__field(xfs_daddr_t, len)
3453		__field(uint64_t, owner)
3454		__field(uint64_t, offset)
3455		__field(uint64_t, flags)
3456	),
3457	TP_fast_assign(
3458		__entry->dev = mp->m_super->s_dev;
3459		__entry->keydev = new_decode_dev(fsmap->fmr_device);
3460		__entry->block = fsmap->fmr_physical;
3461		__entry->len = fsmap->fmr_length;
3462		__entry->owner = fsmap->fmr_owner;
3463		__entry->offset = fsmap->fmr_offset;
3464		__entry->flags = fsmap->fmr_flags;
3465	),
3466	TP_printk("dev %d:%d keydev %d:%d block %llu len %llu owner %lld offset %llu flags 0x%llx",
3467		  MAJOR(__entry->dev), MINOR(__entry->dev),
3468		  MAJOR(__entry->keydev), MINOR(__entry->keydev),
3469		  __entry->block,
3470		  __entry->len,
3471		  __entry->owner,
3472		  __entry->offset,
3473		  __entry->flags)
3474)
3475#define DEFINE_GETFSMAP_EVENT(name) \
3476DEFINE_EVENT(xfs_getfsmap_class, name, \
3477	TP_PROTO(struct xfs_mount *mp, struct xfs_fsmap *fsmap), \
3478	TP_ARGS(mp, fsmap))
3479DEFINE_GETFSMAP_EVENT(xfs_getfsmap_low_key);
3480DEFINE_GETFSMAP_EVENT(xfs_getfsmap_high_key);
3481DEFINE_GETFSMAP_EVENT(xfs_getfsmap_mapping);
3482
3483TRACE_EVENT(xfs_trans_resv_calc,
3484	TP_PROTO(struct xfs_mount *mp, unsigned int type,
3485		 struct xfs_trans_res *res),
3486	TP_ARGS(mp, type, res),
3487	TP_STRUCT__entry(
3488		__field(dev_t, dev)
3489		__field(int, type)
3490		__field(uint, logres)
3491		__field(int, logcount)
3492		__field(int, logflags)
3493	),
3494	TP_fast_assign(
3495		__entry->dev = mp->m_super->s_dev;
3496		__entry->type = type;
3497		__entry->logres = res->tr_logres;
3498		__entry->logcount = res->tr_logcount;
3499		__entry->logflags = res->tr_logflags;
3500	),
3501	TP_printk("dev %d:%d type %d logres %u logcount %d flags 0x%x",
3502		  MAJOR(__entry->dev), MINOR(__entry->dev),
3503		  __entry->type,
3504		  __entry->logres,
3505		  __entry->logcount,
3506		  __entry->logflags)
3507);
3508
3509DECLARE_EVENT_CLASS(xfs_trans_class,
3510	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
3511	TP_ARGS(tp, caller_ip),
3512	TP_STRUCT__entry(
3513		__field(dev_t, dev)
3514		__field(uint32_t, tid)
3515		__field(uint32_t, flags)
3516		__field(unsigned long, caller_ip)
3517	),
3518	TP_fast_assign(
3519		__entry->dev = tp->t_mountp->m_super->s_dev;
3520		__entry->tid = 0;
3521		if (tp->t_ticket)
3522			__entry->tid = tp->t_ticket->t_tid;
3523		__entry->flags = tp->t_flags;
3524		__entry->caller_ip = caller_ip;
3525	),
3526	TP_printk("dev %d:%d trans %x flags 0x%x caller %pS",
3527		  MAJOR(__entry->dev), MINOR(__entry->dev),
3528		  __entry->tid,
3529		  __entry->flags,
3530		  (char *)__entry->caller_ip)
3531)
3532
3533#define DEFINE_TRANS_EVENT(name) \
3534DEFINE_EVENT(xfs_trans_class, name, \
3535	TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip), \
3536	TP_ARGS(tp, caller_ip))
3537DEFINE_TRANS_EVENT(xfs_trans_alloc);
3538DEFINE_TRANS_EVENT(xfs_trans_cancel);
3539DEFINE_TRANS_EVENT(xfs_trans_commit);
3540DEFINE_TRANS_EVENT(xfs_trans_dup);
3541DEFINE_TRANS_EVENT(xfs_trans_free);
3542DEFINE_TRANS_EVENT(xfs_trans_roll);
3543DEFINE_TRANS_EVENT(xfs_trans_add_item);
3544DEFINE_TRANS_EVENT(xfs_trans_commit_items);
3545DEFINE_TRANS_EVENT(xfs_trans_free_items);
3546
3547TRACE_EVENT(xfs_iunlink_update_bucket,
3548	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int bucket,
3549		 xfs_agino_t old_ptr, xfs_agino_t new_ptr),
3550	TP_ARGS(mp, agno, bucket, old_ptr, new_ptr),
3551	TP_STRUCT__entry(
3552		__field(dev_t, dev)
3553		__field(xfs_agnumber_t, agno)
3554		__field(unsigned int, bucket)
3555		__field(xfs_agino_t, old_ptr)
3556		__field(xfs_agino_t, new_ptr)
3557	),
3558	TP_fast_assign(
3559		__entry->dev = mp->m_super->s_dev;
3560		__entry->agno = agno;
3561		__entry->bucket = bucket;
3562		__entry->old_ptr = old_ptr;
3563		__entry->new_ptr = new_ptr;
3564	),
3565	TP_printk("dev %d:%d agno 0x%x bucket %u old 0x%x new 0x%x",
3566		  MAJOR(__entry->dev), MINOR(__entry->dev),
3567		  __entry->agno,
3568		  __entry->bucket,
3569		  __entry->old_ptr,
3570		  __entry->new_ptr)
3571);
3572
3573TRACE_EVENT(xfs_iunlink_update_dinode,
3574	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t agino,
3575		 xfs_agino_t old_ptr, xfs_agino_t new_ptr),
3576	TP_ARGS(mp, agno, agino, old_ptr, new_ptr),
3577	TP_STRUCT__entry(
3578		__field(dev_t, dev)
3579		__field(xfs_agnumber_t, agno)
3580		__field(xfs_agino_t, agino)
3581		__field(xfs_agino_t, old_ptr)
3582		__field(xfs_agino_t, new_ptr)
3583	),
3584	TP_fast_assign(
3585		__entry->dev = mp->m_super->s_dev;
3586		__entry->agno = agno;
3587		__entry->agino = agino;
3588		__entry->old_ptr = old_ptr;
3589		__entry->new_ptr = new_ptr;
3590	),
3591	TP_printk("dev %d:%d agno 0x%x agino 0x%x old 0x%x new 0x%x",
3592		  MAJOR(__entry->dev), MINOR(__entry->dev),
3593		  __entry->agno,
3594		  __entry->agino,
3595		  __entry->old_ptr,
3596		  __entry->new_ptr)
3597);
3598
3599DECLARE_EVENT_CLASS(xfs_ag_inode_class,
3600	TP_PROTO(struct xfs_inode *ip),
3601	TP_ARGS(ip),
3602	TP_STRUCT__entry(
3603		__field(dev_t, dev)
3604		__field(xfs_agnumber_t, agno)
3605		__field(xfs_agino_t, agino)
3606	),
3607	TP_fast_assign(
3608		__entry->dev = VFS_I(ip)->i_sb->s_dev;
3609		__entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino);
3610		__entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino);
3611	),
3612	TP_printk("dev %d:%d agno 0x%x agino 0x%x",
3613		  MAJOR(__entry->dev), MINOR(__entry->dev),
3614		  __entry->agno, __entry->agino)
3615)
3616
3617#define DEFINE_AGINODE_EVENT(name) \
3618DEFINE_EVENT(xfs_ag_inode_class, name, \
3619	TP_PROTO(struct xfs_inode *ip), \
3620	TP_ARGS(ip))
3621DEFINE_AGINODE_EVENT(xfs_iunlink);
3622DEFINE_AGINODE_EVENT(xfs_iunlink_remove);
3623DEFINE_AG_EVENT(xfs_iunlink_map_prev_fallback);
3624
3625DECLARE_EVENT_CLASS(xfs_fs_corrupt_class,
3626	TP_PROTO(struct xfs_mount *mp, unsigned int flags),
3627	TP_ARGS(mp, flags),
3628	TP_STRUCT__entry(
3629		__field(dev_t, dev)
3630		__field(unsigned int, flags)
3631	),
3632	TP_fast_assign(
3633		__entry->dev = mp->m_super->s_dev;
3634		__entry->flags = flags;
3635	),
3636	TP_printk("dev %d:%d flags 0x%x",
3637		  MAJOR(__entry->dev), MINOR(__entry->dev),
3638		  __entry->flags)
3639);
3640#define DEFINE_FS_CORRUPT_EVENT(name)	\
3641DEFINE_EVENT(xfs_fs_corrupt_class, name,	\
3642	TP_PROTO(struct xfs_mount *mp, unsigned int flags), \
3643	TP_ARGS(mp, flags))
3644DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_sick);
3645DEFINE_FS_CORRUPT_EVENT(xfs_fs_mark_healthy);
3646DEFINE_FS_CORRUPT_EVENT(xfs_fs_unfixed_corruption);
3647DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_sick);
3648DEFINE_FS_CORRUPT_EVENT(xfs_rt_mark_healthy);
3649DEFINE_FS_CORRUPT_EVENT(xfs_rt_unfixed_corruption);
3650
3651DECLARE_EVENT_CLASS(xfs_ag_corrupt_class,
3652	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, unsigned int flags),
3653	TP_ARGS(mp, agno, flags),
3654	TP_STRUCT__entry(
3655		__field(dev_t, dev)
3656		__field(xfs_agnumber_t, agno)
3657		__field(unsigned int, flags)
3658	),
3659	TP_fast_assign(
3660		__entry->dev = mp->m_super->s_dev;
3661		__entry->agno = agno;
3662		__entry->flags = flags;
3663	),
3664	TP_printk("dev %d:%d agno 0x%x flags 0x%x",
3665		  MAJOR(__entry->dev), MINOR(__entry->dev),
3666		  __entry->agno, __entry->flags)
3667);
3668#define DEFINE_AG_CORRUPT_EVENT(name)	\
3669DEFINE_EVENT(xfs_ag_corrupt_class, name,	\
3670	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
3671		 unsigned int flags), \
3672	TP_ARGS(mp, agno, flags))
3673DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_sick);
3674DEFINE_AG_CORRUPT_EVENT(xfs_ag_mark_healthy);
3675DEFINE_AG_CORRUPT_EVENT(xfs_ag_unfixed_corruption);
3676
3677DECLARE_EVENT_CLASS(xfs_inode_corrupt_class,
3678	TP_PROTO(struct xfs_inode *ip, unsigned int flags),
3679	TP_ARGS(ip, flags),
3680	TP_STRUCT__entry(
3681		__field(dev_t, dev)
3682		__field(xfs_ino_t, ino)
3683		__field(unsigned int, flags)
3684	),
3685	TP_fast_assign(
3686		__entry->dev = ip->i_mount->m_super->s_dev;
3687		__entry->ino = ip->i_ino;
3688		__entry->flags = flags;
3689	),
3690	TP_printk("dev %d:%d ino 0x%llx flags 0x%x",
3691		  MAJOR(__entry->dev), MINOR(__entry->dev),
3692		  __entry->ino, __entry->flags)
3693);
3694#define DEFINE_INODE_CORRUPT_EVENT(name)	\
3695DEFINE_EVENT(xfs_inode_corrupt_class, name,	\
3696	TP_PROTO(struct xfs_inode *ip, unsigned int flags), \
3697	TP_ARGS(ip, flags))
3698DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_sick);
3699DEFINE_INODE_CORRUPT_EVENT(xfs_inode_mark_healthy);
3700
3701TRACE_EVENT(xfs_iwalk_ag,
3702	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3703		 xfs_agino_t startino),
3704	TP_ARGS(mp, agno, startino),
3705	TP_STRUCT__entry(
3706		__field(dev_t, dev)
3707		__field(xfs_agnumber_t, agno)
3708		__field(xfs_agino_t, startino)
3709	),
3710	TP_fast_assign(
3711		__entry->dev = mp->m_super->s_dev;
3712		__entry->agno = agno;
3713		__entry->startino = startino;
3714	),
3715	TP_printk("dev %d:%d agno 0x%x startino 0x%x",
3716		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno,
3717		  __entry->startino)
3718)
3719
3720TRACE_EVENT(xfs_iwalk_ag_rec,
3721	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
3722		 struct xfs_inobt_rec_incore *irec),
3723	TP_ARGS(mp, agno, irec),
3724	TP_STRUCT__entry(
3725		__field(dev_t, dev)
3726		__field(xfs_agnumber_t, agno)
3727		__field(xfs_agino_t, startino)
3728		__field(uint64_t, freemask)
3729	),
3730	TP_fast_assign(
3731		__entry->dev = mp->m_super->s_dev;
3732		__entry->agno = agno;
3733		__entry->startino = irec->ir_startino;
3734		__entry->freemask = irec->ir_free;
3735	),
3736	TP_printk("dev %d:%d agno 0x%x startino 0x%x freemask 0x%llx",
3737		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno,
3738		  __entry->startino, __entry->freemask)
3739)
3740
3741TRACE_EVENT(xfs_pwork_init,
3742	TP_PROTO(struct xfs_mount *mp, unsigned int nr_threads, pid_t pid),
3743	TP_ARGS(mp, nr_threads, pid),
3744	TP_STRUCT__entry(
3745		__field(dev_t, dev)
3746		__field(unsigned int, nr_threads)
3747		__field(pid_t, pid)
3748	),
3749	TP_fast_assign(
3750		__entry->dev = mp->m_super->s_dev;
3751		__entry->nr_threads = nr_threads;
3752		__entry->pid = pid;
3753	),
3754	TP_printk("dev %d:%d nr_threads %u pid %u",
3755		  MAJOR(__entry->dev), MINOR(__entry->dev),
3756		  __entry->nr_threads, __entry->pid)
3757)
3758
3759DECLARE_EVENT_CLASS(xfs_kmem_class,
3760	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip),
3761	TP_ARGS(size, flags, caller_ip),
3762	TP_STRUCT__entry(
3763		__field(ssize_t, size)
3764		__field(int, flags)
3765		__field(unsigned long, caller_ip)
3766	),
3767	TP_fast_assign(
3768		__entry->size = size;
3769		__entry->flags = flags;
3770		__entry->caller_ip = caller_ip;
3771	),
3772	TP_printk("size %zd flags 0x%x caller %pS",
3773		  __entry->size,
3774		  __entry->flags,
3775		  (char *)__entry->caller_ip)
3776)
3777
3778#define DEFINE_KMEM_EVENT(name) \
3779DEFINE_EVENT(xfs_kmem_class, name, \
3780	TP_PROTO(ssize_t size, int flags, unsigned long caller_ip), \
3781	TP_ARGS(size, flags, caller_ip))
3782DEFINE_KMEM_EVENT(kmem_alloc);
3783
3784TRACE_EVENT(xfs_check_new_dalign,
3785	TP_PROTO(struct xfs_mount *mp, int new_dalign, xfs_ino_t calc_rootino),
3786	TP_ARGS(mp, new_dalign, calc_rootino),
3787	TP_STRUCT__entry(
3788		__field(dev_t, dev)
3789		__field(int, new_dalign)
3790		__field(xfs_ino_t, sb_rootino)
3791		__field(xfs_ino_t, calc_rootino)
3792	),
3793	TP_fast_assign(
3794		__entry->dev = mp->m_super->s_dev;
3795		__entry->new_dalign = new_dalign;
3796		__entry->sb_rootino = mp->m_sb.sb_rootino;
3797		__entry->calc_rootino = calc_rootino;
3798	),
3799	TP_printk("dev %d:%d new_dalign %d sb_rootino 0x%llx calc_rootino 0x%llx",
3800		  MAJOR(__entry->dev), MINOR(__entry->dev),
3801		  __entry->new_dalign, __entry->sb_rootino,
3802		  __entry->calc_rootino)
3803)
3804
3805TRACE_EVENT(xfs_btree_commit_afakeroot,
3806	TP_PROTO(struct xfs_btree_cur *cur),
3807	TP_ARGS(cur),
3808	TP_STRUCT__entry(
3809		__field(dev_t, dev)
3810		__field(xfs_btnum_t, btnum)
3811		__field(xfs_agnumber_t, agno)
3812		__field(xfs_agblock_t, agbno)
3813		__field(unsigned int, levels)
3814		__field(unsigned int, blocks)
3815	),
3816	TP_fast_assign(
3817		__entry->dev = cur->bc_mp->m_super->s_dev;
3818		__entry->btnum = cur->bc_btnum;
3819		__entry->agno = cur->bc_ag.pag->pag_agno;
3820		__entry->agbno = cur->bc_ag.afake->af_root;
3821		__entry->levels = cur->bc_ag.afake->af_levels;
3822		__entry->blocks = cur->bc_ag.afake->af_blocks;
3823	),
3824	TP_printk("dev %d:%d btree %s agno 0x%x levels %u blocks %u root %u",
3825		  MAJOR(__entry->dev), MINOR(__entry->dev),
3826		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3827		  __entry->agno,
3828		  __entry->levels,
3829		  __entry->blocks,
3830		  __entry->agbno)
3831)
3832
3833TRACE_EVENT(xfs_btree_commit_ifakeroot,
3834	TP_PROTO(struct xfs_btree_cur *cur),
3835	TP_ARGS(cur),
3836	TP_STRUCT__entry(
3837		__field(dev_t, dev)
3838		__field(xfs_btnum_t, btnum)
3839		__field(xfs_agnumber_t, agno)
3840		__field(xfs_agino_t, agino)
3841		__field(unsigned int, levels)
3842		__field(unsigned int, blocks)
3843		__field(int, whichfork)
3844	),
3845	TP_fast_assign(
3846		__entry->dev = cur->bc_mp->m_super->s_dev;
3847		__entry->btnum = cur->bc_btnum;
3848		__entry->agno = XFS_INO_TO_AGNO(cur->bc_mp,
3849					cur->bc_ino.ip->i_ino);
3850		__entry->agino = XFS_INO_TO_AGINO(cur->bc_mp,
3851					cur->bc_ino.ip->i_ino);
3852		__entry->levels = cur->bc_ino.ifake->if_levels;
3853		__entry->blocks = cur->bc_ino.ifake->if_blocks;
3854		__entry->whichfork = cur->bc_ino.whichfork;
3855	),
3856	TP_printk("dev %d:%d btree %s agno 0x%x agino 0x%x whichfork %s levels %u blocks %u",
3857		  MAJOR(__entry->dev), MINOR(__entry->dev),
3858		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3859		  __entry->agno,
3860		  __entry->agino,
3861		  __entry->whichfork == XFS_ATTR_FORK ? "attr" : "data",
3862		  __entry->levels,
3863		  __entry->blocks)
3864)
3865
3866TRACE_EVENT(xfs_btree_bload_level_geometry,
3867	TP_PROTO(struct xfs_btree_cur *cur, unsigned int level,
3868		 uint64_t nr_this_level, unsigned int nr_per_block,
3869		 unsigned int desired_npb, uint64_t blocks,
3870		 uint64_t blocks_with_extra),
3871	TP_ARGS(cur, level, nr_this_level, nr_per_block, desired_npb, blocks,
3872		blocks_with_extra),
3873	TP_STRUCT__entry(
3874		__field(dev_t, dev)
3875		__field(xfs_btnum_t, btnum)
3876		__field(unsigned int, level)
3877		__field(unsigned int, nlevels)
3878		__field(uint64_t, nr_this_level)
3879		__field(unsigned int, nr_per_block)
3880		__field(unsigned int, desired_npb)
3881		__field(unsigned long long, blocks)
3882		__field(unsigned long long, blocks_with_extra)
3883	),
3884	TP_fast_assign(
3885		__entry->dev = cur->bc_mp->m_super->s_dev;
3886		__entry->btnum = cur->bc_btnum;
3887		__entry->level = level;
3888		__entry->nlevels = cur->bc_nlevels;
3889		__entry->nr_this_level = nr_this_level;
3890		__entry->nr_per_block = nr_per_block;
3891		__entry->desired_npb = desired_npb;
3892		__entry->blocks = blocks;
3893		__entry->blocks_with_extra = blocks_with_extra;
3894	),
3895	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",
3896		  MAJOR(__entry->dev), MINOR(__entry->dev),
3897		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3898		  __entry->level,
3899		  __entry->nlevels,
3900		  __entry->nr_this_level,
3901		  __entry->nr_per_block,
3902		  __entry->desired_npb,
3903		  __entry->blocks,
3904		  __entry->blocks_with_extra)
3905)
3906
3907TRACE_EVENT(xfs_btree_bload_block,
3908	TP_PROTO(struct xfs_btree_cur *cur, unsigned int level,
3909		 uint64_t block_idx, uint64_t nr_blocks,
3910		 union xfs_btree_ptr *ptr, unsigned int nr_records),
3911	TP_ARGS(cur, level, block_idx, nr_blocks, ptr, nr_records),
3912	TP_STRUCT__entry(
3913		__field(dev_t, dev)
3914		__field(xfs_btnum_t, btnum)
3915		__field(unsigned int, level)
3916		__field(unsigned long long, block_idx)
3917		__field(unsigned long long, nr_blocks)
3918		__field(xfs_agnumber_t, agno)
3919		__field(xfs_agblock_t, agbno)
3920		__field(unsigned int, nr_records)
3921	),
3922	TP_fast_assign(
3923		__entry->dev = cur->bc_mp->m_super->s_dev;
3924		__entry->btnum = cur->bc_btnum;
3925		__entry->level = level;
3926		__entry->block_idx = block_idx;
3927		__entry->nr_blocks = nr_blocks;
3928		if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
3929			xfs_fsblock_t	fsb = be64_to_cpu(ptr->l);
3930
3931			__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsb);
3932			__entry->agbno = XFS_FSB_TO_AGBNO(cur->bc_mp, fsb);
3933		} else {
3934			__entry->agno = cur->bc_ag.pag->pag_agno;
3935			__entry->agbno = be32_to_cpu(ptr->s);
3936		}
3937		__entry->nr_records = nr_records;
3938	),
3939	TP_printk("dev %d:%d btree %s level %u block %llu/%llu agno 0x%x agbno 0x%x recs %u",
3940		  MAJOR(__entry->dev), MINOR(__entry->dev),
3941		  __print_symbolic(__entry->btnum, XFS_BTNUM_STRINGS),
3942		  __entry->level,
3943		  __entry->block_idx,
3944		  __entry->nr_blocks,
3945		  __entry->agno,
3946		  __entry->agbno,
3947		  __entry->nr_records)
3948)
3949
3950DECLARE_EVENT_CLASS(xfs_timestamp_range_class,
3951	TP_PROTO(struct xfs_mount *mp, time64_t min, time64_t max),
3952	TP_ARGS(mp, min, max),
3953	TP_STRUCT__entry(
3954		__field(dev_t, dev)
3955		__field(long long, min)
3956		__field(long long, max)
3957	),
3958	TP_fast_assign(
3959		__entry->dev = mp->m_super->s_dev;
3960		__entry->min = min;
3961		__entry->max = max;
3962	),
3963	TP_printk("dev %d:%d min %lld max %lld",
3964		  MAJOR(__entry->dev), MINOR(__entry->dev),
3965		  __entry->min,
3966		  __entry->max)
3967)
3968
3969#define DEFINE_TIMESTAMP_RANGE_EVENT(name) \
3970DEFINE_EVENT(xfs_timestamp_range_class, name, \
3971	TP_PROTO(struct xfs_mount *mp, long long min, long long max), \
3972	TP_ARGS(mp, min, max))
3973DEFINE_TIMESTAMP_RANGE_EVENT(xfs_inode_timestamp_range);
3974DEFINE_TIMESTAMP_RANGE_EVENT(xfs_quota_expiry_range);
3975
3976DECLARE_EVENT_CLASS(xfs_icwalk_class,
3977	TP_PROTO(struct xfs_mount *mp, struct xfs_icwalk *icw,
3978		 unsigned long caller_ip),
3979	TP_ARGS(mp, icw, caller_ip),
3980	TP_STRUCT__entry(
3981		__field(dev_t, dev)
3982		__field(__u32, flags)
3983		__field(uint32_t, uid)
3984		__field(uint32_t, gid)
3985		__field(prid_t, prid)
3986		__field(__u64, min_file_size)
3987		__field(long, scan_limit)
3988		__field(unsigned long, caller_ip)
3989	),
3990	TP_fast_assign(
3991		__entry->dev = mp->m_super->s_dev;
3992		__entry->flags = icw ? icw->icw_flags : 0;
3993		__entry->uid = icw ? from_kuid(mp->m_super->s_user_ns,
3994						icw->icw_uid) : 0;
3995		__entry->gid = icw ? from_kgid(mp->m_super->s_user_ns,
3996						icw->icw_gid) : 0;
3997		__entry->prid = icw ? icw->icw_prid : 0;
3998		__entry->min_file_size = icw ? icw->icw_min_file_size : 0;
3999		__entry->scan_limit = icw ? icw->icw_scan_limit : 0;
4000		__entry->caller_ip = caller_ip;
4001	),
4002	TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %ld caller %pS",
4003		  MAJOR(__entry->dev), MINOR(__entry->dev),
4004		  __entry->flags,
4005		  __entry->uid,
4006		  __entry->gid,
4007		  __entry->prid,
4008		  __entry->min_file_size,
4009		  __entry->scan_limit,
4010		  (char *)__entry->caller_ip)
4011);
4012#define DEFINE_ICWALK_EVENT(name)	\
4013DEFINE_EVENT(xfs_icwalk_class, name,	\
4014	TP_PROTO(struct xfs_mount *mp, struct xfs_icwalk *icw, \
4015		 unsigned long caller_ip), \
4016	TP_ARGS(mp, icw, caller_ip))
4017DEFINE_ICWALK_EVENT(xfs_ioc_free_eofblocks);
4018DEFINE_ICWALK_EVENT(xfs_blockgc_free_space);
4019
4020TRACE_DEFINE_ENUM(XLOG_STATE_ACTIVE);
4021TRACE_DEFINE_ENUM(XLOG_STATE_WANT_SYNC);
4022TRACE_DEFINE_ENUM(XLOG_STATE_SYNCING);
4023TRACE_DEFINE_ENUM(XLOG_STATE_DONE_SYNC);
4024TRACE_DEFINE_ENUM(XLOG_STATE_CALLBACK);
4025TRACE_DEFINE_ENUM(XLOG_STATE_DIRTY);
4026
4027DECLARE_EVENT_CLASS(xlog_iclog_class,
4028	TP_PROTO(struct xlog_in_core *iclog, unsigned long caller_ip),
4029	TP_ARGS(iclog, caller_ip),
4030	TP_STRUCT__entry(
4031		__field(dev_t, dev)
4032		__field(uint32_t, state)
4033		__field(int32_t, refcount)
4034		__field(uint32_t, offset)
4035		__field(uint32_t, flags)
4036		__field(unsigned long long, lsn)
4037		__field(unsigned long, caller_ip)
4038	),
4039	TP_fast_assign(
4040		__entry->dev = iclog->ic_log->l_mp->m_super->s_dev;
4041		__entry->state = iclog->ic_state;
4042		__entry->refcount = atomic_read(&iclog->ic_refcnt);
4043		__entry->offset = iclog->ic_offset;
4044		__entry->flags = iclog->ic_flags;
4045		__entry->lsn = be64_to_cpu(iclog->ic_header.h_lsn);
4046		__entry->caller_ip = caller_ip;
4047	),
4048	TP_printk("dev %d:%d state %s refcnt %d offset %u lsn 0x%llx flags %s caller %pS",
4049		  MAJOR(__entry->dev), MINOR(__entry->dev),
4050		  __print_symbolic(__entry->state, XLOG_STATE_STRINGS),
4051		  __entry->refcount,
4052		  __entry->offset,
4053		  __entry->lsn,
4054		  __print_flags(__entry->flags, "|", XLOG_ICL_STRINGS),
4055		  (char *)__entry->caller_ip)
4056
4057);
4058
4059#define DEFINE_ICLOG_EVENT(name)	\
4060DEFINE_EVENT(xlog_iclog_class, name,	\
4061	TP_PROTO(struct xlog_in_core *iclog, unsigned long caller_ip), \
4062	TP_ARGS(iclog, caller_ip))
4063
4064DEFINE_ICLOG_EVENT(xlog_iclog_activate);
4065DEFINE_ICLOG_EVENT(xlog_iclog_clean);
4066DEFINE_ICLOG_EVENT(xlog_iclog_callback);
4067DEFINE_ICLOG_EVENT(xlog_iclog_callbacks_start);
4068DEFINE_ICLOG_EVENT(xlog_iclog_callbacks_done);
4069DEFINE_ICLOG_EVENT(xlog_iclog_force);
4070DEFINE_ICLOG_EVENT(xlog_iclog_force_lsn);
4071DEFINE_ICLOG_EVENT(xlog_iclog_get_space);
4072DEFINE_ICLOG_EVENT(xlog_iclog_release);
4073DEFINE_ICLOG_EVENT(xlog_iclog_switch);
4074DEFINE_ICLOG_EVENT(xlog_iclog_sync);
4075DEFINE_ICLOG_EVENT(xlog_iclog_syncing);
4076DEFINE_ICLOG_EVENT(xlog_iclog_sync_done);
4077DEFINE_ICLOG_EVENT(xlog_iclog_want_sync);
4078DEFINE_ICLOG_EVENT(xlog_iclog_wait_on);
4079DEFINE_ICLOG_EVENT(xlog_iclog_write);
4080
4081DECLARE_EVENT_CLASS(xfs_das_state_class,
4082	TP_PROTO(int das, struct xfs_inode *ip),
4083	TP_ARGS(das, ip),
4084	TP_STRUCT__entry(
4085		__field(int, das)
4086		__field(xfs_ino_t, ino)
4087	),
4088	TP_fast_assign(
4089		__entry->das = das;
4090		__entry->ino = ip->i_ino;
4091	),
4092	TP_printk("state change %d ino 0x%llx",
4093		  __entry->das, __entry->ino)
4094)
4095
4096#define DEFINE_DAS_STATE_EVENT(name) \
4097DEFINE_EVENT(xfs_das_state_class, name, \
4098	TP_PROTO(int das, struct xfs_inode *ip), \
4099	TP_ARGS(das, ip))
4100DEFINE_DAS_STATE_EVENT(xfs_attr_sf_addname_return);
4101DEFINE_DAS_STATE_EVENT(xfs_attr_set_iter_return);
4102DEFINE_DAS_STATE_EVENT(xfs_attr_node_addname_return);
4103DEFINE_DAS_STATE_EVENT(xfs_attr_remove_iter_return);
4104DEFINE_DAS_STATE_EVENT(xfs_attr_rmtval_remove_return);
4105
4106TRACE_EVENT(xfs_force_shutdown,
4107	TP_PROTO(struct xfs_mount *mp, int ptag, int flags, const char *fname,
4108		 int line_num),
4109	TP_ARGS(mp, ptag, flags, fname, line_num),
4110	TP_STRUCT__entry(
4111		__field(dev_t, dev)
4112		__field(int, ptag)
4113		__field(int, flags)
4114		__string(fname, fname)
4115		__field(int, line_num)
4116	),
4117	TP_fast_assign(
4118		__entry->dev = mp->m_super->s_dev;
4119		__entry->ptag = ptag;
4120		__entry->flags = flags;
4121		__assign_str(fname, fname);
4122		__entry->line_num = line_num;
4123	),
4124	TP_printk("dev %d:%d tag %s flags %s file %s line_num %d",
4125		  MAJOR(__entry->dev), MINOR(__entry->dev),
4126		__print_flags(__entry->ptag, "|", XFS_PTAG_STRINGS),
4127		__print_flags(__entry->flags, "|", XFS_SHUTDOWN_STRINGS),
4128		__get_str(fname),
4129		__entry->line_num)
4130);
4131
4132#endif /* _TRACE_XFS_H */
4133
4134#undef TRACE_INCLUDE_PATH
4135#define TRACE_INCLUDE_PATH .
4136#define TRACE_INCLUDE_FILE xfs_trace
4137#include <trace/define_trace.h>
4138