2 #define TRACE_SYSTEM btrfs
4 #if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/writeback.h>
8 #include <linux/tracepoint.h>
14 struct btrfs_ordered_extent
;
15 struct btrfs_delayed_ref_node
;
16 struct btrfs_delayed_tree_ref
;
17 struct btrfs_delayed_data_ref
;
18 struct btrfs_delayed_ref_head
;
22 #define show_ref_type(type) \
23 __print_symbolic(type, \
24 { BTRFS_TREE_BLOCK_REF_KEY, "TREE_BLOCK_REF" }, \
25 { BTRFS_EXTENT_DATA_REF_KEY, "EXTENT_DATA_REF" }, \
26 { BTRFS_EXTENT_REF_V0_KEY, "EXTENT_REF_V0" }, \
27 { BTRFS_SHARED_BLOCK_REF_KEY, "SHARED_BLOCK_REF" }, \
28 { BTRFS_SHARED_DATA_REF_KEY, "SHARED_DATA_REF" })
30 #define __show_root_type(obj) \
31 __print_symbolic_u64(obj, \
32 { BTRFS_ROOT_TREE_OBJECTID, "ROOT_TREE" }, \
33 { BTRFS_EXTENT_TREE_OBJECTID, "EXTENT_TREE" }, \
34 { BTRFS_CHUNK_TREE_OBJECTID, "CHUNK_TREE" }, \
35 { BTRFS_DEV_TREE_OBJECTID, "DEV_TREE" }, \
36 { BTRFS_FS_TREE_OBJECTID, "FS_TREE" }, \
37 { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" }, \
38 { BTRFS_CSUM_TREE_OBJECTID, "CSUM_TREE" }, \
39 { BTRFS_TREE_LOG_OBJECTID, "TREE_LOG" }, \
40 { BTRFS_TREE_RELOC_OBJECTID, "TREE_RELOC" }, \
41 { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
43 #define show_root_type(obj) \
44 obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) || \
45 (obj <= BTRFS_CSUM_TREE_OBJECTID )) ? __show_root_type(obj) : "-"
47 TRACE_EVENT(btrfs_transaction_commit
,
49 TP_PROTO(struct btrfs_root
*root
),
54 __field( u64
, generation
)
55 __field( u64
, root_objectid
)
59 __entry
->generation
= root
->fs_info
->generation
;
60 __entry
->root_objectid
= root
->root_key
.objectid
;
63 TP_printk("root = %llu(%s), gen = %llu",
64 show_root_type(__entry
->root_objectid
),
65 (unsigned long long)__entry
->generation
)
68 DECLARE_EVENT_CLASS(btrfs__inode
,
70 TP_PROTO(struct inode
*inode
),
76 __field( blkcnt_t
, blocks
)
77 __field( u64
, disk_i_size
)
78 __field( u64
, generation
)
79 __field( u64
, last_trans
)
80 __field( u64
, logged_trans
)
81 __field( u64
, root_objectid
)
85 __entry
->ino
= inode
->i_ino
;
86 __entry
->blocks
= inode
->i_blocks
;
87 __entry
->disk_i_size
= BTRFS_I(inode
)->disk_i_size
;
88 __entry
->generation
= BTRFS_I(inode
)->generation
;
89 __entry
->last_trans
= BTRFS_I(inode
)->last_trans
;
90 __entry
->logged_trans
= BTRFS_I(inode
)->logged_trans
;
91 __entry
->root_objectid
=
92 BTRFS_I(inode
)->root
->root_key
.objectid
;
95 TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
96 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
97 show_root_type(__entry
->root_objectid
),
98 (unsigned long long)__entry
->generation
,
99 (unsigned long)__entry
->ino
,
100 (unsigned long long)__entry
->blocks
,
101 (unsigned long long)__entry
->disk_i_size
,
102 (unsigned long long)__entry
->last_trans
,
103 (unsigned long long)__entry
->logged_trans
)
106 DEFINE_EVENT(btrfs__inode
, btrfs_inode_new
,
108 TP_PROTO(struct inode
*inode
),
113 DEFINE_EVENT(btrfs__inode
, btrfs_inode_request
,
115 TP_PROTO(struct inode
*inode
),
120 DEFINE_EVENT(btrfs__inode
, btrfs_inode_evict
,
122 TP_PROTO(struct inode
*inode
),
127 #define __show_map_type(type) \
128 __print_symbolic_u64(type, \
129 { EXTENT_MAP_LAST_BYTE, "LAST_BYTE" }, \
130 { EXTENT_MAP_HOLE, "HOLE" }, \
131 { EXTENT_MAP_INLINE, "INLINE" }, \
132 { EXTENT_MAP_DELALLOC, "DELALLOC" })
134 #define show_map_type(type) \
135 type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" : __show_map_type(type)
137 #define show_map_flags(flag) \
138 __print_flags(flag, "|", \
139 { EXTENT_FLAG_PINNED, "PINNED" }, \
140 { EXTENT_FLAG_COMPRESSED, "COMPRESSED" }, \
141 { EXTENT_FLAG_VACANCY, "VACANCY" }, \
142 { EXTENT_FLAG_PREALLOC, "PREALLOC" })
144 TRACE_EVENT(btrfs_get_extent
,
146 TP_PROTO(struct btrfs_root
*root
, struct extent_map
*map
),
151 __field( u64
, root_objectid
)
152 __field( u64
, start
)
154 __field( u64
, orig_start
)
155 __field( u64
, block_start
)
156 __field( u64
, block_len
)
157 __field( unsigned long, flags
)
159 __field( unsigned int, compress_type
)
163 __entry
->root_objectid
= root
->root_key
.objectid
;
164 __entry
->start
= map
->start
;
165 __entry
->len
= map
->len
;
166 __entry
->orig_start
= map
->orig_start
;
167 __entry
->block_start
= map
->block_start
;
168 __entry
->block_len
= map
->block_len
;
169 __entry
->flags
= map
->flags
;
170 __entry
->refs
= atomic_read(&map
->refs
);
171 __entry
->compress_type
= map
->compress_type
;
174 TP_printk("root = %llu(%s), start = %llu, len = %llu, "
175 "orig_start = %llu, block_start = %llu(%s), "
176 "block_len = %llu, flags = %s, refs = %u, "
177 "compress_type = %u",
178 show_root_type(__entry
->root_objectid
),
179 (unsigned long long)__entry
->start
,
180 (unsigned long long)__entry
->len
,
181 (unsigned long long)__entry
->orig_start
,
182 show_map_type(__entry
->block_start
),
183 (unsigned long long)__entry
->block_len
,
184 show_map_flags(__entry
->flags
),
185 __entry
->refs
, __entry
->compress_type
)
188 #define show_ordered_flags(flags) \
189 __print_symbolic(flags, \
190 { BTRFS_ORDERED_IO_DONE, "IO_DONE" }, \
191 { BTRFS_ORDERED_COMPLETE, "COMPLETE" }, \
192 { BTRFS_ORDERED_NOCOW, "NOCOW" }, \
193 { BTRFS_ORDERED_COMPRESSED, "COMPRESSED" }, \
194 { BTRFS_ORDERED_PREALLOC, "PREALLOC" }, \
195 { BTRFS_ORDERED_DIRECT, "DIRECT" })
197 DECLARE_EVENT_CLASS(btrfs__ordered_extent
,
199 TP_PROTO(struct inode
*inode
, struct btrfs_ordered_extent
*ordered
),
201 TP_ARGS(inode
, ordered
),
204 __field( ino_t
, ino
)
205 __field( u64
, file_offset
)
206 __field( u64
, start
)
208 __field( u64
, disk_len
)
209 __field( u64
, bytes_left
)
210 __field( unsigned long, flags
)
211 __field( int, compress_type
)
213 __field( u64
, root_objectid
)
217 __entry
->ino
= inode
->i_ino
;
218 __entry
->file_offset
= ordered
->file_offset
;
219 __entry
->start
= ordered
->start
;
220 __entry
->len
= ordered
->len
;
221 __entry
->disk_len
= ordered
->disk_len
;
222 __entry
->bytes_left
= ordered
->bytes_left
;
223 __entry
->flags
= ordered
->flags
;
224 __entry
->compress_type
= ordered
->compress_type
;
225 __entry
->refs
= atomic_read(&ordered
->refs
);
226 __entry
->root_objectid
=
227 BTRFS_I(inode
)->root
->root_key
.objectid
;
230 TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
231 "start = %llu, len = %llu, disk_len = %llu, "
232 "bytes_left = %llu, flags = %s, compress_type = %d, "
234 show_root_type(__entry
->root_objectid
),
235 (unsigned long long)__entry
->ino
,
236 (unsigned long long)__entry
->file_offset
,
237 (unsigned long long)__entry
->start
,
238 (unsigned long long)__entry
->len
,
239 (unsigned long long)__entry
->disk_len
,
240 (unsigned long long)__entry
->bytes_left
,
241 show_ordered_flags(__entry
->flags
),
242 __entry
->compress_type
, __entry
->refs
)
245 DEFINE_EVENT(btrfs__ordered_extent
, btrfs_ordered_extent_add
,
247 TP_PROTO(struct inode
*inode
, struct btrfs_ordered_extent
*ordered
),
249 TP_ARGS(inode
, ordered
)
252 DEFINE_EVENT(btrfs__ordered_extent
, btrfs_ordered_extent_remove
,
254 TP_PROTO(struct inode
*inode
, struct btrfs_ordered_extent
*ordered
),
256 TP_ARGS(inode
, ordered
)
259 DEFINE_EVENT(btrfs__ordered_extent
, btrfs_ordered_extent_start
,
261 TP_PROTO(struct inode
*inode
, struct btrfs_ordered_extent
*ordered
),
263 TP_ARGS(inode
, ordered
)
266 DEFINE_EVENT(btrfs__ordered_extent
, btrfs_ordered_extent_put
,
268 TP_PROTO(struct inode
*inode
, struct btrfs_ordered_extent
*ordered
),
270 TP_ARGS(inode
, ordered
)
273 DECLARE_EVENT_CLASS(btrfs__writepage
,
275 TP_PROTO(struct page
*page
, struct inode
*inode
,
276 struct writeback_control
*wbc
),
278 TP_ARGS(page
, inode
, wbc
),
281 __field( ino_t
, ino
)
282 __field( pgoff_t
, index
)
283 __field( long, nr_to_write
)
284 __field( long, pages_skipped
)
285 __field( loff_t
, range_start
)
286 __field( loff_t
, range_end
)
287 __field( char, nonblocking
)
288 __field( char, for_kupdate
)
289 __field( char, for_reclaim
)
290 __field( char, range_cyclic
)
291 __field( pgoff_t
, writeback_index
)
292 __field( u64
, root_objectid
)
296 __entry
->ino
= inode
->i_ino
;
297 __entry
->index
= page
->index
;
298 __entry
->nr_to_write
= wbc
->nr_to_write
;
299 __entry
->pages_skipped
= wbc
->pages_skipped
;
300 __entry
->range_start
= wbc
->range_start
;
301 __entry
->range_end
= wbc
->range_end
;
302 __entry
->nonblocking
= wbc
->nonblocking
;
303 __entry
->for_kupdate
= wbc
->for_kupdate
;
304 __entry
->for_reclaim
= wbc
->for_reclaim
;
305 __entry
->range_cyclic
= wbc
->range_cyclic
;
306 __entry
->writeback_index
= inode
->i_mapping
->writeback_index
;
307 __entry
->root_objectid
=
308 BTRFS_I(inode
)->root
->root_key
.objectid
;
311 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
312 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
313 "range_end = %llu, nonblocking = %d, for_kupdate = %d, "
314 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
315 show_root_type(__entry
->root_objectid
),
316 (unsigned long)__entry
->ino
, __entry
->index
,
317 __entry
->nr_to_write
, __entry
->pages_skipped
,
318 __entry
->range_start
, __entry
->range_end
,
319 __entry
->nonblocking
, __entry
->for_kupdate
,
320 __entry
->for_reclaim
, __entry
->range_cyclic
,
321 (unsigned long)__entry
->writeback_index
)
324 DEFINE_EVENT(btrfs__writepage
, __extent_writepage
,
326 TP_PROTO(struct page
*page
, struct inode
*inode
,
327 struct writeback_control
*wbc
),
329 TP_ARGS(page
, inode
, wbc
)
332 TRACE_EVENT(btrfs_writepage_end_io_hook
,
334 TP_PROTO(struct page
*page
, u64 start
, u64 end
, int uptodate
),
336 TP_ARGS(page
, start
, end
, uptodate
),
339 __field( ino_t
, ino
)
340 __field( pgoff_t
, index
)
341 __field( u64
, start
)
343 __field( int, uptodate
)
344 __field( u64
, root_objectid
)
348 __entry
->ino
= page
->mapping
->host
->i_ino
;
349 __entry
->index
= page
->index
;
350 __entry
->start
= start
;
352 __entry
->uptodate
= uptodate
;
353 __entry
->root_objectid
=
354 BTRFS_I(page
->mapping
->host
)->root
->root_key
.objectid
;
357 TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
358 "end = %llu, uptodate = %d",
359 show_root_type(__entry
->root_objectid
),
360 (unsigned long)__entry
->ino
, (unsigned long)__entry
->index
,
361 (unsigned long long)__entry
->start
,
362 (unsigned long long)__entry
->end
, __entry
->uptodate
)
365 TRACE_EVENT(btrfs_sync_file
,
367 TP_PROTO(struct file
*file
, int datasync
),
369 TP_ARGS(file
, datasync
),
372 __field( ino_t
, ino
)
373 __field( ino_t
, parent
)
374 __field( int, datasync
)
375 __field( u64
, root_objectid
)
379 struct dentry
*dentry
= file
->f_path
.dentry
;
380 struct inode
*inode
= dentry
->d_inode
;
382 __entry
->ino
= inode
->i_ino
;
383 __entry
->parent
= dentry
->d_parent
->d_inode
->i_ino
;
384 __entry
->datasync
= datasync
;
385 __entry
->root_objectid
=
386 BTRFS_I(inode
)->root
->root_key
.objectid
;
389 TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
390 show_root_type(__entry
->root_objectid
),
391 (unsigned long)__entry
->ino
, (unsigned long)__entry
->parent
,
395 TRACE_EVENT(btrfs_sync_fs
,
406 __entry
->wait
= wait
;
409 TP_printk("wait = %d", __entry
->wait
)
412 #define show_ref_action(action) \
413 __print_symbolic(action, \
414 { BTRFS_ADD_DELAYED_REF, "ADD_DELAYED_REF" }, \
415 { BTRFS_DROP_DELAYED_REF, "DROP_DELAYED_REF" }, \
416 { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" }, \
417 { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
420 TRACE_EVENT(btrfs_delayed_tree_ref
,
422 TP_PROTO(struct btrfs_delayed_ref_node
*ref
,
423 struct btrfs_delayed_tree_ref
*full_ref
,
426 TP_ARGS(ref
, full_ref
, action
),
429 __field( u64
, bytenr
)
430 __field( u64
, num_bytes
)
431 __field( int, action
)
432 __field( u64
, parent
)
433 __field( u64
, ref_root
)
434 __field( int, level
)
439 __entry
->bytenr
= ref
->bytenr
;
440 __entry
->num_bytes
= ref
->num_bytes
;
441 __entry
->action
= action
;
442 __entry
->parent
= full_ref
->parent
;
443 __entry
->ref_root
= full_ref
->root
;
444 __entry
->level
= full_ref
->level
;
445 __entry
->type
= ref
->type
;
448 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
449 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
451 (unsigned long long)__entry
->bytenr
,
452 (unsigned long long)__entry
->num_bytes
,
453 show_ref_action(__entry
->action
),
454 show_root_type(__entry
->parent
),
455 show_root_type(__entry
->ref_root
),
456 __entry
->level
, show_ref_type(__entry
->type
))
459 TRACE_EVENT(btrfs_delayed_data_ref
,
461 TP_PROTO(struct btrfs_delayed_ref_node
*ref
,
462 struct btrfs_delayed_data_ref
*full_ref
,
465 TP_ARGS(ref
, full_ref
, action
),
468 __field( u64
, bytenr
)
469 __field( u64
, num_bytes
)
470 __field( int, action
)
471 __field( u64
, parent
)
472 __field( u64
, ref_root
)
473 __field( u64
, owner
)
474 __field( u64
, offset
)
479 __entry
->bytenr
= ref
->bytenr
;
480 __entry
->num_bytes
= ref
->num_bytes
;
481 __entry
->action
= action
;
482 __entry
->parent
= full_ref
->parent
;
483 __entry
->ref_root
= full_ref
->root
;
484 __entry
->owner
= full_ref
->objectid
;
485 __entry
->offset
= full_ref
->offset
;
486 __entry
->type
= ref
->type
;
489 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
490 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
491 "offset = %llu, type = %s",
492 (unsigned long long)__entry
->bytenr
,
493 (unsigned long long)__entry
->num_bytes
,
494 show_ref_action(__entry
->action
),
495 show_root_type(__entry
->parent
),
496 show_root_type(__entry
->ref_root
),
497 (unsigned long long)__entry
->owner
,
498 (unsigned long long)__entry
->offset
,
499 show_ref_type(__entry
->type
))
502 TRACE_EVENT(btrfs_delayed_ref_head
,
504 TP_PROTO(struct btrfs_delayed_ref_node
*ref
,
505 struct btrfs_delayed_ref_head
*head_ref
,
508 TP_ARGS(ref
, head_ref
, action
),
511 __field( u64
, bytenr
)
512 __field( u64
, num_bytes
)
513 __field( int, action
)
514 __field( int, is_data
)
518 __entry
->bytenr
= ref
->bytenr
;
519 __entry
->num_bytes
= ref
->num_bytes
;
520 __entry
->action
= action
;
521 __entry
->is_data
= head_ref
->is_data
;
524 TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
525 (unsigned long long)__entry
->bytenr
,
526 (unsigned long long)__entry
->num_bytes
,
527 show_ref_action(__entry
->action
),
531 #define show_chunk_type(type) \
532 __print_flags(type, "|", \
533 { BTRFS_BLOCK_GROUP_DATA, "DATA" }, \
534 { BTRFS_BLOCK_GROUP_SYSTEM, "SYSTEM"}, \
535 { BTRFS_BLOCK_GROUP_METADATA, "METADATA"}, \
536 { BTRFS_BLOCK_GROUP_RAID0, "RAID0" }, \
537 { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \
538 { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \
539 { BTRFS_BLOCK_GROUP_RAID10, "RAID10"})
541 DECLARE_EVENT_CLASS(btrfs__chunk
,
543 TP_PROTO(struct btrfs_root
*root
, struct map_lookup
*map
,
544 u64 offset
, u64 size
),
546 TP_ARGS(root
, map
, offset
, size
),
549 __field( int, num_stripes
)
551 __field( int, sub_stripes
)
552 __field( u64
, offset
)
554 __field( u64
, root_objectid
)
558 __entry
->num_stripes
= map
->num_stripes
;
559 __entry
->type
= map
->type
;
560 __entry
->sub_stripes
= map
->sub_stripes
;
561 __entry
->offset
= offset
;
562 __entry
->size
= size
;
563 __entry
->root_objectid
= root
->root_key
.objectid
;
566 TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
567 "num_stripes = %d, sub_stripes = %d, type = %s",
568 show_root_type(__entry
->root_objectid
),
569 (unsigned long long)__entry
->offset
,
570 (unsigned long long)__entry
->size
,
571 __entry
->num_stripes
, __entry
->sub_stripes
,
572 show_chunk_type(__entry
->type
))
575 DEFINE_EVENT(btrfs__chunk
, btrfs_chunk_alloc
,
577 TP_PROTO(struct btrfs_root
*root
, struct map_lookup
*map
,
578 u64 offset
, u64 size
),
580 TP_ARGS(root
, map
, offset
, size
)
583 DEFINE_EVENT(btrfs__chunk
, btrfs_chunk_free
,
585 TP_PROTO(struct btrfs_root
*root
, struct map_lookup
*map
,
586 u64 offset
, u64 size
),
588 TP_ARGS(root
, map
, offset
, size
)
591 TRACE_EVENT(btrfs_cow_block
,
593 TP_PROTO(struct btrfs_root
*root
, struct extent_buffer
*buf
,
594 struct extent_buffer
*cow
),
596 TP_ARGS(root
, buf
, cow
),
599 __field( u64
, root_objectid
)
600 __field( u64
, buf_start
)
602 __field( u64
, cow_start
)
603 __field( int, buf_level
)
604 __field( int, cow_level
)
608 __entry
->root_objectid
= root
->root_key
.objectid
;
609 __entry
->buf_start
= buf
->start
;
610 __entry
->refs
= atomic_read(&buf
->refs
);
611 __entry
->cow_start
= cow
->start
;
612 __entry
->buf_level
= btrfs_header_level(buf
);
613 __entry
->cow_level
= btrfs_header_level(cow
);
616 TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
617 "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
618 show_root_type(__entry
->root_objectid
),
620 (unsigned long long)__entry
->buf_start
,
622 (unsigned long long)__entry
->cow_start
,
626 DECLARE_EVENT_CLASS(btrfs__reserved_extent
,
628 TP_PROTO(struct btrfs_root
*root
, u64 start
, u64 len
),
630 TP_ARGS(root
, start
, len
),
633 __field( u64
, root_objectid
)
634 __field( u64
, start
)
639 __entry
->root_objectid
= root
->root_key
.objectid
;
640 __entry
->start
= start
;
644 TP_printk("root = %llu(%s), start = %llu, len = %llu",
645 show_root_type(__entry
->root_objectid
),
646 (unsigned long long)__entry
->start
,
647 (unsigned long long)__entry
->len
)
650 DEFINE_EVENT(btrfs__reserved_extent
, btrfs_reserved_extent_alloc
,
652 TP_PROTO(struct btrfs_root
*root
, u64 start
, u64 len
),
654 TP_ARGS(root
, start
, len
)
657 DEFINE_EVENT(btrfs__reserved_extent
, btrfs_reserved_extent_free
,
659 TP_PROTO(struct btrfs_root
*root
, u64 start
, u64 len
),
661 TP_ARGS(root
, start
, len
)
664 #endif /* _TRACE_BTRFS_H */
666 /* This part must be outside protection */
667 #include <trace/define_trace.h>