diff options
author | Josef Bacik <jbacik@fb.com> | 2016-03-25 13:25:56 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-07-07 12:45:53 -0400 |
commit | f376df2b7da3a40f62f861a65efdd8c29fa1b877 (patch) | |
tree | 80619bff6da54d004aeac46fd58f866c3a543f03 | |
parent | f485c9ee32531794e39631437fcedc82d5b8e650 (diff) |
Btrfs: add tracepoints for flush events
We want to track when we're triggering flushing from our reservation code and
what flushing is being done when we start flushing. Thanks,
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/ctree.h | 9 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 22 | ||||
-rw-r--r-- | include/trace/events/btrfs.h | 82 |
3 files changed, 103 insertions, 10 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2e04c9d6f21d..83a6a931af09 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2626,6 +2626,15 @@ enum btrfs_reserve_flush_enum { | |||
2626 | BTRFS_RESERVE_FLUSH_ALL, | 2626 | BTRFS_RESERVE_FLUSH_ALL, |
2627 | }; | 2627 | }; |
2628 | 2628 | ||
2629 | enum btrfs_flush_state { | ||
2630 | FLUSH_DELAYED_ITEMS_NR = 1, | ||
2631 | FLUSH_DELAYED_ITEMS = 2, | ||
2632 | FLUSH_DELALLOC = 3, | ||
2633 | FLUSH_DELALLOC_WAIT = 4, | ||
2634 | ALLOC_CHUNK = 5, | ||
2635 | COMMIT_TRANS = 6, | ||
2636 | }; | ||
2637 | |||
2629 | int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len); | 2638 | int btrfs_check_data_free_space(struct inode *inode, u64 start, u64 len); |
2630 | int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes); | 2639 | int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes); |
2631 | void btrfs_free_reserved_data_space(struct inode *inode, u64 start, u64 len); | 2640 | void btrfs_free_reserved_data_space(struct inode *inode, u64 start, u64 len); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 5d24ec44d99b..31ded6aae1f0 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -4835,15 +4835,6 @@ commit: | |||
4835 | return btrfs_commit_transaction(trans, root); | 4835 | return btrfs_commit_transaction(trans, root); |
4836 | } | 4836 | } |
4837 | 4837 | ||
4838 | enum flush_state { | ||
4839 | FLUSH_DELAYED_ITEMS_NR = 1, | ||
4840 | FLUSH_DELAYED_ITEMS = 2, | ||
4841 | FLUSH_DELALLOC = 3, | ||
4842 | FLUSH_DELALLOC_WAIT = 4, | ||
4843 | ALLOC_CHUNK = 5, | ||
4844 | COMMIT_TRANS = 6, | ||
4845 | }; | ||
4846 | |||
4847 | struct reserve_ticket { | 4838 | struct reserve_ticket { |
4848 | u64 bytes; | 4839 | u64 bytes; |
4849 | int error; | 4840 | int error; |
@@ -4901,6 +4892,8 @@ static int flush_space(struct btrfs_root *root, | |||
4901 | break; | 4892 | break; |
4902 | } | 4893 | } |
4903 | 4894 | ||
4895 | trace_btrfs_flush_space(root->fs_info, space_info->flags, num_bytes, | ||
4896 | orig_bytes, state, ret); | ||
4904 | return ret; | 4897 | return ret; |
4905 | } | 4898 | } |
4906 | 4899 | ||
@@ -5178,6 +5171,10 @@ static int __reserve_metadata_bytes(struct btrfs_root *root, | |||
5178 | list_add_tail(&ticket.list, &space_info->tickets); | 5171 | list_add_tail(&ticket.list, &space_info->tickets); |
5179 | if (!space_info->flush) { | 5172 | if (!space_info->flush) { |
5180 | space_info->flush = 1; | 5173 | space_info->flush = 1; |
5174 | trace_btrfs_trigger_flush(root->fs_info, | ||
5175 | space_info->flags, | ||
5176 | orig_bytes, flush, | ||
5177 | "enospc"); | ||
5181 | queue_work(system_unbound_wq, | 5178 | queue_work(system_unbound_wq, |
5182 | &root->fs_info->async_reclaim_work); | 5179 | &root->fs_info->async_reclaim_work); |
5183 | } | 5180 | } |
@@ -5194,9 +5191,14 @@ static int __reserve_metadata_bytes(struct btrfs_root *root, | |||
5194 | */ | 5191 | */ |
5195 | if (!root->fs_info->log_root_recovering && | 5192 | if (!root->fs_info->log_root_recovering && |
5196 | need_do_async_reclaim(space_info, root->fs_info, used) && | 5193 | need_do_async_reclaim(space_info, root->fs_info, used) && |
5197 | !work_busy(&root->fs_info->async_reclaim_work)) | 5194 | !work_busy(&root->fs_info->async_reclaim_work)) { |
5195 | trace_btrfs_trigger_flush(root->fs_info, | ||
5196 | space_info->flags, | ||
5197 | orig_bytes, flush, | ||
5198 | "preempt"); | ||
5198 | queue_work(system_unbound_wq, | 5199 | queue_work(system_unbound_wq, |
5199 | &root->fs_info->async_reclaim_work); | 5200 | &root->fs_info->async_reclaim_work); |
5201 | } | ||
5200 | } | 5202 | } |
5201 | spin_unlock(&space_info->lock); | 5203 | spin_unlock(&space_info->lock); |
5202 | if (!ret || flush == BTRFS_RESERVE_NO_FLUSH) | 5204 | if (!ret || flush == BTRFS_RESERVE_NO_FLUSH) |
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index 985e01b6c849..226c7f283247 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h | |||
@@ -784,6 +784,88 @@ TRACE_EVENT(btrfs_space_reservation, | |||
784 | __entry->bytes) | 784 | __entry->bytes) |
785 | ); | 785 | ); |
786 | 786 | ||
787 | #define show_flush_action(action) \ | ||
788 | __print_symbolic(action, \ | ||
789 | { BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ | ||
790 | { BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ | ||
791 | { BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) | ||
792 | |||
793 | TRACE_EVENT(btrfs_trigger_flush, | ||
794 | |||
795 | TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 bytes, | ||
796 | int flush, char *reason), | ||
797 | |||
798 | TP_ARGS(fs_info, flags, bytes, flush, reason), | ||
799 | |||
800 | TP_STRUCT__entry( | ||
801 | __array( u8, fsid, BTRFS_UUID_SIZE ) | ||
802 | __field( u64, flags ) | ||
803 | __field( u64, bytes ) | ||
804 | __field( int, flush ) | ||
805 | __string( reason, reason ) | ||
806 | ), | ||
807 | |||
808 | TP_fast_assign( | ||
809 | memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); | ||
810 | __entry->flags = flags; | ||
811 | __entry->bytes = bytes; | ||
812 | __entry->flush = flush; | ||
813 | __assign_str(reason, reason) | ||
814 | ), | ||
815 | |||
816 | TP_printk("%pU: %s: flush = %d(%s), flags = %llu(%s), bytes = %llu", | ||
817 | __entry->fsid, __get_str(reason), __entry->flush, | ||
818 | show_flush_action(__entry->flush), | ||
819 | (unsigned long long)__entry->flags, | ||
820 | __print_flags((unsigned long)__entry->flags, "|", | ||
821 | BTRFS_GROUP_FLAGS), | ||
822 | (unsigned long long)__entry->bytes) | ||
823 | ); | ||
824 | |||
825 | #define show_flush_state(state) \ | ||
826 | __print_symbolic(state, \ | ||
827 | { FLUSH_DELAYED_ITEMS_NR, "FLUSH_DELAYED_ITEMS_NR"}, \ | ||
828 | { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ | ||
829 | { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ | ||
830 | { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ | ||
831 | { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ | ||
832 | { COMMIT_TRANS, "COMMIT_TRANS"}) | ||
833 | |||
834 | TRACE_EVENT(btrfs_flush_space, | ||
835 | |||
836 | TP_PROTO(struct btrfs_fs_info *fs_info, u64 flags, u64 num_bytes, | ||
837 | u64 orig_bytes, int state, int ret), | ||
838 | |||
839 | TP_ARGS(fs_info, flags, num_bytes, orig_bytes, state, ret), | ||
840 | |||
841 | TP_STRUCT__entry( | ||
842 | __array( u8, fsid, BTRFS_UUID_SIZE ) | ||
843 | __field( u64, flags ) | ||
844 | __field( u64, num_bytes ) | ||
845 | __field( u64, orig_bytes ) | ||
846 | __field( int, state ) | ||
847 | __field( int, ret ) | ||
848 | ), | ||
849 | |||
850 | TP_fast_assign( | ||
851 | memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE); | ||
852 | __entry->flags = flags; | ||
853 | __entry->num_bytes = num_bytes; | ||
854 | __entry->orig_bytes = orig_bytes; | ||
855 | __entry->state = state; | ||
856 | __entry->ret = ret; | ||
857 | ), | ||
858 | |||
859 | TP_printk("%pU: state = %d(%s), flags = %llu(%s), num_bytes = %llu, " | ||
860 | "orig_bytes = %llu, ret = %d", __entry->fsid, __entry->state, | ||
861 | show_flush_state(__entry->state), | ||
862 | (unsigned long long)__entry->flags, | ||
863 | __print_flags((unsigned long)__entry->flags, "|", | ||
864 | BTRFS_GROUP_FLAGS), | ||
865 | (unsigned long long)__entry->num_bytes, | ||
866 | (unsigned long long)__entry->orig_bytes, __entry->ret) | ||
867 | ); | ||
868 | |||
787 | DECLARE_EVENT_CLASS(btrfs__reserved_extent, | 869 | DECLARE_EVENT_CLASS(btrfs__reserved_extent, |
788 | 870 | ||
789 | TP_PROTO(struct btrfs_root *root, u64 start, u64 len), | 871 | TP_PROTO(struct btrfs_root *root, u64 start, u64 len), |