Skip to content

Commit

Permalink
btrfs: Add qgroup tracing
Browse files Browse the repository at this point in the history
This patch adds tracepoints to the qgroup code on both the reporting side
(insert_dirty_extents) and the accounting side. Taken together it allows us
to see what qgroup operations have happened, and what their result was.

Signed-off-by: Mark Fasheh <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
Mark Fasheh authored and kdave committed Apr 4, 2016
1 parent c79b471 commit 0f5dcf8
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 1 deletion.
9 changes: 9 additions & 0 deletions fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,7 @@ struct btrfs_qgroup_extent_record
u64 bytenr = record->bytenr;

assert_spin_locked(&delayed_refs->lock);
trace_btrfs_qgroup_insert_dirty_extent(record);

while (*p) {
parent_node = *p;
Expand Down Expand Up @@ -1594,6 +1595,9 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info,
cur_old_count = btrfs_qgroup_get_old_refcnt(qg, seq);
cur_new_count = btrfs_qgroup_get_new_refcnt(qg, seq);

trace_qgroup_update_counters(qg->qgroupid, cur_old_count,
cur_new_count);

/* Rfer update part */
if (cur_old_count == 0 && cur_new_count > 0) {
qg->rfer += num_bytes;
Expand Down Expand Up @@ -1683,6 +1687,9 @@ btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
goto out_free;
BUG_ON(!fs_info->quota_root);

trace_btrfs_qgroup_account_extent(bytenr, num_bytes, nr_old_roots,
nr_new_roots);

qgroups = ulist_alloc(GFP_NOFS);
if (!qgroups) {
ret = -ENOMEM;
Expand Down Expand Up @@ -1752,6 +1759,8 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
record = rb_entry(node, struct btrfs_qgroup_extent_record,
node);

trace_btrfs_qgroup_account_extents(record);

if (!ret) {
/*
* Use (u64)-1 as time_seq to do special search, which
Expand Down
89 changes: 88 additions & 1 deletion include/trace/events/btrfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct map_lookup;
struct extent_buffer;
struct btrfs_work;
struct __btrfs_workqueue;
struct btrfs_qgroup_operation;
struct btrfs_qgroup_extent_record;

#define show_ref_type(type) \
__print_symbolic(type, \
Expand Down Expand Up @@ -1231,6 +1231,93 @@ DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,

TP_ARGS(ref_root, reserved)
);

DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
TP_PROTO(struct btrfs_qgroup_extent_record *rec),

TP_ARGS(rec),

TP_STRUCT__entry(
__field( u64, bytenr )
__field( u64, num_bytes )
),

TP_fast_assign(
__entry->bytenr = rec->bytenr,
__entry->num_bytes = rec->num_bytes;
),

TP_printk("bytenr = %llu, num_bytes = %llu",
(unsigned long long)__entry->bytenr,
(unsigned long long)__entry->num_bytes)
);

DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,

TP_PROTO(struct btrfs_qgroup_extent_record *rec),

TP_ARGS(rec)
);

DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_insert_dirty_extent,

TP_PROTO(struct btrfs_qgroup_extent_record *rec),

TP_ARGS(rec)
);

TRACE_EVENT(btrfs_qgroup_account_extent,

TP_PROTO(u64 bytenr, u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),

TP_ARGS(bytenr, num_bytes, nr_old_roots, nr_new_roots),

TP_STRUCT__entry(
__field( u64, bytenr )
__field( u64, num_bytes )
__field( u64, nr_old_roots )
__field( u64, nr_new_roots )
),

TP_fast_assign(
__entry->bytenr = bytenr;
__entry->num_bytes = num_bytes;
__entry->nr_old_roots = nr_old_roots;
__entry->nr_new_roots = nr_new_roots;
),

TP_printk("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, "
"nr_new_roots = %llu",
__entry->bytenr,
__entry->num_bytes,
__entry->nr_old_roots,
__entry->nr_new_roots)
);

TRACE_EVENT(qgroup_update_counters,

TP_PROTO(u64 qgid, u64 cur_old_count, u64 cur_new_count),

TP_ARGS(qgid, cur_old_count, cur_new_count),

TP_STRUCT__entry(
__field( u64, qgid )
__field( u64, cur_old_count )
__field( u64, cur_new_count )
),

TP_fast_assign(
__entry->qgid = qgid;
__entry->cur_old_count = cur_old_count;
__entry->cur_new_count = cur_new_count;
),

TP_printk("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu",
__entry->qgid,
__entry->cur_old_count,
__entry->cur_new_count)
);

#endif /* _TRACE_BTRFS_H */

/* This part must be outside protection */
Expand Down

0 comments on commit 0f5dcf8

Please sign in to comment.