btrfs: qgroup: Introduce trace event to analyse the number of dirty extents accounted
authorQu Wenruo <wqu@suse.com>
Thu, 27 Sep 2018 06:42:29 +0000 (14:42 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 15 Oct 2018 15:23:36 +0000 (17:23 +0200)
Number of qgroup dirty extents is directly linked to the performance
overhead, so add a new trace event, trace_qgroup_num_dirty_extents(), to
record how many dirty extents is processed in
btrfs_qgroup_account_extents().

This will be pretty handy to analyze later balance performance
improvement.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/qgroup.c
include/trace/events/btrfs.h

index bdd8c0da6e3227c72e27714f668d615d8c2070dd..8a03adc11f532c4af14ed3bb291cf96260efe6c0 100644 (file)
@@ -2132,6 +2132,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans)
        struct btrfs_delayed_ref_root *delayed_refs;
        struct ulist *new_roots = NULL;
        struct rb_node *node;
+       u64 num_dirty_extents = 0;
        u64 qgroup_to_skip;
        int ret = 0;
 
@@ -2141,6 +2142,7 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans)
                record = rb_entry(node, struct btrfs_qgroup_extent_record,
                                  node);
 
+               num_dirty_extents++;
                trace_btrfs_qgroup_account_extents(fs_info, record);
 
                if (!ret) {
@@ -2186,6 +2188,8 @@ cleanup:
                kfree(record);
 
        }
+       trace_qgroup_num_dirty_extents(fs_info, trans->transid,
+                                      num_dirty_extents);
        return ret;
 }
 
index abe3ff774f583f1f5981aaeb1e03521ea4f29568..8568946f491d757d8357ae565c91474512b12d1f 100644 (file)
@@ -1576,6 +1576,27 @@ DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_trace_extent,
        TP_ARGS(fs_info, rec)
 );
 
+TRACE_EVENT(qgroup_num_dirty_extents,
+
+       TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid,
+                u64 num_dirty_extents),
+
+       TP_ARGS(fs_info, transid, num_dirty_extents),
+
+       TP_STRUCT__entry_btrfs(
+               __field(        u64, transid                    )
+               __field(        u64, num_dirty_extents          )
+       ),
+
+       TP_fast_assign_btrfs(fs_info,
+               __entry->transid           = transid;
+               __entry->num_dirty_extents = num_dirty_extents;
+       ),
+
+       TP_printk_btrfs("transid=%llu num_dirty_extents=%llu",
+               __entry->transid, __entry->num_dirty_extents)
+);
+
 TRACE_EVENT(btrfs_qgroup_account_extent,
 
        TP_PROTO(const struct btrfs_fs_info *fs_info, u64 transid, u64 bytenr,