diff options
author | Chao Yu <chao2.yu@samsung.com> | 2015-02-05 04:59:59 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-03-03 12:58:47 -0500 |
commit | 1ec4610c522cc51219cc022ef120a928828fa934 (patch) | |
tree | bb287725a378bd5ebc4474bab98e2e95708ee527 | |
parent | 4bf6fd9fedf14a8bab75f3710cd63e7bc8928014 (diff) |
f2fs: add trace for rb-tree extent cache ops
This patch adds trace for lookup/update/shrink/destroy ops in rb-tree extent cache.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/data.c | 16 | ||||
-rw-r--r-- | include/trace/events/f2fs.h | 134 |
2 files changed, 148 insertions, 2 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index acdc0767f77c..d7ff4ca5be18 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c | |||
@@ -533,6 +533,8 @@ static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs, | |||
533 | if (is_inode_flag_set(F2FS_I(inode), FI_NO_EXTENT)) | 533 | if (is_inode_flag_set(F2FS_I(inode), FI_NO_EXTENT)) |
534 | return false; | 534 | return false; |
535 | 535 | ||
536 | trace_f2fs_lookup_extent_tree_start(inode, pgofs); | ||
537 | |||
536 | down_read(&sbi->extent_tree_lock); | 538 | down_read(&sbi->extent_tree_lock); |
537 | et = radix_tree_lookup(&sbi->extent_tree_root, inode->i_ino); | 539 | et = radix_tree_lookup(&sbi->extent_tree_root, inode->i_ino); |
538 | if (!et) { | 540 | if (!et) { |
@@ -555,6 +557,8 @@ static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs, | |||
555 | stat_inc_total_hit(sbi->sb); | 557 | stat_inc_total_hit(sbi->sb); |
556 | read_unlock(&et->lock); | 558 | read_unlock(&et->lock); |
557 | 559 | ||
560 | trace_f2fs_lookup_extent_tree_end(inode, pgofs, en); | ||
561 | |||
558 | atomic_dec(&et->refcount); | 562 | atomic_dec(&et->refcount); |
559 | return en ? true : false; | 563 | return en ? true : false; |
560 | } | 564 | } |
@@ -573,6 +577,8 @@ static void f2fs_update_extent_tree(struct inode *inode, pgoff_t fofs, | |||
573 | if (is_inode_flag_set(F2FS_I(inode), FI_NO_EXTENT)) | 577 | if (is_inode_flag_set(F2FS_I(inode), FI_NO_EXTENT)) |
574 | return; | 578 | return; |
575 | 579 | ||
580 | trace_f2fs_update_extent_tree(inode, fofs, blkaddr); | ||
581 | |||
576 | down_write(&sbi->extent_tree_lock); | 582 | down_write(&sbi->extent_tree_lock); |
577 | et = radix_tree_lookup(&sbi->extent_tree_root, ino); | 583 | et = radix_tree_lookup(&sbi->extent_tree_root, ino); |
578 | if (!et) { | 584 | if (!et) { |
@@ -665,6 +671,7 @@ void f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink) | |||
665 | struct radix_tree_iter iter; | 671 | struct radix_tree_iter iter; |
666 | void **slot; | 672 | void **slot; |
667 | unsigned int found; | 673 | unsigned int found; |
674 | unsigned int node_cnt = 0, tree_cnt = 0; | ||
668 | 675 | ||
669 | if (!test_opt(sbi, EXTENT_CACHE)) | 676 | if (!test_opt(sbi, EXTENT_CACHE)) |
670 | return; | 677 | return; |
@@ -691,7 +698,7 @@ void f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink) | |||
691 | 698 | ||
692 | atomic_inc(&et->refcount); | 699 | atomic_inc(&et->refcount); |
693 | write_lock(&et->lock); | 700 | write_lock(&et->lock); |
694 | __free_extent_tree(sbi, et, false); | 701 | node_cnt += __free_extent_tree(sbi, et, false); |
695 | write_unlock(&et->lock); | 702 | write_unlock(&et->lock); |
696 | atomic_dec(&et->refcount); | 703 | atomic_dec(&et->refcount); |
697 | } | 704 | } |
@@ -707,15 +714,19 @@ void f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink) | |||
707 | radix_tree_delete(&sbi->extent_tree_root, et->ino); | 714 | radix_tree_delete(&sbi->extent_tree_root, et->ino); |
708 | kmem_cache_free(extent_tree_slab, et); | 715 | kmem_cache_free(extent_tree_slab, et); |
709 | sbi->total_ext_tree--; | 716 | sbi->total_ext_tree--; |
717 | tree_cnt++; | ||
710 | } | 718 | } |
711 | } | 719 | } |
712 | up_write(&sbi->extent_tree_lock); | 720 | up_write(&sbi->extent_tree_lock); |
721 | |||
722 | trace_f2fs_shrink_extent_tree(sbi, node_cnt, tree_cnt); | ||
713 | } | 723 | } |
714 | 724 | ||
715 | void f2fs_destroy_extent_tree(struct inode *inode) | 725 | void f2fs_destroy_extent_tree(struct inode *inode) |
716 | { | 726 | { |
717 | struct f2fs_sb_info *sbi = F2FS_I_SB(inode); | 727 | struct f2fs_sb_info *sbi = F2FS_I_SB(inode); |
718 | struct extent_tree *et; | 728 | struct extent_tree *et; |
729 | unsigned int node_cnt = 0; | ||
719 | 730 | ||
720 | if (!test_opt(sbi, EXTENT_CACHE)) | 731 | if (!test_opt(sbi, EXTENT_CACHE)) |
721 | return; | 732 | return; |
@@ -731,7 +742,7 @@ void f2fs_destroy_extent_tree(struct inode *inode) | |||
731 | 742 | ||
732 | /* free all extent info belong to this extent tree */ | 743 | /* free all extent info belong to this extent tree */ |
733 | write_lock(&et->lock); | 744 | write_lock(&et->lock); |
734 | __free_extent_tree(sbi, et, true); | 745 | node_cnt = __free_extent_tree(sbi, et, true); |
735 | write_unlock(&et->lock); | 746 | write_unlock(&et->lock); |
736 | 747 | ||
737 | atomic_dec(&et->refcount); | 748 | atomic_dec(&et->refcount); |
@@ -749,6 +760,7 @@ void f2fs_destroy_extent_tree(struct inode *inode) | |||
749 | sbi->total_ext_tree--; | 760 | sbi->total_ext_tree--; |
750 | up_write(&sbi->extent_tree_lock); | 761 | up_write(&sbi->extent_tree_lock); |
751 | out: | 762 | out: |
763 | trace_f2fs_destroy_extent_tree(inode, node_cnt); | ||
752 | return; | 764 | return; |
753 | } | 765 | } |
754 | 766 | ||
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 5422dbfaf97d..09a56dc75f8d 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h | |||
@@ -1011,6 +1011,140 @@ TRACE_EVENT(f2fs_issue_flush, | |||
1011 | __entry->nobarrier ? "skip (nobarrier)" : "issue", | 1011 | __entry->nobarrier ? "skip (nobarrier)" : "issue", |
1012 | __entry->flush_merge ? " with flush_merge" : "") | 1012 | __entry->flush_merge ? " with flush_merge" : "") |
1013 | ); | 1013 | ); |
1014 | |||
1015 | TRACE_EVENT(f2fs_lookup_extent_tree_start, | ||
1016 | |||
1017 | TP_PROTO(struct inode *inode, unsigned int pgofs), | ||
1018 | |||
1019 | TP_ARGS(inode, pgofs), | ||
1020 | |||
1021 | TP_STRUCT__entry( | ||
1022 | __field(dev_t, dev) | ||
1023 | __field(ino_t, ino) | ||
1024 | __field(unsigned int, pgofs) | ||
1025 | ), | ||
1026 | |||
1027 | TP_fast_assign( | ||
1028 | __entry->dev = inode->i_sb->s_dev; | ||
1029 | __entry->ino = inode->i_ino; | ||
1030 | __entry->pgofs = pgofs; | ||
1031 | ), | ||
1032 | |||
1033 | TP_printk("dev = (%d,%d), ino = %lu, pgofs = %u", | ||
1034 | show_dev_ino(__entry), | ||
1035 | __entry->pgofs) | ||
1036 | ); | ||
1037 | |||
1038 | TRACE_EVENT_CONDITION(f2fs_lookup_extent_tree_end, | ||
1039 | |||
1040 | TP_PROTO(struct inode *inode, unsigned int pgofs, | ||
1041 | struct extent_node *en), | ||
1042 | |||
1043 | TP_ARGS(inode, pgofs, en), | ||
1044 | |||
1045 | TP_CONDITION(en), | ||
1046 | |||
1047 | TP_STRUCT__entry( | ||
1048 | __field(dev_t, dev) | ||
1049 | __field(ino_t, ino) | ||
1050 | __field(unsigned int, pgofs) | ||
1051 | __field(unsigned int, fofs) | ||
1052 | __field(u32, blk) | ||
1053 | __field(unsigned int, len) | ||
1054 | ), | ||
1055 | |||
1056 | TP_fast_assign( | ||
1057 | __entry->dev = inode->i_sb->s_dev; | ||
1058 | __entry->ino = inode->i_ino; | ||
1059 | __entry->pgofs = pgofs; | ||
1060 | __entry->fofs = en->ei.fofs; | ||
1061 | __entry->blk = en->ei.blk; | ||
1062 | __entry->len = en->ei.len; | ||
1063 | ), | ||
1064 | |||
1065 | TP_printk("dev = (%d,%d), ino = %lu, pgofs = %u, " | ||
1066 | "ext_info(fofs: %u, blk: %u, len: %u)", | ||
1067 | show_dev_ino(__entry), | ||
1068 | __entry->pgofs, | ||
1069 | __entry->fofs, | ||
1070 | __entry->blk, | ||
1071 | __entry->len) | ||
1072 | ); | ||
1073 | |||
1074 | TRACE_EVENT(f2fs_update_extent_tree, | ||
1075 | |||
1076 | TP_PROTO(struct inode *inode, unsigned int pgofs, block_t blkaddr), | ||
1077 | |||
1078 | TP_ARGS(inode, pgofs, blkaddr), | ||
1079 | |||
1080 | TP_STRUCT__entry( | ||
1081 | __field(dev_t, dev) | ||
1082 | __field(ino_t, ino) | ||
1083 | __field(unsigned int, pgofs) | ||
1084 | __field(u32, blk) | ||
1085 | ), | ||
1086 | |||
1087 | TP_fast_assign( | ||
1088 | __entry->dev = inode->i_sb->s_dev; | ||
1089 | __entry->ino = inode->i_ino; | ||
1090 | __entry->pgofs = pgofs; | ||
1091 | __entry->blk = blkaddr; | ||
1092 | ), | ||
1093 | |||
1094 | TP_printk("dev = (%d,%d), ino = %lu, pgofs = %u, blkaddr = %u", | ||
1095 | show_dev_ino(__entry), | ||
1096 | __entry->pgofs, | ||
1097 | __entry->blk) | ||
1098 | ); | ||
1099 | |||
1100 | TRACE_EVENT(f2fs_shrink_extent_tree, | ||
1101 | |||
1102 | TP_PROTO(struct f2fs_sb_info *sbi, unsigned int node_cnt, | ||
1103 | unsigned int tree_cnt), | ||
1104 | |||
1105 | TP_ARGS(sbi, node_cnt, tree_cnt), | ||
1106 | |||
1107 | TP_STRUCT__entry( | ||
1108 | __field(dev_t, dev) | ||
1109 | __field(unsigned int, node_cnt) | ||
1110 | __field(unsigned int, tree_cnt) | ||
1111 | ), | ||
1112 | |||
1113 | TP_fast_assign( | ||
1114 | __entry->dev = sbi->sb->s_dev; | ||
1115 | __entry->node_cnt = node_cnt; | ||
1116 | __entry->tree_cnt = tree_cnt; | ||
1117 | ), | ||
1118 | |||
1119 | TP_printk("dev = (%d,%d), shrunk: node_cnt = %u, tree_cnt = %u", | ||
1120 | show_dev(__entry), | ||
1121 | __entry->node_cnt, | ||
1122 | __entry->tree_cnt) | ||
1123 | ); | ||
1124 | |||
1125 | TRACE_EVENT(f2fs_destroy_extent_tree, | ||
1126 | |||
1127 | TP_PROTO(struct inode *inode, unsigned int node_cnt), | ||
1128 | |||
1129 | TP_ARGS(inode, node_cnt), | ||
1130 | |||
1131 | TP_STRUCT__entry( | ||
1132 | __field(dev_t, dev) | ||
1133 | __field(ino_t, ino) | ||
1134 | __field(unsigned int, node_cnt) | ||
1135 | ), | ||
1136 | |||
1137 | TP_fast_assign( | ||
1138 | __entry->dev = inode->i_sb->s_dev; | ||
1139 | __entry->ino = inode->i_ino; | ||
1140 | __entry->node_cnt = node_cnt; | ||
1141 | ), | ||
1142 | |||
1143 | TP_printk("dev = (%d,%d), ino = %lu, destroyed: node_cnt = %u", | ||
1144 | show_dev_ino(__entry), | ||
1145 | __entry->node_cnt) | ||
1146 | ); | ||
1147 | |||
1014 | #endif /* _TRACE_F2FS_H */ | 1148 | #endif /* _TRACE_F2FS_H */ |
1015 | 1149 | ||
1016 | /* This part must be outside protection */ | 1150 | /* This part must be outside protection */ |