1 /*
2  * Copyright (c) 2009, Christoph Hellwig
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 #undef TRACE_SYSTEM
19 #define TRACE_SYSTEM xfs
20 
21 #if !defined(_TRACE_XFS_H) || defined(TRACE_HEADER_MULTI_READ)
22 #define _TRACE_XFS_H
23 
24 #include <linux/tracepoint.h>
25 
26 struct xfs_agf;
27 struct xfs_alloc_arg;
28 struct xfs_attr_list_context;
29 struct xfs_buf_log_item;
30 struct xfs_da_args;
31 struct xfs_da_node_entry;
32 struct xfs_dquot;
33 struct xfs_log_item;
34 struct xlog_ticket;
35 struct log;
36 struct xlog_recover;
37 struct xlog_recover_item;
38 struct xfs_buf_log_format;
39 struct xfs_inode_log_format;
40 
41 DECLARE_EVENT_CLASS(xfs_attr_list_class,
42 	TP_PROTO(struct xfs_attr_list_context *ctx),
43 	TP_ARGS(ctx),
44 	TP_STRUCT__entry(
45 		__field(dev_t, dev)
46 		__field(xfs_ino_t, ino)
47 		__field(u32, hashval)
48 		__field(u32, blkno)
49 		__field(u32, offset)
50 		__field(void *, alist)
51 		__field(int, bufsize)
52 		__field(int, count)
53 		__field(int, firstu)
54 		__field(int, dupcnt)
55 		__field(int, flags)
56 	),
57 	TP_fast_assign(
58 		__entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
59 		__entry->ino = ctx->dp->i_ino;
60 		__entry->hashval = ctx->cursor->hashval;
61 		__entry->blkno = ctx->cursor->blkno;
62 		__entry->offset = ctx->cursor->offset;
63 		__entry->alist = ctx->alist;
64 		__entry->bufsize = ctx->bufsize;
65 		__entry->count = ctx->count;
66 		__entry->firstu = ctx->firstu;
67 		__entry->flags = ctx->flags;
68 	),
69 	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
70 		  "alist 0x%p size %u count %u firstu %u flags %d %s",
71 		  MAJOR(__entry->dev), MINOR(__entry->dev),
72 		   __entry->ino,
73 		   __entry->hashval,
74 		   __entry->blkno,
75 		   __entry->offset,
76 		   __entry->dupcnt,
77 		   __entry->alist,
78 		   __entry->bufsize,
79 		   __entry->count,
80 		   __entry->firstu,
81 		   __entry->flags,
82 		   __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS)
83 	)
84 )
85 
86 #define DEFINE_ATTR_LIST_EVENT(name) \
87 DEFINE_EVENT(xfs_attr_list_class, name, \
88 	TP_PROTO(struct xfs_attr_list_context *ctx), \
89 	TP_ARGS(ctx))
90 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf);
91 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf_all);
92 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf);
93 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf_end);
94 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_full);
95 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_add);
96 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_wrong_blk);
97 DEFINE_ATTR_LIST_EVENT(xfs_attr_list_notfound);
98 
99 DECLARE_EVENT_CLASS(xfs_perag_class,
100 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int refcount,
101 		 unsigned long caller_ip),
102 	TP_ARGS(mp, agno, refcount, caller_ip),
103 	TP_STRUCT__entry(
104 		__field(dev_t, dev)
105 		__field(xfs_agnumber_t, agno)
106 		__field(int, refcount)
107 		__field(unsigned long, caller_ip)
108 	),
109 	TP_fast_assign(
110 		__entry->dev = mp->m_super->s_dev;
111 		__entry->agno = agno;
112 		__entry->refcount = refcount;
113 		__entry->caller_ip = caller_ip;
114 	),
115 	TP_printk("dev %d:%d agno %u refcount %d caller %pf",
116 		  MAJOR(__entry->dev), MINOR(__entry->dev),
117 		  __entry->agno,
118 		  __entry->refcount,
119 		  (char *)__entry->caller_ip)
120 );
121 
122 #define DEFINE_PERAG_REF_EVENT(name)	\
123 DEFINE_EVENT(xfs_perag_class, name,	\
124 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, int refcount,	\
125 		 unsigned long caller_ip),					\
126 	TP_ARGS(mp, agno, refcount, caller_ip))
127 DEFINE_PERAG_REF_EVENT(xfs_perag_get);
128 DEFINE_PERAG_REF_EVENT(xfs_perag_get_tag);
129 DEFINE_PERAG_REF_EVENT(xfs_perag_put);
130 DEFINE_PERAG_REF_EVENT(xfs_perag_set_reclaim);
131 DEFINE_PERAG_REF_EVENT(xfs_perag_clear_reclaim);
132 
133 TRACE_EVENT(xfs_attr_list_node_descend,
134 	TP_PROTO(struct xfs_attr_list_context *ctx,
135 		 struct xfs_da_node_entry *btree),
136 	TP_ARGS(ctx, btree),
137 	TP_STRUCT__entry(
138 		__field(dev_t, dev)
139 		__field(xfs_ino_t, ino)
140 		__field(u32, hashval)
141 		__field(u32, blkno)
142 		__field(u32, offset)
143 		__field(void *, alist)
144 		__field(int, bufsize)
145 		__field(int, count)
146 		__field(int, firstu)
147 		__field(int, dupcnt)
148 		__field(int, flags)
149 		__field(u32, bt_hashval)
150 		__field(u32, bt_before)
151 	),
152 	TP_fast_assign(
153 		__entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
154 		__entry->ino = ctx->dp->i_ino;
155 		__entry->hashval = ctx->cursor->hashval;
156 		__entry->blkno = ctx->cursor->blkno;
157 		__entry->offset = ctx->cursor->offset;
158 		__entry->alist = ctx->alist;
159 		__entry->bufsize = ctx->bufsize;
160 		__entry->count = ctx->count;
161 		__entry->firstu = ctx->firstu;
162 		__entry->flags = ctx->flags;
163 		__entry->bt_hashval = be32_to_cpu(btree->hashval);
164 		__entry->bt_before = be32_to_cpu(btree->before);
165 	),
166 	TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
167 		  "alist 0x%p size %u count %u firstu %u flags %d %s "
168 		  "node hashval %u, node before %u",
169 		  MAJOR(__entry->dev), MINOR(__entry->dev),
170 		   __entry->ino,
171 		   __entry->hashval,
172 		   __entry->blkno,
173 		   __entry->offset,
174 		   __entry->dupcnt,
175 		   __entry->alist,
176 		   __entry->bufsize,
177 		   __entry->count,
178 		   __entry->firstu,
179 		   __entry->flags,
180 		   __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS),
181 		   __entry->bt_hashval,
182 		   __entry->bt_before)
183 );
184 
185 TRACE_EVENT(xfs_iext_insert,
186 	TP_PROTO(struct xfs_inode *ip, xfs_extnum_t idx,
187 		 struct xfs_bmbt_irec *r, int state, unsigned long caller_ip),
188 	TP_ARGS(ip, idx, r, state, caller_ip),
189 	TP_STRUCT__entry(
190 		__field(dev_t, dev)
191 		__field(xfs_ino_t, ino)
192 		__field(xfs_extnum_t, idx)
193 		__field(xfs_fileoff_t, startoff)
194 		__field(xfs_fsblock_t, startblock)
195 		__field(xfs_filblks_t, blockcount)
196 		__field(xfs_exntst_t, state)
197 		__field(int, bmap_state)
198 		__field(unsigned long, caller_ip)
199 	),
200 	TP_fast_assign(
201 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
202 		__entry->ino = ip->i_ino;
203 		__entry->idx = idx;
204 		__entry->startoff = r->br_startoff;
205 		__entry->startblock = r->br_startblock;
206 		__entry->blockcount = r->br_blockcount;
207 		__entry->state = r->br_state;
208 		__entry->bmap_state = state;
209 		__entry->caller_ip = caller_ip;
210 	),
211 	TP_printk("dev %d:%d ino 0x%llx state %s idx %ld "
212 		  "offset %lld block %lld count %lld flag %d caller %pf",
213 		  MAJOR(__entry->dev), MINOR(__entry->dev),
214 		  __entry->ino,
215 		  __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS),
216 		  (long)__entry->idx,
217 		  __entry->startoff,
218 		  (__int64_t)__entry->startblock,
219 		  __entry->blockcount,
220 		  __entry->state,
221 		  (char *)__entry->caller_ip)
222 );
223 
224 DECLARE_EVENT_CLASS(xfs_bmap_class,
225 	TP_PROTO(struct xfs_inode *ip, xfs_extnum_t idx, int state,
226 		 unsigned long caller_ip),
227 	TP_ARGS(ip, idx, state, caller_ip),
228 	TP_STRUCT__entry(
229 		__field(dev_t, dev)
230 		__field(xfs_ino_t, ino)
231 		__field(xfs_extnum_t, idx)
232 		__field(xfs_fileoff_t, startoff)
233 		__field(xfs_fsblock_t, startblock)
234 		__field(xfs_filblks_t, blockcount)
235 		__field(xfs_exntst_t, state)
236 		__field(int, bmap_state)
237 		__field(unsigned long, caller_ip)
238 	),
239 	TP_fast_assign(
240 		struct xfs_ifork	*ifp = (state & BMAP_ATTRFORK) ?
241 						ip->i_afp : &ip->i_df;
242 		struct xfs_bmbt_irec	r;
243 
244 		xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &r);
245 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
246 		__entry->ino = ip->i_ino;
247 		__entry->idx = idx;
248 		__entry->startoff = r.br_startoff;
249 		__entry->startblock = r.br_startblock;
250 		__entry->blockcount = r.br_blockcount;
251 		__entry->state = r.br_state;
252 		__entry->bmap_state = state;
253 		__entry->caller_ip = caller_ip;
254 	),
255 	TP_printk("dev %d:%d ino 0x%llx state %s idx %ld "
256 		  "offset %lld block %lld count %lld flag %d caller %pf",
257 		  MAJOR(__entry->dev), MINOR(__entry->dev),
258 		  __entry->ino,
259 		  __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS),
260 		  (long)__entry->idx,
261 		  __entry->startoff,
262 		  (__int64_t)__entry->startblock,
263 		  __entry->blockcount,
264 		  __entry->state,
265 		  (char *)__entry->caller_ip)
266 )
267 
268 #define DEFINE_BMAP_EVENT(name) \
269 DEFINE_EVENT(xfs_bmap_class, name, \
270 	TP_PROTO(struct xfs_inode *ip, xfs_extnum_t idx, int state, \
271 		 unsigned long caller_ip), \
272 	TP_ARGS(ip, idx, state, caller_ip))
273 DEFINE_BMAP_EVENT(xfs_iext_remove);
274 DEFINE_BMAP_EVENT(xfs_bmap_pre_update);
275 DEFINE_BMAP_EVENT(xfs_bmap_post_update);
276 DEFINE_BMAP_EVENT(xfs_extlist);
277 
278 DECLARE_EVENT_CLASS(xfs_buf_class,
279 	TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip),
280 	TP_ARGS(bp, caller_ip),
281 	TP_STRUCT__entry(
282 		__field(dev_t, dev)
283 		__field(xfs_daddr_t, bno)
284 		__field(size_t, buffer_length)
285 		__field(int, hold)
286 		__field(int, pincount)
287 		__field(unsigned, lockval)
288 		__field(unsigned, flags)
289 		__field(unsigned long, caller_ip)
290 	),
291 	TP_fast_assign(
292 		__entry->dev = bp->b_target->bt_dev;
293 		__entry->bno = bp->b_bn;
294 		__entry->buffer_length = bp->b_buffer_length;
295 		__entry->hold = atomic_read(&bp->b_hold);
296 		__entry->pincount = atomic_read(&bp->b_pin_count);
297 		__entry->lockval = bp->b_sema.count;
298 		__entry->flags = bp->b_flags;
299 		__entry->caller_ip = caller_ip;
300 	),
301 	TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
302 		  "lock %d flags %s caller %pf",
303 		  MAJOR(__entry->dev), MINOR(__entry->dev),
304 		  (unsigned long long)__entry->bno,
305 		  __entry->buffer_length,
306 		  __entry->hold,
307 		  __entry->pincount,
308 		  __entry->lockval,
309 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
310 		  (void *)__entry->caller_ip)
311 )
312 
313 #define DEFINE_BUF_EVENT(name) \
314 DEFINE_EVENT(xfs_buf_class, name, \
315 	TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip), \
316 	TP_ARGS(bp, caller_ip))
317 DEFINE_BUF_EVENT(xfs_buf_init);
318 DEFINE_BUF_EVENT(xfs_buf_free);
319 DEFINE_BUF_EVENT(xfs_buf_hold);
320 DEFINE_BUF_EVENT(xfs_buf_rele);
321 DEFINE_BUF_EVENT(xfs_buf_iodone);
322 DEFINE_BUF_EVENT(xfs_buf_iorequest);
323 DEFINE_BUF_EVENT(xfs_buf_bawrite);
324 DEFINE_BUF_EVENT(xfs_buf_lock);
325 DEFINE_BUF_EVENT(xfs_buf_lock_done);
326 DEFINE_BUF_EVENT(xfs_buf_trylock);
327 DEFINE_BUF_EVENT(xfs_buf_unlock);
328 DEFINE_BUF_EVENT(xfs_buf_iowait);
329 DEFINE_BUF_EVENT(xfs_buf_iowait_done);
330 DEFINE_BUF_EVENT(xfs_buf_delwri_queue);
331 DEFINE_BUF_EVENT(xfs_buf_delwri_dequeue);
332 DEFINE_BUF_EVENT(xfs_buf_delwri_split);
333 DEFINE_BUF_EVENT(xfs_buf_get_uncached);
334 DEFINE_BUF_EVENT(xfs_bdstrat_shut);
335 DEFINE_BUF_EVENT(xfs_buf_item_relse);
336 DEFINE_BUF_EVENT(xfs_buf_item_iodone);
337 DEFINE_BUF_EVENT(xfs_buf_item_iodone_async);
338 DEFINE_BUF_EVENT(xfs_buf_error_relse);
339 DEFINE_BUF_EVENT(xfs_trans_read_buf_io);
340 DEFINE_BUF_EVENT(xfs_trans_read_buf_shut);
341 
342 /* not really buffer traces, but the buf provides useful information */
343 DEFINE_BUF_EVENT(xfs_btree_corrupt);
344 DEFINE_BUF_EVENT(xfs_da_btree_corrupt);
345 DEFINE_BUF_EVENT(xfs_reset_dqcounts);
346 DEFINE_BUF_EVENT(xfs_inode_item_push);
347 
348 /* pass flags explicitly */
349 DECLARE_EVENT_CLASS(xfs_buf_flags_class,
350 	TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip),
351 	TP_ARGS(bp, flags, caller_ip),
352 	TP_STRUCT__entry(
353 		__field(dev_t, dev)
354 		__field(xfs_daddr_t, bno)
355 		__field(size_t, buffer_length)
356 		__field(int, hold)
357 		__field(int, pincount)
358 		__field(unsigned, lockval)
359 		__field(unsigned, flags)
360 		__field(unsigned long, caller_ip)
361 	),
362 	TP_fast_assign(
363 		__entry->dev = bp->b_target->bt_dev;
364 		__entry->bno = bp->b_bn;
365 		__entry->buffer_length = bp->b_buffer_length;
366 		__entry->flags = flags;
367 		__entry->hold = atomic_read(&bp->b_hold);
368 		__entry->pincount = atomic_read(&bp->b_pin_count);
369 		__entry->lockval = bp->b_sema.count;
370 		__entry->caller_ip = caller_ip;
371 	),
372 	TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
373 		  "lock %d flags %s caller %pf",
374 		  MAJOR(__entry->dev), MINOR(__entry->dev),
375 		  (unsigned long long)__entry->bno,
376 		  __entry->buffer_length,
377 		  __entry->hold,
378 		  __entry->pincount,
379 		  __entry->lockval,
380 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
381 		  (void *)__entry->caller_ip)
382 )
383 
384 #define DEFINE_BUF_FLAGS_EVENT(name) \
385 DEFINE_EVENT(xfs_buf_flags_class, name, \
386 	TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip), \
387 	TP_ARGS(bp, flags, caller_ip))
388 DEFINE_BUF_FLAGS_EVENT(xfs_buf_find);
389 DEFINE_BUF_FLAGS_EVENT(xfs_buf_get);
390 DEFINE_BUF_FLAGS_EVENT(xfs_buf_read);
391 
392 TRACE_EVENT(xfs_buf_ioerror,
393 	TP_PROTO(struct xfs_buf *bp, int error, unsigned long caller_ip),
394 	TP_ARGS(bp, error, caller_ip),
395 	TP_STRUCT__entry(
396 		__field(dev_t, dev)
397 		__field(xfs_daddr_t, bno)
398 		__field(size_t, buffer_length)
399 		__field(unsigned, flags)
400 		__field(int, hold)
401 		__field(int, pincount)
402 		__field(unsigned, lockval)
403 		__field(int, error)
404 		__field(unsigned long, caller_ip)
405 	),
406 	TP_fast_assign(
407 		__entry->dev = bp->b_target->bt_dev;
408 		__entry->bno = bp->b_bn;
409 		__entry->buffer_length = bp->b_buffer_length;
410 		__entry->hold = atomic_read(&bp->b_hold);
411 		__entry->pincount = atomic_read(&bp->b_pin_count);
412 		__entry->lockval = bp->b_sema.count;
413 		__entry->error = error;
414 		__entry->flags = bp->b_flags;
415 		__entry->caller_ip = caller_ip;
416 	),
417 	TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
418 		  "lock %d error %d flags %s caller %pf",
419 		  MAJOR(__entry->dev), MINOR(__entry->dev),
420 		  (unsigned long long)__entry->bno,
421 		  __entry->buffer_length,
422 		  __entry->hold,
423 		  __entry->pincount,
424 		  __entry->lockval,
425 		  __entry->error,
426 		  __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
427 		  (void *)__entry->caller_ip)
428 );
429 
430 DECLARE_EVENT_CLASS(xfs_buf_item_class,
431 	TP_PROTO(struct xfs_buf_log_item *bip),
432 	TP_ARGS(bip),
433 	TP_STRUCT__entry(
434 		__field(dev_t, dev)
435 		__field(xfs_daddr_t, buf_bno)
436 		__field(size_t, buf_len)
437 		__field(int, buf_hold)
438 		__field(int, buf_pincount)
439 		__field(int, buf_lockval)
440 		__field(unsigned, buf_flags)
441 		__field(unsigned, bli_recur)
442 		__field(int, bli_refcount)
443 		__field(unsigned, bli_flags)
444 		__field(void *, li_desc)
445 		__field(unsigned, li_flags)
446 	),
447 	TP_fast_assign(
448 		__entry->dev = bip->bli_buf->b_target->bt_dev;
449 		__entry->bli_flags = bip->bli_flags;
450 		__entry->bli_recur = bip->bli_recur;
451 		__entry->bli_refcount = atomic_read(&bip->bli_refcount);
452 		__entry->buf_bno = bip->bli_buf->b_bn;
453 		__entry->buf_len = bip->bli_buf->b_buffer_length;
454 		__entry->buf_flags = bip->bli_buf->b_flags;
455 		__entry->buf_hold = atomic_read(&bip->bli_buf->b_hold);
456 		__entry->buf_pincount = atomic_read(&bip->bli_buf->b_pin_count);
457 		__entry->buf_lockval = bip->bli_buf->b_sema.count;
458 		__entry->li_desc = bip->bli_item.li_desc;
459 		__entry->li_flags = bip->bli_item.li_flags;
460 	),
461 	TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
462 		  "lock %d flags %s recur %d refcount %d bliflags %s "
463 		  "lidesc 0x%p liflags %s",
464 		  MAJOR(__entry->dev), MINOR(__entry->dev),
465 		  (unsigned long long)__entry->buf_bno,
466 		  __entry->buf_len,
467 		  __entry->buf_hold,
468 		  __entry->buf_pincount,
469 		  __entry->buf_lockval,
470 		  __print_flags(__entry->buf_flags, "|", XFS_BUF_FLAGS),
471 		  __entry->bli_recur,
472 		  __entry->bli_refcount,
473 		  __print_flags(__entry->bli_flags, "|", XFS_BLI_FLAGS),
474 		  __entry->li_desc,
475 		  __print_flags(__entry->li_flags, "|", XFS_LI_FLAGS))
476 )
477 
478 #define DEFINE_BUF_ITEM_EVENT(name) \
479 DEFINE_EVENT(xfs_buf_item_class, name, \
480 	TP_PROTO(struct xfs_buf_log_item *bip), \
481 	TP_ARGS(bip))
482 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size);
483 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale);
484 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format);
485 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale);
486 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
487 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin);
488 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale);
489 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_trylock);
490 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock);
491 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock_stale);
492 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed);
493 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push);
494 DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pushbuf);
495 DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf);
496 DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf_recur);
497 DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb);
498 DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb_recur);
499 DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf);
500 DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf_recur);
501 DEFINE_BUF_ITEM_EVENT(xfs_trans_log_buf);
502 DEFINE_BUF_ITEM_EVENT(xfs_trans_brelse);
503 DEFINE_BUF_ITEM_EVENT(xfs_trans_bjoin);
504 DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold);
505 DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release);
506 DEFINE_BUF_ITEM_EVENT(xfs_trans_binval);
507 
508 DECLARE_EVENT_CLASS(xfs_lock_class,
509 	TP_PROTO(struct xfs_inode *ip, unsigned lock_flags,
510 		 unsigned long caller_ip),
511 	TP_ARGS(ip,  lock_flags, caller_ip),
512 	TP_STRUCT__entry(
513 		__field(dev_t, dev)
514 		__field(xfs_ino_t, ino)
515 		__field(int, lock_flags)
516 		__field(unsigned long, caller_ip)
517 	),
518 	TP_fast_assign(
519 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
520 		__entry->ino = ip->i_ino;
521 		__entry->lock_flags = lock_flags;
522 		__entry->caller_ip = caller_ip;
523 	),
524 	TP_printk("dev %d:%d ino 0x%llx flags %s caller %pf",
525 		  MAJOR(__entry->dev), MINOR(__entry->dev),
526 		  __entry->ino,
527 		  __print_flags(__entry->lock_flags, "|", XFS_LOCK_FLAGS),
528 		  (void *)__entry->caller_ip)
529 )
530 
531 #define DEFINE_LOCK_EVENT(name) \
532 DEFINE_EVENT(xfs_lock_class, name, \
533 	TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, \
534 		 unsigned long caller_ip), \
535 	TP_ARGS(ip,  lock_flags, caller_ip))
536 DEFINE_LOCK_EVENT(xfs_ilock);
537 DEFINE_LOCK_EVENT(xfs_ilock_nowait);
538 DEFINE_LOCK_EVENT(xfs_ilock_demote);
539 DEFINE_LOCK_EVENT(xfs_iunlock);
540 
541 DECLARE_EVENT_CLASS(xfs_inode_class,
542 	TP_PROTO(struct xfs_inode *ip),
543 	TP_ARGS(ip),
544 	TP_STRUCT__entry(
545 		__field(dev_t, dev)
546 		__field(xfs_ino_t, ino)
547 	),
548 	TP_fast_assign(
549 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
550 		__entry->ino = ip->i_ino;
551 	),
552 	TP_printk("dev %d:%d ino 0x%llx",
553 		  MAJOR(__entry->dev), MINOR(__entry->dev),
554 		  __entry->ino)
555 )
556 
557 #define DEFINE_INODE_EVENT(name) \
558 DEFINE_EVENT(xfs_inode_class, name, \
559 	TP_PROTO(struct xfs_inode *ip), \
560 	TP_ARGS(ip))
561 DEFINE_INODE_EVENT(xfs_iget_skip);
562 DEFINE_INODE_EVENT(xfs_iget_reclaim);
563 DEFINE_INODE_EVENT(xfs_iget_reclaim_fail);
564 DEFINE_INODE_EVENT(xfs_iget_hit);
565 DEFINE_INODE_EVENT(xfs_iget_miss);
566 
567 DEFINE_INODE_EVENT(xfs_getattr);
568 DEFINE_INODE_EVENT(xfs_setattr);
569 DEFINE_INODE_EVENT(xfs_readlink);
570 DEFINE_INODE_EVENT(xfs_alloc_file_space);
571 DEFINE_INODE_EVENT(xfs_free_file_space);
572 DEFINE_INODE_EVENT(xfs_readdir);
573 #ifdef CONFIG_XFS_POSIX_ACL
574 DEFINE_INODE_EVENT(xfs_get_acl);
575 #endif
576 DEFINE_INODE_EVENT(xfs_vm_bmap);
577 DEFINE_INODE_EVENT(xfs_file_ioctl);
578 DEFINE_INODE_EVENT(xfs_file_compat_ioctl);
579 DEFINE_INODE_EVENT(xfs_ioctl_setattr);
580 DEFINE_INODE_EVENT(xfs_dir_fsync);
581 DEFINE_INODE_EVENT(xfs_file_fsync);
582 DEFINE_INODE_EVENT(xfs_destroy_inode);
583 DEFINE_INODE_EVENT(xfs_dirty_inode);
584 DEFINE_INODE_EVENT(xfs_evict_inode);
585 
586 DEFINE_INODE_EVENT(xfs_dquot_dqalloc);
587 DEFINE_INODE_EVENT(xfs_dquot_dqdetach);
588 
589 DECLARE_EVENT_CLASS(xfs_iref_class,
590 	TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip),
591 	TP_ARGS(ip, caller_ip),
592 	TP_STRUCT__entry(
593 		__field(dev_t, dev)
594 		__field(xfs_ino_t, ino)
595 		__field(int, count)
596 		__field(int, pincount)
597 		__field(unsigned long, caller_ip)
598 	),
599 	TP_fast_assign(
600 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
601 		__entry->ino = ip->i_ino;
602 		__entry->count = atomic_read(&VFS_I(ip)->i_count);
603 		__entry->pincount = atomic_read(&ip->i_pincount);
604 		__entry->caller_ip = caller_ip;
605 	),
606 	TP_printk("dev %d:%d ino 0x%llx count %d pincount %d caller %pf",
607 		  MAJOR(__entry->dev), MINOR(__entry->dev),
608 		  __entry->ino,
609 		  __entry->count,
610 		  __entry->pincount,
611 		  (char *)__entry->caller_ip)
612 )
613 
614 #define DEFINE_IREF_EVENT(name) \
615 DEFINE_EVENT(xfs_iref_class, name, \
616 	TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \
617 	TP_ARGS(ip, caller_ip))
618 DEFINE_IREF_EVENT(xfs_ihold);
619 DEFINE_IREF_EVENT(xfs_irele);
620 DEFINE_IREF_EVENT(xfs_inode_pin);
621 DEFINE_IREF_EVENT(xfs_inode_unpin);
622 DEFINE_IREF_EVENT(xfs_inode_unpin_nowait);
623 
624 DECLARE_EVENT_CLASS(xfs_namespace_class,
625 	TP_PROTO(struct xfs_inode *dp, struct xfs_name *name),
626 	TP_ARGS(dp, name),
627 	TP_STRUCT__entry(
628 		__field(dev_t, dev)
629 		__field(xfs_ino_t, dp_ino)
630 		__field(int, namelen)
631 		__dynamic_array(char, name, name->len)
632 	),
633 	TP_fast_assign(
634 		__entry->dev = VFS_I(dp)->i_sb->s_dev;
635 		__entry->dp_ino = dp->i_ino;
636 		__entry->namelen = name->len;
637 		memcpy(__get_str(name), name->name, name->len);
638 	),
639 	TP_printk("dev %d:%d dp ino 0x%llx name %.*s",
640 		  MAJOR(__entry->dev), MINOR(__entry->dev),
641 		  __entry->dp_ino,
642 		  __entry->namelen,
643 		  __get_str(name))
644 )
645 
646 #define DEFINE_NAMESPACE_EVENT(name) \
647 DEFINE_EVENT(xfs_namespace_class, name, \
648 	TP_PROTO(struct xfs_inode *dp, struct xfs_name *name), \
649 	TP_ARGS(dp, name))
650 DEFINE_NAMESPACE_EVENT(xfs_remove);
651 DEFINE_NAMESPACE_EVENT(xfs_link);
652 DEFINE_NAMESPACE_EVENT(xfs_lookup);
653 DEFINE_NAMESPACE_EVENT(xfs_create);
654 DEFINE_NAMESPACE_EVENT(xfs_symlink);
655 
656 TRACE_EVENT(xfs_rename,
657 	TP_PROTO(struct xfs_inode *src_dp, struct xfs_inode *target_dp,
658 		 struct xfs_name *src_name, struct xfs_name *target_name),
659 	TP_ARGS(src_dp, target_dp, src_name, target_name),
660 	TP_STRUCT__entry(
661 		__field(dev_t, dev)
662 		__field(xfs_ino_t, src_dp_ino)
663 		__field(xfs_ino_t, target_dp_ino)
664 		__field(int, src_namelen)
665 		__field(int, target_namelen)
666 		__dynamic_array(char, src_name, src_name->len)
667 		__dynamic_array(char, target_name, target_name->len)
668 	),
669 	TP_fast_assign(
670 		__entry->dev = VFS_I(src_dp)->i_sb->s_dev;
671 		__entry->src_dp_ino = src_dp->i_ino;
672 		__entry->target_dp_ino = target_dp->i_ino;
673 		__entry->src_namelen = src_name->len;
674 		__entry->target_namelen = target_name->len;
675 		memcpy(__get_str(src_name), src_name->name, src_name->len);
676 		memcpy(__get_str(target_name), target_name->name,
677 			target_name->len);
678 	),
679 	TP_printk("dev %d:%d src dp ino 0x%llx target dp ino 0x%llx"
680 		  " src name %.*s target name %.*s",
681 		  MAJOR(__entry->dev), MINOR(__entry->dev),
682 		  __entry->src_dp_ino,
683 		  __entry->target_dp_ino,
684 		  __entry->src_namelen,
685 		  __get_str(src_name),
686 		  __entry->target_namelen,
687 		  __get_str(target_name))
688 )
689 
690 DECLARE_EVENT_CLASS(xfs_dquot_class,
691 	TP_PROTO(struct xfs_dquot *dqp),
692 	TP_ARGS(dqp),
693 	TP_STRUCT__entry(
694 		__field(dev_t, dev)
695 		__field(u32, id)
696 		__field(unsigned, flags)
697 		__field(unsigned, nrefs)
698 		__field(unsigned long long, res_bcount)
699 		__field(unsigned long long, bcount)
700 		__field(unsigned long long, icount)
701 		__field(unsigned long long, blk_hardlimit)
702 		__field(unsigned long long, blk_softlimit)
703 		__field(unsigned long long, ino_hardlimit)
704 		__field(unsigned long long, ino_softlimit)
705 	), \
706 	TP_fast_assign(
707 		__entry->dev = dqp->q_mount->m_super->s_dev;
708 		__entry->id = be32_to_cpu(dqp->q_core.d_id);
709 		__entry->flags = dqp->dq_flags;
710 		__entry->nrefs = dqp->q_nrefs;
711 		__entry->res_bcount = dqp->q_res_bcount;
712 		__entry->bcount = be64_to_cpu(dqp->q_core.d_bcount);
713 		__entry->icount = be64_to_cpu(dqp->q_core.d_icount);
714 		__entry->blk_hardlimit =
715 			be64_to_cpu(dqp->q_core.d_blk_hardlimit);
716 		__entry->blk_softlimit =
717 			be64_to_cpu(dqp->q_core.d_blk_softlimit);
718 		__entry->ino_hardlimit =
719 			be64_to_cpu(dqp->q_core.d_ino_hardlimit);
720 		__entry->ino_softlimit =
721 			be64_to_cpu(dqp->q_core.d_ino_softlimit);
722 	),
723 	TP_printk("dev %d:%d id 0x%x flags %s nrefs %u res_bc 0x%llx "
724 		  "bcnt 0x%llx bhardlimit 0x%llx bsoftlimit 0x%llx "
725 		  "icnt 0x%llx ihardlimit 0x%llx isoftlimit 0x%llx]",
726 		  MAJOR(__entry->dev), MINOR(__entry->dev),
727 		  __entry->id,
728 		  __print_flags(__entry->flags, "|", XFS_DQ_FLAGS),
729 		  __entry->nrefs,
730 		  __entry->res_bcount,
731 		  __entry->bcount,
732 		  __entry->blk_hardlimit,
733 		  __entry->blk_softlimit,
734 		  __entry->icount,
735 		  __entry->ino_hardlimit,
736 		  __entry->ino_softlimit)
737 )
738 
739 #define DEFINE_DQUOT_EVENT(name) \
740 DEFINE_EVENT(xfs_dquot_class, name, \
741 	TP_PROTO(struct xfs_dquot *dqp), \
742 	TP_ARGS(dqp))
743 DEFINE_DQUOT_EVENT(xfs_dqadjust);
744 DEFINE_DQUOT_EVENT(xfs_dqreclaim_want);
745 DEFINE_DQUOT_EVENT(xfs_dqreclaim_dirty);
746 DEFINE_DQUOT_EVENT(xfs_dqreclaim_busy);
747 DEFINE_DQUOT_EVENT(xfs_dqreclaim_done);
748 DEFINE_DQUOT_EVENT(xfs_dqattach_found);
749 DEFINE_DQUOT_EVENT(xfs_dqattach_get);
750 DEFINE_DQUOT_EVENT(xfs_dqalloc);
751 DEFINE_DQUOT_EVENT(xfs_dqtobp_read);
752 DEFINE_DQUOT_EVENT(xfs_dqread);
753 DEFINE_DQUOT_EVENT(xfs_dqread_fail);
754 DEFINE_DQUOT_EVENT(xfs_dqget_hit);
755 DEFINE_DQUOT_EVENT(xfs_dqget_miss);
756 DEFINE_DQUOT_EVENT(xfs_dqget_freeing);
757 DEFINE_DQUOT_EVENT(xfs_dqget_dup);
758 DEFINE_DQUOT_EVENT(xfs_dqput);
759 DEFINE_DQUOT_EVENT(xfs_dqput_wait);
760 DEFINE_DQUOT_EVENT(xfs_dqput_free);
761 DEFINE_DQUOT_EVENT(xfs_dqrele);
762 DEFINE_DQUOT_EVENT(xfs_dqflush);
763 DEFINE_DQUOT_EVENT(xfs_dqflush_force);
764 DEFINE_DQUOT_EVENT(xfs_dqflush_done);
765 
766 DECLARE_EVENT_CLASS(xfs_loggrant_class,
767 	TP_PROTO(struct log *log, struct xlog_ticket *tic),
768 	TP_ARGS(log, tic),
769 	TP_STRUCT__entry(
770 		__field(dev_t, dev)
771 		__field(unsigned, trans_type)
772 		__field(char, ocnt)
773 		__field(char, cnt)
774 		__field(int, curr_res)
775 		__field(int, unit_res)
776 		__field(unsigned int, flags)
777 		__field(int, reserveq)
778 		__field(int, writeq)
779 		__field(int, grant_reserve_cycle)
780 		__field(int, grant_reserve_bytes)
781 		__field(int, grant_write_cycle)
782 		__field(int, grant_write_bytes)
783 		__field(int, curr_cycle)
784 		__field(int, curr_block)
785 		__field(xfs_lsn_t, tail_lsn)
786 	),
787 	TP_fast_assign(
788 		__entry->dev = log->l_mp->m_super->s_dev;
789 		__entry->trans_type = tic->t_trans_type;
790 		__entry->ocnt = tic->t_ocnt;
791 		__entry->cnt = tic->t_cnt;
792 		__entry->curr_res = tic->t_curr_res;
793 		__entry->unit_res = tic->t_unit_res;
794 		__entry->flags = tic->t_flags;
795 		__entry->reserveq = list_empty(&log->l_reserve_head.waiters);
796 		__entry->writeq = list_empty(&log->l_write_head.waiters);
797 		xlog_crack_grant_head(&log->l_reserve_head.grant,
798 				&__entry->grant_reserve_cycle,
799 				&__entry->grant_reserve_bytes);
800 		xlog_crack_grant_head(&log->l_write_head.grant,
801 				&__entry->grant_write_cycle,
802 				&__entry->grant_write_bytes);
803 		__entry->curr_cycle = log->l_curr_cycle;
804 		__entry->curr_block = log->l_curr_block;
805 		__entry->tail_lsn = atomic64_read(&log->l_tail_lsn);
806 	),
807 	TP_printk("dev %d:%d type %s t_ocnt %u t_cnt %u t_curr_res %u "
808 		  "t_unit_res %u t_flags %s reserveq %s "
809 		  "writeq %s grant_reserve_cycle %d "
810 		  "grant_reserve_bytes %d grant_write_cycle %d "
811 		  "grant_write_bytes %d curr_cycle %d curr_block %d "
812 		  "tail_cycle %d tail_block %d",
813 		  MAJOR(__entry->dev), MINOR(__entry->dev),
814 		  __print_symbolic(__entry->trans_type, XFS_TRANS_TYPES),
815 		  __entry->ocnt,
816 		  __entry->cnt,
817 		  __entry->curr_res,
818 		  __entry->unit_res,
819 		  __print_flags(__entry->flags, "|", XLOG_TIC_FLAGS),
820 		  __entry->reserveq ? "empty" : "active",
821 		  __entry->writeq ? "empty" : "active",
822 		  __entry->grant_reserve_cycle,
823 		  __entry->grant_reserve_bytes,
824 		  __entry->grant_write_cycle,
825 		  __entry->grant_write_bytes,
826 		  __entry->curr_cycle,
827 		  __entry->curr_block,
828 		  CYCLE_LSN(__entry->tail_lsn),
829 		  BLOCK_LSN(__entry->tail_lsn)
830 	)
831 )
832 
833 #define DEFINE_LOGGRANT_EVENT(name) \
834 DEFINE_EVENT(xfs_loggrant_class, name, \
835 	TP_PROTO(struct log *log, struct xlog_ticket *tic), \
836 	TP_ARGS(log, tic))
837 DEFINE_LOGGRANT_EVENT(xfs_log_done_nonperm);
838 DEFINE_LOGGRANT_EVENT(xfs_log_done_perm);
839 DEFINE_LOGGRANT_EVENT(xfs_log_umount_write);
840 DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep);
841 DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake);
842 DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake_up);
843 DEFINE_LOGGRANT_EVENT(xfs_log_reserve);
844 DEFINE_LOGGRANT_EVENT(xfs_log_reserve_exit);
845 DEFINE_LOGGRANT_EVENT(xfs_log_regrant);
846 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_exit);
847 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter);
848 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit);
849 DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_sub);
850 DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_enter);
851 DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_exit);
852 DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_sub);
853 
854 DECLARE_EVENT_CLASS(xfs_log_item_class,
855 	TP_PROTO(struct xfs_log_item *lip),
856 	TP_ARGS(lip),
857 	TP_STRUCT__entry(
858 		__field(dev_t, dev)
859 		__field(void *, lip)
860 		__field(uint, type)
861 		__field(uint, flags)
862 		__field(xfs_lsn_t, lsn)
863 	),
864 	TP_fast_assign(
865 		__entry->dev = lip->li_mountp->m_super->s_dev;
866 		__entry->lip = lip;
867 		__entry->type = lip->li_type;
868 		__entry->flags = lip->li_flags;
869 		__entry->lsn = lip->li_lsn;
870 	),
871 	TP_printk("dev %d:%d lip 0x%p lsn %d/%d type %s flags %s",
872 		  MAJOR(__entry->dev), MINOR(__entry->dev),
873 		  __entry->lip,
874 		  CYCLE_LSN(__entry->lsn), BLOCK_LSN(__entry->lsn),
875 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
876 		  __print_flags(__entry->flags, "|", XFS_LI_FLAGS))
877 )
878 
879 #define DEFINE_LOG_ITEM_EVENT(name) \
880 DEFINE_EVENT(xfs_log_item_class, name, \
881 	TP_PROTO(struct xfs_log_item *lip), \
882 	TP_ARGS(lip))
883 DEFINE_LOG_ITEM_EVENT(xfs_ail_push);
884 DEFINE_LOG_ITEM_EVENT(xfs_ail_pushbuf);
885 DEFINE_LOG_ITEM_EVENT(xfs_ail_pushbuf_pinned);
886 DEFINE_LOG_ITEM_EVENT(xfs_ail_pinned);
887 DEFINE_LOG_ITEM_EVENT(xfs_ail_locked);
888 
889 
890 DECLARE_EVENT_CLASS(xfs_file_class,
891 	TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset, int flags),
892 	TP_ARGS(ip, count, offset, flags),
893 	TP_STRUCT__entry(
894 		__field(dev_t, dev)
895 		__field(xfs_ino_t, ino)
896 		__field(xfs_fsize_t, size)
897 		__field(loff_t, offset)
898 		__field(size_t, count)
899 		__field(int, flags)
900 	),
901 	TP_fast_assign(
902 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
903 		__entry->ino = ip->i_ino;
904 		__entry->size = ip->i_d.di_size;
905 		__entry->offset = offset;
906 		__entry->count = count;
907 		__entry->flags = flags;
908 	),
909 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx "
910 		  "offset 0x%llx count 0x%zx ioflags %s",
911 		  MAJOR(__entry->dev), MINOR(__entry->dev),
912 		  __entry->ino,
913 		  __entry->size,
914 		  __entry->offset,
915 		  __entry->count,
916 		  __print_flags(__entry->flags, "|", XFS_IO_FLAGS))
917 )
918 
919 #define DEFINE_RW_EVENT(name)		\
920 DEFINE_EVENT(xfs_file_class, name,	\
921 	TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset, int flags),	\
922 	TP_ARGS(ip, count, offset, flags))
923 DEFINE_RW_EVENT(xfs_file_read);
924 DEFINE_RW_EVENT(xfs_file_buffered_write);
925 DEFINE_RW_EVENT(xfs_file_direct_write);
926 DEFINE_RW_EVENT(xfs_file_splice_read);
927 DEFINE_RW_EVENT(xfs_file_splice_write);
928 
929 DECLARE_EVENT_CLASS(xfs_page_class,
930 	TP_PROTO(struct inode *inode, struct page *page, unsigned long off),
931 	TP_ARGS(inode, page, off),
932 	TP_STRUCT__entry(
933 		__field(dev_t, dev)
934 		__field(xfs_ino_t, ino)
935 		__field(pgoff_t, pgoff)
936 		__field(loff_t, size)
937 		__field(unsigned long, offset)
938 		__field(int, delalloc)
939 		__field(int, unwritten)
940 	),
941 	TP_fast_assign(
942 		int delalloc = -1, unwritten = -1;
943 
944 		if (page_has_buffers(page))
945 			xfs_count_page_state(page, &delalloc, &unwritten);
946 		__entry->dev = inode->i_sb->s_dev;
947 		__entry->ino = XFS_I(inode)->i_ino;
948 		__entry->pgoff = page_offset(page);
949 		__entry->size = i_size_read(inode);
950 		__entry->offset = off;
951 		__entry->delalloc = delalloc;
952 		__entry->unwritten = unwritten;
953 	),
954 	TP_printk("dev %d:%d ino 0x%llx pgoff 0x%lx size 0x%llx offset %lx "
955 		  "delalloc %d unwritten %d",
956 		  MAJOR(__entry->dev), MINOR(__entry->dev),
957 		  __entry->ino,
958 		  __entry->pgoff,
959 		  __entry->size,
960 		  __entry->offset,
961 		  __entry->delalloc,
962 		  __entry->unwritten)
963 )
964 
965 #define DEFINE_PAGE_EVENT(name)		\
966 DEFINE_EVENT(xfs_page_class, name,	\
967 	TP_PROTO(struct inode *inode, struct page *page, unsigned long off),	\
968 	TP_ARGS(inode, page, off))
969 DEFINE_PAGE_EVENT(xfs_writepage);
970 DEFINE_PAGE_EVENT(xfs_releasepage);
971 DEFINE_PAGE_EVENT(xfs_invalidatepage);
972 
973 DECLARE_EVENT_CLASS(xfs_imap_class,
974 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,
975 		 int type, struct xfs_bmbt_irec *irec),
976 	TP_ARGS(ip, offset, count, type, irec),
977 	TP_STRUCT__entry(
978 		__field(dev_t, dev)
979 		__field(xfs_ino_t, ino)
980 		__field(loff_t, size)
981 		__field(loff_t, offset)
982 		__field(size_t, count)
983 		__field(int, type)
984 		__field(xfs_fileoff_t, startoff)
985 		__field(xfs_fsblock_t, startblock)
986 		__field(xfs_filblks_t, blockcount)
987 	),
988 	TP_fast_assign(
989 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
990 		__entry->ino = ip->i_ino;
991 		__entry->size = ip->i_d.di_size;
992 		__entry->offset = offset;
993 		__entry->count = count;
994 		__entry->type = type;
995 		__entry->startoff = irec ? irec->br_startoff : 0;
996 		__entry->startblock = irec ? irec->br_startblock : 0;
997 		__entry->blockcount = irec ? irec->br_blockcount : 0;
998 	),
999 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset 0x%llx count %zd "
1000 		  "type %s startoff 0x%llx startblock %lld blockcount 0x%llx",
1001 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1002 		  __entry->ino,
1003 		  __entry->size,
1004 		  __entry->offset,
1005 		  __entry->count,
1006 		  __print_symbolic(__entry->type, XFS_IO_TYPES),
1007 		  __entry->startoff,
1008 		  (__int64_t)__entry->startblock,
1009 		  __entry->blockcount)
1010 )
1011 
1012 #define DEFINE_IOMAP_EVENT(name)	\
1013 DEFINE_EVENT(xfs_imap_class, name,	\
1014 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,	\
1015 		 int type, struct xfs_bmbt_irec *irec),		\
1016 	TP_ARGS(ip, offset, count, type, irec))
1017 DEFINE_IOMAP_EVENT(xfs_map_blocks_found);
1018 DEFINE_IOMAP_EVENT(xfs_map_blocks_alloc);
1019 DEFINE_IOMAP_EVENT(xfs_get_blocks_found);
1020 DEFINE_IOMAP_EVENT(xfs_get_blocks_alloc);
1021 
1022 DECLARE_EVENT_CLASS(xfs_simple_io_class,
1023 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),
1024 	TP_ARGS(ip, offset, count),
1025 	TP_STRUCT__entry(
1026 		__field(dev_t, dev)
1027 		__field(xfs_ino_t, ino)
1028 		__field(loff_t, isize)
1029 		__field(loff_t, disize)
1030 		__field(loff_t, offset)
1031 		__field(size_t, count)
1032 	),
1033 	TP_fast_assign(
1034 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1035 		__entry->ino = ip->i_ino;
1036 		__entry->isize = VFS_I(ip)->i_size;
1037 		__entry->disize = ip->i_d.di_size;
1038 		__entry->offset = offset;
1039 		__entry->count = count;
1040 	),
1041 	TP_printk("dev %d:%d ino 0x%llx isize 0x%llx disize 0x%llx "
1042 		  "offset 0x%llx count %zd",
1043 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1044 		  __entry->ino,
1045 		  __entry->isize,
1046 		  __entry->disize,
1047 		  __entry->offset,
1048 		  __entry->count)
1049 );
1050 
1051 #define DEFINE_SIMPLE_IO_EVENT(name)	\
1052 DEFINE_EVENT(xfs_simple_io_class, name,	\
1053 	TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),	\
1054 	TP_ARGS(ip, offset, count))
1055 DEFINE_SIMPLE_IO_EVENT(xfs_delalloc_enospc);
1056 DEFINE_SIMPLE_IO_EVENT(xfs_unwritten_convert);
1057 DEFINE_SIMPLE_IO_EVENT(xfs_get_blocks_notfound);
1058 DEFINE_SIMPLE_IO_EVENT(xfs_setfilesize);
1059 
1060 DECLARE_EVENT_CLASS(xfs_itrunc_class,
1061 	TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size),
1062 	TP_ARGS(ip, new_size),
1063 	TP_STRUCT__entry(
1064 		__field(dev_t, dev)
1065 		__field(xfs_ino_t, ino)
1066 		__field(xfs_fsize_t, size)
1067 		__field(xfs_fsize_t, new_size)
1068 	),
1069 	TP_fast_assign(
1070 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1071 		__entry->ino = ip->i_ino;
1072 		__entry->size = ip->i_d.di_size;
1073 		__entry->new_size = new_size;
1074 	),
1075 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx",
1076 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1077 		  __entry->ino,
1078 		  __entry->size,
1079 		  __entry->new_size)
1080 )
1081 
1082 #define DEFINE_ITRUNC_EVENT(name) \
1083 DEFINE_EVENT(xfs_itrunc_class, name, \
1084 	TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), \
1085 	TP_ARGS(ip, new_size))
1086 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_start);
1087 DEFINE_ITRUNC_EVENT(xfs_itruncate_extents_end);
1088 
1089 TRACE_EVENT(xfs_pagecache_inval,
1090 	TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),
1091 	TP_ARGS(ip, start, finish),
1092 	TP_STRUCT__entry(
1093 		__field(dev_t, dev)
1094 		__field(xfs_ino_t, ino)
1095 		__field(xfs_fsize_t, size)
1096 		__field(xfs_off_t, start)
1097 		__field(xfs_off_t, finish)
1098 	),
1099 	TP_fast_assign(
1100 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1101 		__entry->ino = ip->i_ino;
1102 		__entry->size = ip->i_d.di_size;
1103 		__entry->start = start;
1104 		__entry->finish = finish;
1105 	),
1106 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx start 0x%llx finish 0x%llx",
1107 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1108 		  __entry->ino,
1109 		  __entry->size,
1110 		  __entry->start,
1111 		  __entry->finish)
1112 );
1113 
1114 TRACE_EVENT(xfs_bunmap,
1115 	TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t len,
1116 		 int flags, unsigned long caller_ip),
1117 	TP_ARGS(ip, bno, len, flags, caller_ip),
1118 	TP_STRUCT__entry(
1119 		__field(dev_t, dev)
1120 		__field(xfs_ino_t, ino)
1121 		__field(xfs_fsize_t, size)
1122 		__field(xfs_fileoff_t, bno)
1123 		__field(xfs_filblks_t, len)
1124 		__field(unsigned long, caller_ip)
1125 		__field(int, flags)
1126 	),
1127 	TP_fast_assign(
1128 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1129 		__entry->ino = ip->i_ino;
1130 		__entry->size = ip->i_d.di_size;
1131 		__entry->bno = bno;
1132 		__entry->len = len;
1133 		__entry->caller_ip = caller_ip;
1134 		__entry->flags = flags;
1135 	),
1136 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx bno 0x%llx len 0x%llx"
1137 		  "flags %s caller %pf",
1138 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1139 		  __entry->ino,
1140 		  __entry->size,
1141 		  __entry->bno,
1142 		  __entry->len,
1143 		  __print_flags(__entry->flags, "|", XFS_BMAPI_FLAGS),
1144 		  (void *)__entry->caller_ip)
1145 
1146 );
1147 
1148 DECLARE_EVENT_CLASS(xfs_busy_class,
1149 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1150 		 xfs_agblock_t agbno, xfs_extlen_t len),
1151 	TP_ARGS(mp, agno, agbno, len),
1152 	TP_STRUCT__entry(
1153 		__field(dev_t, dev)
1154 		__field(xfs_agnumber_t, agno)
1155 		__field(xfs_agblock_t, agbno)
1156 		__field(xfs_extlen_t, len)
1157 	),
1158 	TP_fast_assign(
1159 		__entry->dev = mp->m_super->s_dev;
1160 		__entry->agno = agno;
1161 		__entry->agbno = agbno;
1162 		__entry->len = len;
1163 	),
1164 	TP_printk("dev %d:%d agno %u agbno %u len %u",
1165 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1166 		  __entry->agno,
1167 		  __entry->agbno,
1168 		  __entry->len)
1169 );
1170 #define DEFINE_BUSY_EVENT(name) \
1171 DEFINE_EVENT(xfs_busy_class, name, \
1172 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1173 		 xfs_agblock_t agbno, xfs_extlen_t len), \
1174 	TP_ARGS(mp, agno, agbno, len))
1175 DEFINE_BUSY_EVENT(xfs_alloc_busy);
1176 DEFINE_BUSY_EVENT(xfs_alloc_busy_enomem);
1177 DEFINE_BUSY_EVENT(xfs_alloc_busy_force);
1178 DEFINE_BUSY_EVENT(xfs_alloc_busy_reuse);
1179 DEFINE_BUSY_EVENT(xfs_alloc_busy_clear);
1180 
1181 TRACE_EVENT(xfs_alloc_busy_trim,
1182 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1183 		 xfs_agblock_t agbno, xfs_extlen_t len,
1184 		 xfs_agblock_t tbno, xfs_extlen_t tlen),
1185 	TP_ARGS(mp, agno, agbno, len, tbno, tlen),
1186 	TP_STRUCT__entry(
1187 		__field(dev_t, dev)
1188 		__field(xfs_agnumber_t, agno)
1189 		__field(xfs_agblock_t, agbno)
1190 		__field(xfs_extlen_t, len)
1191 		__field(xfs_agblock_t, tbno)
1192 		__field(xfs_extlen_t, tlen)
1193 	),
1194 	TP_fast_assign(
1195 		__entry->dev = mp->m_super->s_dev;
1196 		__entry->agno = agno;
1197 		__entry->agbno = agbno;
1198 		__entry->len = len;
1199 		__entry->tbno = tbno;
1200 		__entry->tlen = tlen;
1201 	),
1202 	TP_printk("dev %d:%d agno %u agbno %u len %u tbno %u tlen %u",
1203 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1204 		  __entry->agno,
1205 		  __entry->agbno,
1206 		  __entry->len,
1207 		  __entry->tbno,
1208 		  __entry->tlen)
1209 );
1210 
1211 TRACE_EVENT(xfs_trans_commit_lsn,
1212 	TP_PROTO(struct xfs_trans *trans),
1213 	TP_ARGS(trans),
1214 	TP_STRUCT__entry(
1215 		__field(dev_t, dev)
1216 		__field(struct xfs_trans *, tp)
1217 		__field(xfs_lsn_t, lsn)
1218 	),
1219 	TP_fast_assign(
1220 		__entry->dev = trans->t_mountp->m_super->s_dev;
1221 		__entry->tp = trans;
1222 		__entry->lsn = trans->t_commit_lsn;
1223 	),
1224 	TP_printk("dev %d:%d trans 0x%p commit_lsn 0x%llx",
1225 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1226 		  __entry->tp,
1227 		  __entry->lsn)
1228 );
1229 
1230 TRACE_EVENT(xfs_agf,
1231 	TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags,
1232 		 unsigned long caller_ip),
1233 	TP_ARGS(mp, agf, flags, caller_ip),
1234 	TP_STRUCT__entry(
1235 		__field(dev_t, dev)
1236 		__field(xfs_agnumber_t, agno)
1237 		__field(int, flags)
1238 		__field(__u32, length)
1239 		__field(__u32, bno_root)
1240 		__field(__u32, cnt_root)
1241 		__field(__u32, bno_level)
1242 		__field(__u32, cnt_level)
1243 		__field(__u32, flfirst)
1244 		__field(__u32, fllast)
1245 		__field(__u32, flcount)
1246 		__field(__u32, freeblks)
1247 		__field(__u32, longest)
1248 		__field(unsigned long, caller_ip)
1249 	),
1250 	TP_fast_assign(
1251 		__entry->dev = mp->m_super->s_dev;
1252 		__entry->agno = be32_to_cpu(agf->agf_seqno),
1253 		__entry->flags = flags;
1254 		__entry->length = be32_to_cpu(agf->agf_length),
1255 		__entry->bno_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
1256 		__entry->cnt_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
1257 		__entry->bno_level =
1258 				be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
1259 		__entry->cnt_level =
1260 				be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
1261 		__entry->flfirst = be32_to_cpu(agf->agf_flfirst),
1262 		__entry->fllast = be32_to_cpu(agf->agf_fllast),
1263 		__entry->flcount = be32_to_cpu(agf->agf_flcount),
1264 		__entry->freeblks = be32_to_cpu(agf->agf_freeblks),
1265 		__entry->longest = be32_to_cpu(agf->agf_longest);
1266 		__entry->caller_ip = caller_ip;
1267 	),
1268 	TP_printk("dev %d:%d agno %u flags %s length %u roots b %u c %u "
1269 		  "levels b %u c %u flfirst %u fllast %u flcount %u "
1270 		  "freeblks %u longest %u caller %pf",
1271 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1272 		  __entry->agno,
1273 		  __print_flags(__entry->flags, "|", XFS_AGF_FLAGS),
1274 		  __entry->length,
1275 		  __entry->bno_root,
1276 		  __entry->cnt_root,
1277 		  __entry->bno_level,
1278 		  __entry->cnt_level,
1279 		  __entry->flfirst,
1280 		  __entry->fllast,
1281 		  __entry->flcount,
1282 		  __entry->freeblks,
1283 		  __entry->longest,
1284 		  (void *)__entry->caller_ip)
1285 );
1286 
1287 TRACE_EVENT(xfs_free_extent,
1288 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
1289 		 xfs_extlen_t len, bool isfl, int haveleft, int haveright),
1290 	TP_ARGS(mp, agno, agbno, len, isfl, haveleft, haveright),
1291 	TP_STRUCT__entry(
1292 		__field(dev_t, dev)
1293 		__field(xfs_agnumber_t, agno)
1294 		__field(xfs_agblock_t, agbno)
1295 		__field(xfs_extlen_t, len)
1296 		__field(int, isfl)
1297 		__field(int, haveleft)
1298 		__field(int, haveright)
1299 	),
1300 	TP_fast_assign(
1301 		__entry->dev = mp->m_super->s_dev;
1302 		__entry->agno = agno;
1303 		__entry->agbno = agbno;
1304 		__entry->len = len;
1305 		__entry->isfl = isfl;
1306 		__entry->haveleft = haveleft;
1307 		__entry->haveright = haveright;
1308 	),
1309 	TP_printk("dev %d:%d agno %u agbno %u len %u isfl %d %s",
1310 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1311 		  __entry->agno,
1312 		  __entry->agbno,
1313 		  __entry->len,
1314 		  __entry->isfl,
1315 		  __entry->haveleft ?
1316 			(__entry->haveright ? "both" : "left") :
1317 			(__entry->haveright ? "right" : "none"))
1318 
1319 );
1320 
1321 DECLARE_EVENT_CLASS(xfs_alloc_class,
1322 	TP_PROTO(struct xfs_alloc_arg *args),
1323 	TP_ARGS(args),
1324 	TP_STRUCT__entry(
1325 		__field(dev_t, dev)
1326 		__field(xfs_agnumber_t, agno)
1327 		__field(xfs_agblock_t, agbno)
1328 		__field(xfs_extlen_t, minlen)
1329 		__field(xfs_extlen_t, maxlen)
1330 		__field(xfs_extlen_t, mod)
1331 		__field(xfs_extlen_t, prod)
1332 		__field(xfs_extlen_t, minleft)
1333 		__field(xfs_extlen_t, total)
1334 		__field(xfs_extlen_t, alignment)
1335 		__field(xfs_extlen_t, minalignslop)
1336 		__field(xfs_extlen_t, len)
1337 		__field(short, type)
1338 		__field(short, otype)
1339 		__field(char, wasdel)
1340 		__field(char, wasfromfl)
1341 		__field(char, isfl)
1342 		__field(char, userdata)
1343 		__field(xfs_fsblock_t, firstblock)
1344 	),
1345 	TP_fast_assign(
1346 		__entry->dev = args->mp->m_super->s_dev;
1347 		__entry->agno = args->agno;
1348 		__entry->agbno = args->agbno;
1349 		__entry->minlen = args->minlen;
1350 		__entry->maxlen = args->maxlen;
1351 		__entry->mod = args->mod;
1352 		__entry->prod = args->prod;
1353 		__entry->minleft = args->minleft;
1354 		__entry->total = args->total;
1355 		__entry->alignment = args->alignment;
1356 		__entry->minalignslop = args->minalignslop;
1357 		__entry->len = args->len;
1358 		__entry->type = args->type;
1359 		__entry->otype = args->otype;
1360 		__entry->wasdel = args->wasdel;
1361 		__entry->wasfromfl = args->wasfromfl;
1362 		__entry->isfl = args->isfl;
1363 		__entry->userdata = args->userdata;
1364 		__entry->firstblock = args->firstblock;
1365 	),
1366 	TP_printk("dev %d:%d agno %u agbno %u minlen %u maxlen %u mod %u "
1367 		  "prod %u minleft %u total %u alignment %u minalignslop %u "
1368 		  "len %u type %s otype %s wasdel %d wasfromfl %d isfl %d "
1369 		  "userdata %d firstblock 0x%llx",
1370 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1371 		  __entry->agno,
1372 		  __entry->agbno,
1373 		  __entry->minlen,
1374 		  __entry->maxlen,
1375 		  __entry->mod,
1376 		  __entry->prod,
1377 		  __entry->minleft,
1378 		  __entry->total,
1379 		  __entry->alignment,
1380 		  __entry->minalignslop,
1381 		  __entry->len,
1382 		  __print_symbolic(__entry->type, XFS_ALLOC_TYPES),
1383 		  __print_symbolic(__entry->otype, XFS_ALLOC_TYPES),
1384 		  __entry->wasdel,
1385 		  __entry->wasfromfl,
1386 		  __entry->isfl,
1387 		  __entry->userdata,
1388 		  (unsigned long long)__entry->firstblock)
1389 )
1390 
1391 #define DEFINE_ALLOC_EVENT(name) \
1392 DEFINE_EVENT(xfs_alloc_class, name, \
1393 	TP_PROTO(struct xfs_alloc_arg *args), \
1394 	TP_ARGS(args))
1395 DEFINE_ALLOC_EVENT(xfs_alloc_exact_done);
1396 DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound);
1397 DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
1398 DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
1399 DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
1400 DEFINE_ALLOC_EVENT(xfs_alloc_near_greater);
1401 DEFINE_ALLOC_EVENT(xfs_alloc_near_lesser);
1402 DEFINE_ALLOC_EVENT(xfs_alloc_near_error);
1403 DEFINE_ALLOC_EVENT(xfs_alloc_near_noentry);
1404 DEFINE_ALLOC_EVENT(xfs_alloc_near_busy);
1405 DEFINE_ALLOC_EVENT(xfs_alloc_size_neither);
1406 DEFINE_ALLOC_EVENT(xfs_alloc_size_noentry);
1407 DEFINE_ALLOC_EVENT(xfs_alloc_size_nominleft);
1408 DEFINE_ALLOC_EVENT(xfs_alloc_size_done);
1409 DEFINE_ALLOC_EVENT(xfs_alloc_size_error);
1410 DEFINE_ALLOC_EVENT(xfs_alloc_size_busy);
1411 DEFINE_ALLOC_EVENT(xfs_alloc_small_freelist);
1412 DEFINE_ALLOC_EVENT(xfs_alloc_small_notenough);
1413 DEFINE_ALLOC_EVENT(xfs_alloc_small_done);
1414 DEFINE_ALLOC_EVENT(xfs_alloc_small_error);
1415 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_badargs);
1416 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_nofix);
1417 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp);
1418 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed);
1419 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed);
1420 
1421 DECLARE_EVENT_CLASS(xfs_da_class,
1422 	TP_PROTO(struct xfs_da_args *args),
1423 	TP_ARGS(args),
1424 	TP_STRUCT__entry(
1425 		__field(dev_t, dev)
1426 		__field(xfs_ino_t, ino)
1427 		__dynamic_array(char, name, args->namelen)
1428 		__field(int, namelen)
1429 		__field(xfs_dahash_t, hashval)
1430 		__field(xfs_ino_t, inumber)
1431 		__field(int, op_flags)
1432 	),
1433 	TP_fast_assign(
1434 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1435 		__entry->ino = args->dp->i_ino;
1436 		if (args->namelen)
1437 			memcpy(__get_str(name), args->name, args->namelen);
1438 		__entry->namelen = args->namelen;
1439 		__entry->hashval = args->hashval;
1440 		__entry->inumber = args->inumber;
1441 		__entry->op_flags = args->op_flags;
1442 	),
1443 	TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d hashval 0x%x "
1444 		  "inumber 0x%llx op_flags %s",
1445 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1446 		  __entry->ino,
1447 		  __entry->namelen,
1448 		  __entry->namelen ? __get_str(name) : NULL,
1449 		  __entry->namelen,
1450 		  __entry->hashval,
1451 		  __entry->inumber,
1452 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS))
1453 )
1454 
1455 #define DEFINE_DIR2_EVENT(name) \
1456 DEFINE_EVENT(xfs_da_class, name, \
1457 	TP_PROTO(struct xfs_da_args *args), \
1458 	TP_ARGS(args))
1459 DEFINE_DIR2_EVENT(xfs_dir2_sf_addname);
1460 DEFINE_DIR2_EVENT(xfs_dir2_sf_create);
1461 DEFINE_DIR2_EVENT(xfs_dir2_sf_lookup);
1462 DEFINE_DIR2_EVENT(xfs_dir2_sf_replace);
1463 DEFINE_DIR2_EVENT(xfs_dir2_sf_removename);
1464 DEFINE_DIR2_EVENT(xfs_dir2_sf_toino4);
1465 DEFINE_DIR2_EVENT(xfs_dir2_sf_toino8);
1466 DEFINE_DIR2_EVENT(xfs_dir2_sf_to_block);
1467 DEFINE_DIR2_EVENT(xfs_dir2_block_addname);
1468 DEFINE_DIR2_EVENT(xfs_dir2_block_lookup);
1469 DEFINE_DIR2_EVENT(xfs_dir2_block_replace);
1470 DEFINE_DIR2_EVENT(xfs_dir2_block_removename);
1471 DEFINE_DIR2_EVENT(xfs_dir2_block_to_sf);
1472 DEFINE_DIR2_EVENT(xfs_dir2_block_to_leaf);
1473 DEFINE_DIR2_EVENT(xfs_dir2_leaf_addname);
1474 DEFINE_DIR2_EVENT(xfs_dir2_leaf_lookup);
1475 DEFINE_DIR2_EVENT(xfs_dir2_leaf_replace);
1476 DEFINE_DIR2_EVENT(xfs_dir2_leaf_removename);
1477 DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_block);
1478 DEFINE_DIR2_EVENT(xfs_dir2_leaf_to_node);
1479 DEFINE_DIR2_EVENT(xfs_dir2_node_addname);
1480 DEFINE_DIR2_EVENT(xfs_dir2_node_lookup);
1481 DEFINE_DIR2_EVENT(xfs_dir2_node_replace);
1482 DEFINE_DIR2_EVENT(xfs_dir2_node_removename);
1483 DEFINE_DIR2_EVENT(xfs_dir2_node_to_leaf);
1484 
1485 #define DEFINE_ATTR_EVENT(name) \
1486 DEFINE_EVENT(xfs_da_class, name, \
1487 	TP_PROTO(struct xfs_da_args *args), \
1488 	TP_ARGS(args))
1489 DEFINE_ATTR_EVENT(xfs_attr_sf_add);
1490 DEFINE_ATTR_EVENT(xfs_attr_sf_addname);
1491 DEFINE_ATTR_EVENT(xfs_attr_sf_create);
1492 DEFINE_ATTR_EVENT(xfs_attr_sf_lookup);
1493 DEFINE_ATTR_EVENT(xfs_attr_sf_remove);
1494 DEFINE_ATTR_EVENT(xfs_attr_sf_removename);
1495 DEFINE_ATTR_EVENT(xfs_attr_sf_to_leaf);
1496 
1497 DEFINE_ATTR_EVENT(xfs_attr_leaf_add);
1498 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old);
1499 DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new);
1500 DEFINE_ATTR_EVENT(xfs_attr_leaf_addname);
1501 DEFINE_ATTR_EVENT(xfs_attr_leaf_create);
1502 DEFINE_ATTR_EVENT(xfs_attr_leaf_lookup);
1503 DEFINE_ATTR_EVENT(xfs_attr_leaf_replace);
1504 DEFINE_ATTR_EVENT(xfs_attr_leaf_removename);
1505 DEFINE_ATTR_EVENT(xfs_attr_leaf_split);
1506 DEFINE_ATTR_EVENT(xfs_attr_leaf_split_before);
1507 DEFINE_ATTR_EVENT(xfs_attr_leaf_split_after);
1508 DEFINE_ATTR_EVENT(xfs_attr_leaf_clearflag);
1509 DEFINE_ATTR_EVENT(xfs_attr_leaf_setflag);
1510 DEFINE_ATTR_EVENT(xfs_attr_leaf_flipflags);
1511 DEFINE_ATTR_EVENT(xfs_attr_leaf_to_sf);
1512 DEFINE_ATTR_EVENT(xfs_attr_leaf_to_node);
1513 DEFINE_ATTR_EVENT(xfs_attr_leaf_rebalance);
1514 DEFINE_ATTR_EVENT(xfs_attr_leaf_unbalance);
1515 
1516 DEFINE_ATTR_EVENT(xfs_attr_node_addname);
1517 DEFINE_ATTR_EVENT(xfs_attr_node_lookup);
1518 DEFINE_ATTR_EVENT(xfs_attr_node_replace);
1519 DEFINE_ATTR_EVENT(xfs_attr_node_removename);
1520 
1521 #define DEFINE_DA_EVENT(name) \
1522 DEFINE_EVENT(xfs_da_class, name, \
1523 	TP_PROTO(struct xfs_da_args *args), \
1524 	TP_ARGS(args))
1525 DEFINE_DA_EVENT(xfs_da_split);
1526 DEFINE_DA_EVENT(xfs_da_join);
1527 DEFINE_DA_EVENT(xfs_da_link_before);
1528 DEFINE_DA_EVENT(xfs_da_link_after);
1529 DEFINE_DA_EVENT(xfs_da_unlink_back);
1530 DEFINE_DA_EVENT(xfs_da_unlink_forward);
1531 DEFINE_DA_EVENT(xfs_da_root_split);
1532 DEFINE_DA_EVENT(xfs_da_root_join);
1533 DEFINE_DA_EVENT(xfs_da_node_add);
1534 DEFINE_DA_EVENT(xfs_da_node_create);
1535 DEFINE_DA_EVENT(xfs_da_node_split);
1536 DEFINE_DA_EVENT(xfs_da_node_remove);
1537 DEFINE_DA_EVENT(xfs_da_node_rebalance);
1538 DEFINE_DA_EVENT(xfs_da_node_unbalance);
1539 DEFINE_DA_EVENT(xfs_da_swap_lastblock);
1540 DEFINE_DA_EVENT(xfs_da_grow_inode);
1541 DEFINE_DA_EVENT(xfs_da_shrink_inode);
1542 
1543 DECLARE_EVENT_CLASS(xfs_dir2_space_class,
1544 	TP_PROTO(struct xfs_da_args *args, int idx),
1545 	TP_ARGS(args, idx),
1546 	TP_STRUCT__entry(
1547 		__field(dev_t, dev)
1548 		__field(xfs_ino_t, ino)
1549 		__field(int, op_flags)
1550 		__field(int, idx)
1551 	),
1552 	TP_fast_assign(
1553 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1554 		__entry->ino = args->dp->i_ino;
1555 		__entry->op_flags = args->op_flags;
1556 		__entry->idx = idx;
1557 	),
1558 	TP_printk("dev %d:%d ino 0x%llx op_flags %s index %d",
1559 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1560 		  __entry->ino,
1561 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
1562 		  __entry->idx)
1563 )
1564 
1565 #define DEFINE_DIR2_SPACE_EVENT(name) \
1566 DEFINE_EVENT(xfs_dir2_space_class, name, \
1567 	TP_PROTO(struct xfs_da_args *args, int idx), \
1568 	TP_ARGS(args, idx))
1569 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_add);
1570 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_leafn_remove);
1571 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_grow_inode);
1572 DEFINE_DIR2_SPACE_EVENT(xfs_dir2_shrink_inode);
1573 
1574 TRACE_EVENT(xfs_dir2_leafn_moveents,
1575 	TP_PROTO(struct xfs_da_args *args, int src_idx, int dst_idx, int count),
1576 	TP_ARGS(args, src_idx, dst_idx, count),
1577 	TP_STRUCT__entry(
1578 		__field(dev_t, dev)
1579 		__field(xfs_ino_t, ino)
1580 		__field(int, op_flags)
1581 		__field(int, src_idx)
1582 		__field(int, dst_idx)
1583 		__field(int, count)
1584 	),
1585 	TP_fast_assign(
1586 		__entry->dev = VFS_I(args->dp)->i_sb->s_dev;
1587 		__entry->ino = args->dp->i_ino;
1588 		__entry->op_flags = args->op_flags;
1589 		__entry->src_idx = src_idx;
1590 		__entry->dst_idx = dst_idx;
1591 		__entry->count = count;
1592 	),
1593 	TP_printk("dev %d:%d ino 0x%llx op_flags %s "
1594 		  "src_idx %d dst_idx %d count %d",
1595 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1596 		  __entry->ino,
1597 		  __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
1598 		  __entry->src_idx,
1599 		  __entry->dst_idx,
1600 		  __entry->count)
1601 );
1602 
1603 #define XFS_SWAPEXT_INODES \
1604 	{ 0,	"target" }, \
1605 	{ 1,	"temp" }
1606 
1607 #define XFS_INODE_FORMAT_STR \
1608 	{ 0,	"invalid" }, \
1609 	{ 1,	"local" }, \
1610 	{ 2,	"extent" }, \
1611 	{ 3,	"btree" }
1612 
1613 DECLARE_EVENT_CLASS(xfs_swap_extent_class,
1614 	TP_PROTO(struct xfs_inode *ip, int which),
1615 	TP_ARGS(ip, which),
1616 	TP_STRUCT__entry(
1617 		__field(dev_t, dev)
1618 		__field(int, which)
1619 		__field(xfs_ino_t, ino)
1620 		__field(int, format)
1621 		__field(int, nex)
1622 		__field(int, broot_size)
1623 		__field(int, fork_off)
1624 	),
1625 	TP_fast_assign(
1626 		__entry->dev = VFS_I(ip)->i_sb->s_dev;
1627 		__entry->which = which;
1628 		__entry->ino = ip->i_ino;
1629 		__entry->format = ip->i_d.di_format;
1630 		__entry->nex = ip->i_d.di_nextents;
1631 		__entry->broot_size = ip->i_df.if_broot_bytes;
1632 		__entry->fork_off = XFS_IFORK_BOFF(ip);
1633 	),
1634 	TP_printk("dev %d:%d ino 0x%llx (%s), %s format, num_extents %d, "
1635 		  "broot size %d, fork offset %d",
1636 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1637 		  __entry->ino,
1638 		  __print_symbolic(__entry->which, XFS_SWAPEXT_INODES),
1639 		  __print_symbolic(__entry->format, XFS_INODE_FORMAT_STR),
1640 		  __entry->nex,
1641 		  __entry->broot_size,
1642 		  __entry->fork_off)
1643 )
1644 
1645 #define DEFINE_SWAPEXT_EVENT(name) \
1646 DEFINE_EVENT(xfs_swap_extent_class, name, \
1647 	TP_PROTO(struct xfs_inode *ip, int which), \
1648 	TP_ARGS(ip, which))
1649 
1650 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_before);
1651 DEFINE_SWAPEXT_EVENT(xfs_swap_extent_after);
1652 
1653 DECLARE_EVENT_CLASS(xfs_log_recover_item_class,
1654 	TP_PROTO(struct log *log, struct xlog_recover *trans,
1655 		struct xlog_recover_item *item, int pass),
1656 	TP_ARGS(log, trans, item, pass),
1657 	TP_STRUCT__entry(
1658 		__field(dev_t, dev)
1659 		__field(unsigned long, item)
1660 		__field(xlog_tid_t, tid)
1661 		__field(int, type)
1662 		__field(int, pass)
1663 		__field(int, count)
1664 		__field(int, total)
1665 	),
1666 	TP_fast_assign(
1667 		__entry->dev = log->l_mp->m_super->s_dev;
1668 		__entry->item = (unsigned long)item;
1669 		__entry->tid = trans->r_log_tid;
1670 		__entry->type = ITEM_TYPE(item);
1671 		__entry->pass = pass;
1672 		__entry->count = item->ri_cnt;
1673 		__entry->total = item->ri_total;
1674 	),
1675 	TP_printk("dev %d:%d trans 0x%x, pass %d, item 0x%p, item type %s "
1676 		  "item region count/total %d/%d",
1677 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1678 		  __entry->tid,
1679 		  __entry->pass,
1680 		  (void *)__entry->item,
1681 		  __print_symbolic(__entry->type, XFS_LI_TYPE_DESC),
1682 		  __entry->count,
1683 		  __entry->total)
1684 )
1685 
1686 #define DEFINE_LOG_RECOVER_ITEM(name) \
1687 DEFINE_EVENT(xfs_log_recover_item_class, name, \
1688 	TP_PROTO(struct log *log, struct xlog_recover *trans, \
1689 		struct xlog_recover_item *item, int pass), \
1690 	TP_ARGS(log, trans, item, pass))
1691 
1692 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add);
1693 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_add_cont);
1694 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_head);
1695 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_reorder_tail);
1696 DEFINE_LOG_RECOVER_ITEM(xfs_log_recover_item_recover);
1697 
1698 DECLARE_EVENT_CLASS(xfs_log_recover_buf_item_class,
1699 	TP_PROTO(struct log *log, struct xfs_buf_log_format *buf_f),
1700 	TP_ARGS(log, buf_f),
1701 	TP_STRUCT__entry(
1702 		__field(dev_t, dev)
1703 		__field(__int64_t, blkno)
1704 		__field(unsigned short, len)
1705 		__field(unsigned short, flags)
1706 		__field(unsigned short, size)
1707 		__field(unsigned int, map_size)
1708 	),
1709 	TP_fast_assign(
1710 		__entry->dev = log->l_mp->m_super->s_dev;
1711 		__entry->blkno = buf_f->blf_blkno;
1712 		__entry->len = buf_f->blf_len;
1713 		__entry->flags = buf_f->blf_flags;
1714 		__entry->size = buf_f->blf_size;
1715 		__entry->map_size = buf_f->blf_map_size;
1716 	),
1717 	TP_printk("dev %d:%d blkno 0x%llx, len %u, flags 0x%x, size %d, "
1718 			"map_size %d",
1719 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1720 		  __entry->blkno,
1721 		  __entry->len,
1722 		  __entry->flags,
1723 		  __entry->size,
1724 		  __entry->map_size)
1725 )
1726 
1727 #define DEFINE_LOG_RECOVER_BUF_ITEM(name) \
1728 DEFINE_EVENT(xfs_log_recover_buf_item_class, name, \
1729 	TP_PROTO(struct log *log, struct xfs_buf_log_format *buf_f), \
1730 	TP_ARGS(log, buf_f))
1731 
1732 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_not_cancel);
1733 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel);
1734 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_add);
1735 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_cancel_ref_inc);
1736 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_recover);
1737 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_inode_buf);
1738 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_reg_buf);
1739 DEFINE_LOG_RECOVER_BUF_ITEM(xfs_log_recover_buf_dquot_buf);
1740 
1741 DECLARE_EVENT_CLASS(xfs_log_recover_ino_item_class,
1742 	TP_PROTO(struct log *log, struct xfs_inode_log_format *in_f),
1743 	TP_ARGS(log, in_f),
1744 	TP_STRUCT__entry(
1745 		__field(dev_t, dev)
1746 		__field(xfs_ino_t, ino)
1747 		__field(unsigned short, size)
1748 		__field(int, fields)
1749 		__field(unsigned short, asize)
1750 		__field(unsigned short, dsize)
1751 		__field(__int64_t, blkno)
1752 		__field(int, len)
1753 		__field(int, boffset)
1754 	),
1755 	TP_fast_assign(
1756 		__entry->dev = log->l_mp->m_super->s_dev;
1757 		__entry->ino = in_f->ilf_ino;
1758 		__entry->size = in_f->ilf_size;
1759 		__entry->fields = in_f->ilf_fields;
1760 		__entry->asize = in_f->ilf_asize;
1761 		__entry->dsize = in_f->ilf_dsize;
1762 		__entry->blkno = in_f->ilf_blkno;
1763 		__entry->len = in_f->ilf_len;
1764 		__entry->boffset = in_f->ilf_boffset;
1765 	),
1766 	TP_printk("dev %d:%d ino 0x%llx, size %u, fields 0x%x, asize %d, "
1767 			"dsize %d, blkno 0x%llx, len %d, boffset %d",
1768 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1769 		  __entry->ino,
1770 		  __entry->size,
1771 		  __entry->fields,
1772 		  __entry->asize,
1773 		  __entry->dsize,
1774 		  __entry->blkno,
1775 		  __entry->len,
1776 		  __entry->boffset)
1777 )
1778 #define DEFINE_LOG_RECOVER_INO_ITEM(name) \
1779 DEFINE_EVENT(xfs_log_recover_ino_item_class, name, \
1780 	TP_PROTO(struct log *log, struct xfs_inode_log_format *in_f), \
1781 	TP_ARGS(log, in_f))
1782 
1783 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_recover);
1784 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_cancel);
1785 DEFINE_LOG_RECOVER_INO_ITEM(xfs_log_recover_inode_skip);
1786 
1787 DECLARE_EVENT_CLASS(xfs_discard_class,
1788 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
1789 		 xfs_agblock_t agbno, xfs_extlen_t len),
1790 	TP_ARGS(mp, agno, agbno, len),
1791 	TP_STRUCT__entry(
1792 		__field(dev_t, dev)
1793 		__field(xfs_agnumber_t, agno)
1794 		__field(xfs_agblock_t, agbno)
1795 		__field(xfs_extlen_t, len)
1796 	),
1797 	TP_fast_assign(
1798 		__entry->dev = mp->m_super->s_dev;
1799 		__entry->agno = agno;
1800 		__entry->agbno = agbno;
1801 		__entry->len = len;
1802 	),
1803 	TP_printk("dev %d:%d agno %u agbno %u len %u\n",
1804 		  MAJOR(__entry->dev), MINOR(__entry->dev),
1805 		  __entry->agno,
1806 		  __entry->agbno,
1807 		  __entry->len)
1808 )
1809 
1810 #define DEFINE_DISCARD_EVENT(name) \
1811 DEFINE_EVENT(xfs_discard_class, name, \
1812 	TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
1813 		 xfs_agblock_t agbno, xfs_extlen_t len), \
1814 	TP_ARGS(mp, agno, agbno, len))
1815 DEFINE_DISCARD_EVENT(xfs_discard_extent);
1816 DEFINE_DISCARD_EVENT(xfs_discard_toosmall);
1817 DEFINE_DISCARD_EVENT(xfs_discard_exclude);
1818 DEFINE_DISCARD_EVENT(xfs_discard_busy);
1819 
1820 #endif /* _TRACE_XFS_H */
1821 
1822 #undef TRACE_INCLUDE_PATH
1823 #define TRACE_INCLUDE_PATH .
1824 #define TRACE_INCLUDE_FILE xfs_trace
1825 #include <trace/define_trace.h>
1826