2 #define TRACE_SYSTEM f2fs
4 #if !defined(_TRACE_F2FS_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/tracepoint.h>
9 #define show_dev(entry) MAJOR(entry->dev), MINOR(entry->dev)
10 #define show_dev_ino(entry) show_dev(entry), (unsigned long)entry->ino
12 #define show_block_type(type) \
13 __print_symbolic(type, \
17 { META_FLUSH, "META_FLUSH" })
19 #define F2FS_BIO_MASK(t) (t & (READA | WRITE_FLUSH_FUA))
20 #define F2FS_BIO_EXTRA_MASK(t) (t & (REQ_META | REQ_PRIO))
22 #define show_bio_type(type) show_bio_base(type), show_bio_extra(type)
24 #define show_bio_base(type) \
25 __print_symbolic(F2FS_BIO_MASK(type), \
27 { READA, "READAHEAD" }, \
28 { READ_SYNC, "READ_SYNC" }, \
30 { WRITE_SYNC, "WRITE_SYNC" }, \
31 { WRITE_FLUSH, "WRITE_FLUSH" }, \
32 { WRITE_FUA, "WRITE_FUA" }, \
33 { WRITE_FLUSH_FUA, "WRITE_FLUSH_FUA" })
35 #define show_bio_extra(type) \
36 __print_symbolic(F2FS_BIO_EXTRA_MASK(type), \
37 { REQ_META, "(M)" }, \
38 { REQ_PRIO, "(P)" }, \
39 { REQ_META | REQ_PRIO, "(MP)" }, \
42 #define show_data_type(type) \
43 __print_symbolic(type, \
44 { CURSEG_HOT_DATA, "Hot DATA" }, \
45 { CURSEG_WARM_DATA, "Warm DATA" }, \
46 { CURSEG_COLD_DATA, "Cold DATA" }, \
47 { CURSEG_HOT_NODE, "Hot NODE" }, \
48 { CURSEG_WARM_NODE, "Warm NODE" }, \
49 { CURSEG_COLD_NODE, "Cold NODE" }, \
50 { NO_CHECK_TYPE, "No TYPE" })
52 #define show_file_type(type) \
53 __print_symbolic(type, \
57 #define show_gc_type(type) \
58 __print_symbolic(type, \
59 { FG_GC, "Foreground GC" }, \
60 { BG_GC, "Background GC" })
62 #define show_alloc_mode(type) \
63 __print_symbolic(type, \
64 { LFS, "LFS-mode" }, \
67 #define show_victim_policy(type) \
68 __print_symbolic(type, \
69 { GC_GREEDY, "Greedy" }, \
70 { GC_CB, "Cost-Benefit" })
72 struct victim_sel_policy
;
74 DECLARE_EVENT_CLASS(f2fs__inode
,
76 TP_PROTO(struct inode
*inode
),
84 __field(umode_t
, mode
)
86 __field(unsigned int, nlink
)
87 __field(blkcnt_t
, blocks
)
92 __entry
->dev
= inode
->i_sb
->s_dev
;
93 __entry
->ino
= inode
->i_ino
;
94 __entry
->pino
= F2FS_I(inode
)->i_pino
;
95 __entry
->mode
= inode
->i_mode
;
96 __entry
->nlink
= inode
->i_nlink
;
97 __entry
->size
= inode
->i_size
;
98 __entry
->blocks
= inode
->i_blocks
;
99 __entry
->advise
= F2FS_I(inode
)->i_advise
;
102 TP_printk("dev = (%d,%d), ino = %lu, pino = %lu, i_mode = 0x%hx, "
103 "i_size = %lld, i_nlink = %u, i_blocks = %llu, i_advise = 0x%x",
104 show_dev_ino(__entry
),
105 (unsigned long)__entry
->pino
,
108 (unsigned int)__entry
->nlink
,
109 (unsigned long long)__entry
->blocks
,
110 (unsigned char)__entry
->advise
)
113 DECLARE_EVENT_CLASS(f2fs__inode_exit
,
115 TP_PROTO(struct inode
*inode
, int ret
),
126 __entry
->dev
= inode
->i_sb
->s_dev
;
127 __entry
->ino
= inode
->i_ino
;
131 TP_printk("dev = (%d,%d), ino = %lu, ret = %d",
132 show_dev_ino(__entry
),
136 DEFINE_EVENT(f2fs__inode
, f2fs_sync_file_enter
,
138 TP_PROTO(struct inode
*inode
),
143 TRACE_EVENT(f2fs_sync_file_exit
,
145 TP_PROTO(struct inode
*inode
, bool need_cp
, int datasync
, int ret
),
147 TP_ARGS(inode
, need_cp
, datasync
, ret
),
152 __field(bool, need_cp
)
153 __field(int, datasync
)
158 __entry
->dev
= inode
->i_sb
->s_dev
;
159 __entry
->ino
= inode
->i_ino
;
160 __entry
->need_cp
= need_cp
;
161 __entry
->datasync
= datasync
;
165 TP_printk("dev = (%d,%d), ino = %lu, checkpoint is %s, "
166 "datasync = %d, ret = %d",
167 show_dev_ino(__entry
),
168 __entry
->need_cp
? "needed" : "not needed",
173 TRACE_EVENT(f2fs_sync_fs
,
175 TP_PROTO(struct super_block
*sb
, int wait
),
186 __entry
->dev
= sb
->s_dev
;
187 __entry
->dirty
= F2FS_SB(sb
)->s_dirty
;
188 __entry
->wait
= wait
;
191 TP_printk("dev = (%d,%d), superblock is %s, wait = %d",
193 __entry
->dirty
? "dirty" : "not dirty",
197 DEFINE_EVENT(f2fs__inode
, f2fs_iget
,
199 TP_PROTO(struct inode
*inode
),
204 DEFINE_EVENT(f2fs__inode_exit
, f2fs_iget_exit
,
206 TP_PROTO(struct inode
*inode
, int ret
),
211 DEFINE_EVENT(f2fs__inode
, f2fs_evict_inode
,
213 TP_PROTO(struct inode
*inode
),
218 DEFINE_EVENT(f2fs__inode_exit
, f2fs_new_inode
,
220 TP_PROTO(struct inode
*inode
, int ret
),
225 TRACE_EVENT(f2fs_unlink_enter
,
227 TP_PROTO(struct inode
*dir
, struct dentry
*dentry
),
229 TP_ARGS(dir
, dentry
),
234 __field(loff_t
, size
)
235 __field(blkcnt_t
, blocks
)
236 __field(const char *, name
)
240 __entry
->dev
= dir
->i_sb
->s_dev
;
241 __entry
->ino
= dir
->i_ino
;
242 __entry
->size
= dir
->i_size
;
243 __entry
->blocks
= dir
->i_blocks
;
244 __entry
->name
= dentry
->d_name
.name
;
247 TP_printk("dev = (%d,%d), dir ino = %lu, i_size = %lld, "
248 "i_blocks = %llu, name = %s",
249 show_dev_ino(__entry
),
251 (unsigned long long)__entry
->blocks
,
255 DEFINE_EVENT(f2fs__inode_exit
, f2fs_unlink_exit
,
257 TP_PROTO(struct inode
*inode
, int ret
),
262 DEFINE_EVENT(f2fs__inode
, f2fs_truncate
,
264 TP_PROTO(struct inode
*inode
),
269 TRACE_EVENT(f2fs_truncate_data_blocks_range
,
271 TP_PROTO(struct inode
*inode
, nid_t nid
, unsigned int ofs
, int free
),
273 TP_ARGS(inode
, nid
, ofs
, free
),
279 __field(unsigned int, ofs
)
284 __entry
->dev
= inode
->i_sb
->s_dev
;
285 __entry
->ino
= inode
->i_ino
;
288 __entry
->free
= free
;
291 TP_printk("dev = (%d,%d), ino = %lu, nid = %u, offset = %u, freed = %d",
292 show_dev_ino(__entry
),
293 (unsigned int)__entry
->nid
,
298 DECLARE_EVENT_CLASS(f2fs__truncate_op
,
300 TP_PROTO(struct inode
*inode
, u64 from
),
302 TP_ARGS(inode
, from
),
307 __field(loff_t
, size
)
308 __field(blkcnt_t
, blocks
)
313 __entry
->dev
= inode
->i_sb
->s_dev
;
314 __entry
->ino
= inode
->i_ino
;
315 __entry
->size
= inode
->i_size
;
316 __entry
->blocks
= inode
->i_blocks
;
317 __entry
->from
= from
;
320 TP_printk("dev = (%d,%d), ino = %lu, i_size = %lld, i_blocks = %llu, "
321 "start file offset = %llu",
322 show_dev_ino(__entry
),
324 (unsigned long long)__entry
->blocks
,
325 (unsigned long long)__entry
->from
)
328 DEFINE_EVENT(f2fs__truncate_op
, f2fs_truncate_blocks_enter
,
330 TP_PROTO(struct inode
*inode
, u64 from
),
335 DEFINE_EVENT(f2fs__inode_exit
, f2fs_truncate_blocks_exit
,
337 TP_PROTO(struct inode
*inode
, int ret
),
342 DEFINE_EVENT(f2fs__truncate_op
, f2fs_truncate_inode_blocks_enter
,
344 TP_PROTO(struct inode
*inode
, u64 from
),
349 DEFINE_EVENT(f2fs__inode_exit
, f2fs_truncate_inode_blocks_exit
,
351 TP_PROTO(struct inode
*inode
, int ret
),
356 DECLARE_EVENT_CLASS(f2fs__truncate_node
,
358 TP_PROTO(struct inode
*inode
, nid_t nid
, block_t blk_addr
),
360 TP_ARGS(inode
, nid
, blk_addr
),
366 __field(block_t
, blk_addr
)
370 __entry
->dev
= inode
->i_sb
->s_dev
;
371 __entry
->ino
= inode
->i_ino
;
373 __entry
->blk_addr
= blk_addr
;
376 TP_printk("dev = (%d,%d), ino = %lu, nid = %u, block_address = 0x%llx",
377 show_dev_ino(__entry
),
378 (unsigned int)__entry
->nid
,
379 (unsigned long long)__entry
->blk_addr
)
382 DEFINE_EVENT(f2fs__truncate_node
, f2fs_truncate_nodes_enter
,
384 TP_PROTO(struct inode
*inode
, nid_t nid
, block_t blk_addr
),
386 TP_ARGS(inode
, nid
, blk_addr
)
389 DEFINE_EVENT(f2fs__inode_exit
, f2fs_truncate_nodes_exit
,
391 TP_PROTO(struct inode
*inode
, int ret
),
396 DEFINE_EVENT(f2fs__truncate_node
, f2fs_truncate_node
,
398 TP_PROTO(struct inode
*inode
, nid_t nid
, block_t blk_addr
),
400 TP_ARGS(inode
, nid
, blk_addr
)
403 TRACE_EVENT(f2fs_truncate_partial_nodes
,
405 TP_PROTO(struct inode
*inode
, nid_t nid
[], int depth
, int err
),
407 TP_ARGS(inode
, nid
, depth
, err
),
412 __field(nid_t
, nid
[3])
418 __entry
->dev
= inode
->i_sb
->s_dev
;
419 __entry
->ino
= inode
->i_ino
;
420 __entry
->nid
[0] = nid
[0];
421 __entry
->nid
[1] = nid
[1];
422 __entry
->nid
[2] = nid
[2];
423 __entry
->depth
= depth
;
427 TP_printk("dev = (%d,%d), ino = %lu, "
428 "nid[0] = %u, nid[1] = %u, nid[2] = %u, depth = %d, err = %d",
429 show_dev_ino(__entry
),
430 (unsigned int)__entry
->nid
[0],
431 (unsigned int)__entry
->nid
[1],
432 (unsigned int)__entry
->nid
[2],
437 TRACE_EVENT_CONDITION(f2fs_submit_page_bio
,
439 TP_PROTO(struct page
*page
, sector_t blkaddr
, int type
),
441 TP_ARGS(page
, blkaddr
, type
),
443 TP_CONDITION(page
->mapping
),
448 __field(pgoff_t
, index
)
449 __field(sector_t
, blkaddr
)
454 __entry
->dev
= page
->mapping
->host
->i_sb
->s_dev
;
455 __entry
->ino
= page
->mapping
->host
->i_ino
;
456 __entry
->index
= page
->index
;
457 __entry
->blkaddr
= blkaddr
;
458 __entry
->type
= type
;
461 TP_printk("dev = (%d,%d), ino = %lu, page_index = 0x%lx, "
462 "blkaddr = 0x%llx, bio_type = %s%s",
463 show_dev_ino(__entry
),
464 (unsigned long)__entry
->index
,
465 (unsigned long long)__entry
->blkaddr
,
466 show_bio_type(__entry
->type
))
469 TRACE_EVENT(f2fs_get_data_block
,
470 TP_PROTO(struct inode
*inode
, sector_t iblock
,
471 struct buffer_head
*bh
, int ret
),
473 TP_ARGS(inode
, iblock
, bh
, ret
),
478 __field(sector_t
, iblock
)
479 __field(sector_t
, bh_start
)
480 __field(size_t, bh_size
)
485 __entry
->dev
= inode
->i_sb
->s_dev
;
486 __entry
->ino
= inode
->i_ino
;
487 __entry
->iblock
= iblock
;
488 __entry
->bh_start
= bh
->b_blocknr
;
489 __entry
->bh_size
= bh
->b_size
;
493 TP_printk("dev = (%d,%d), ino = %lu, file offset = %llu, "
494 "start blkaddr = 0x%llx, len = 0x%llx bytes, err = %d",
495 show_dev_ino(__entry
),
496 (unsigned long long)__entry
->iblock
,
497 (unsigned long long)__entry
->bh_start
,
498 (unsigned long long)__entry
->bh_size
,
502 TRACE_EVENT(f2fs_get_victim
,
504 TP_PROTO(struct super_block
*sb
, int type
, int gc_type
,
505 struct victim_sel_policy
*p
, unsigned int pre_victim
,
506 unsigned int prefree
, unsigned int free
),
508 TP_ARGS(sb
, type
, gc_type
, p
, pre_victim
, prefree
, free
),
513 __field(int, gc_type
)
514 __field(int, alloc_mode
)
515 __field(int, gc_mode
)
516 __field(unsigned int, victim
)
517 __field(unsigned int, ofs_unit
)
518 __field(unsigned int, pre_victim
)
519 __field(unsigned int, prefree
)
520 __field(unsigned int, free
)
524 __entry
->dev
= sb
->s_dev
;
525 __entry
->type
= type
;
526 __entry
->gc_type
= gc_type
;
527 __entry
->alloc_mode
= p
->alloc_mode
;
528 __entry
->gc_mode
= p
->gc_mode
;
529 __entry
->victim
= p
->min_segno
;
530 __entry
->ofs_unit
= p
->ofs_unit
;
531 __entry
->pre_victim
= pre_victim
;
532 __entry
->prefree
= prefree
;
533 __entry
->free
= free
;
536 TP_printk("dev = (%d,%d), type = %s, policy = (%s, %s, %s), victim = %u "
537 "ofs_unit = %u, pre_victim_secno = %d, prefree = %u, free = %u",
539 show_data_type(__entry
->type
),
540 show_gc_type(__entry
->gc_type
),
541 show_alloc_mode(__entry
->alloc_mode
),
542 show_victim_policy(__entry
->gc_mode
),
545 (int)__entry
->pre_victim
,
550 TRACE_EVENT(f2fs_fallocate
,
552 TP_PROTO(struct inode
*inode
, int mode
,
553 loff_t offset
, loff_t len
, int ret
),
555 TP_ARGS(inode
, mode
, offset
, len
, ret
),
561 __field(loff_t
, offset
)
563 __field(loff_t
, size
)
564 __field(blkcnt_t
, blocks
)
569 __entry
->dev
= inode
->i_sb
->s_dev
;
570 __entry
->ino
= inode
->i_ino
;
571 __entry
->mode
= mode
;
572 __entry
->offset
= offset
;
574 __entry
->size
= inode
->i_size
;
575 __entry
->blocks
= inode
->i_blocks
;
579 TP_printk("dev = (%d,%d), ino = %lu, mode = %x, offset = %lld, "
580 "len = %lld, i_size = %lld, i_blocks = %llu, ret = %d",
581 show_dev_ino(__entry
),
583 (unsigned long long)__entry
->offset
,
584 (unsigned long long)__entry
->len
,
585 (unsigned long long)__entry
->size
,
586 (unsigned long long)__entry
->blocks
,
590 TRACE_EVENT(f2fs_reserve_new_block
,
592 TP_PROTO(struct inode
*inode
, nid_t nid
, unsigned int ofs_in_node
),
594 TP_ARGS(inode
, nid
, ofs_in_node
),
599 __field(unsigned int, ofs_in_node
)
603 __entry
->dev
= inode
->i_sb
->s_dev
;
605 __entry
->ofs_in_node
= ofs_in_node
;
608 TP_printk("dev = (%d,%d), nid = %u, ofs_in_node = %u",
610 (unsigned int)__entry
->nid
,
611 __entry
->ofs_in_node
)
614 DECLARE_EVENT_CLASS(f2fs__submit_bio
,
616 TP_PROTO(struct super_block
*sb
, int rw
, int type
, struct bio
*bio
),
618 TP_ARGS(sb
, rw
, type
, bio
),
624 __field(sector_t
, sector
)
625 __field(unsigned int, size
)
629 __entry
->dev
= sb
->s_dev
;
631 __entry
->type
= type
;
632 __entry
->sector
= bio
->bi_iter
.bi_sector
;
633 __entry
->size
= bio
->bi_iter
.bi_size
;
636 TP_printk("dev = (%d,%d), %s%s, %s, sector = %lld, size = %u",
638 show_bio_type(__entry
->rw
),
639 show_block_type(__entry
->type
),
640 (unsigned long long)__entry
->sector
,
644 DEFINE_EVENT_CONDITION(f2fs__submit_bio
, f2fs_submit_write_bio
,
646 TP_PROTO(struct super_block
*sb
, int rw
, int type
, struct bio
*bio
),
648 TP_ARGS(sb
, rw
, type
, bio
),
653 DEFINE_EVENT_CONDITION(f2fs__submit_bio
, f2fs_submit_read_bio
,
655 TP_PROTO(struct super_block
*sb
, int rw
, int type
, struct bio
*bio
),
657 TP_ARGS(sb
, rw
, type
, bio
),
662 DECLARE_EVENT_CLASS(f2fs__page
,
664 TP_PROTO(struct page
*page
, int type
),
673 __field(pgoff_t
, index
)
678 __entry
->dev
= page
->mapping
->host
->i_sb
->s_dev
;
679 __entry
->ino
= page
->mapping
->host
->i_ino
;
680 __entry
->type
= type
;
681 __entry
->dir
= S_ISDIR(page
->mapping
->host
->i_mode
);
682 __entry
->index
= page
->index
;
683 __entry
->dirty
= PageDirty(page
);
686 TP_printk("dev = (%d,%d), ino = %lu, %s, %s, index = %lu, dirty = %d",
687 show_dev_ino(__entry
),
688 show_block_type(__entry
->type
),
689 show_file_type(__entry
->dir
),
690 (unsigned long)__entry
->index
,
694 DEFINE_EVENT(f2fs__page
, f2fs_set_page_dirty
,
696 TP_PROTO(struct page
*page
, int type
),
701 DEFINE_EVENT(f2fs__page
, f2fs_vm_page_mkwrite
,
703 TP_PROTO(struct page
*page
, int type
),
708 TRACE_EVENT(f2fs_submit_page_mbio
,
710 TP_PROTO(struct page
*page
, int rw
, int type
, block_t blk_addr
),
712 TP_ARGS(page
, rw
, type
, blk_addr
),
719 __field(pgoff_t
, index
)
720 __field(block_t
, block
)
724 __entry
->dev
= page
->mapping
->host
->i_sb
->s_dev
;
725 __entry
->ino
= page
->mapping
->host
->i_ino
;
727 __entry
->type
= type
;
728 __entry
->index
= page
->index
;
729 __entry
->block
= blk_addr
;
732 TP_printk("dev = (%d,%d), ino = %lu, %s%s, %s, index = %lu, blkaddr = 0x%llx",
733 show_dev_ino(__entry
),
734 show_bio_type(__entry
->rw
),
735 show_block_type(__entry
->type
),
736 (unsigned long)__entry
->index
,
737 (unsigned long long)__entry
->block
)
740 TRACE_EVENT(f2fs_write_checkpoint
,
742 TP_PROTO(struct super_block
*sb
, bool is_umount
, char *msg
),
744 TP_ARGS(sb
, is_umount
, msg
),
748 __field(bool, is_umount
)
753 __entry
->dev
= sb
->s_dev
;
754 __entry
->is_umount
= is_umount
;
758 TP_printk("dev = (%d,%d), checkpoint for %s, state = %s",
760 __entry
->is_umount
? "clean umount" : "consistency",
764 TRACE_EVENT(f2fs_issue_discard
,
766 TP_PROTO(struct super_block
*sb
, block_t blkstart
, block_t blklen
),
768 TP_ARGS(sb
, blkstart
, blklen
),
772 __field(block_t
, blkstart
)
773 __field(block_t
, blklen
)
777 __entry
->dev
= sb
->s_dev
;
778 __entry
->blkstart
= blkstart
;
779 __entry
->blklen
= blklen
;
782 TP_printk("dev = (%d,%d), blkstart = 0x%llx, blklen = 0x%llx",
784 (unsigned long long)__entry
->blkstart
,
785 (unsigned long long)__entry
->blklen
)
787 #endif /* _TRACE_F2FS_H */
789 /* This part must be outside protection */
790 #include <trace/define_trace.h>