Skip to content

Commit 0f5dcf8

Browse files
Mark Fashehkdave
authored andcommitted
btrfs: Add qgroup tracing
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]>
1 parent c79b471 commit 0f5dcf8

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed

fs/btrfs/qgroup.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,7 @@ struct btrfs_qgroup_extent_record
14631463
u64 bytenr = record->bytenr;
14641464

14651465
assert_spin_locked(&delayed_refs->lock);
1466+
trace_btrfs_qgroup_insert_dirty_extent(record);
14661467

14671468
while (*p) {
14681469
parent_node = *p;
@@ -1594,6 +1595,9 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info,
15941595
cur_old_count = btrfs_qgroup_get_old_refcnt(qg, seq);
15951596
cur_new_count = btrfs_qgroup_get_new_refcnt(qg, seq);
15961597

1598+
trace_qgroup_update_counters(qg->qgroupid, cur_old_count,
1599+
cur_new_count);
1600+
15971601
/* Rfer update part */
15981602
if (cur_old_count == 0 && cur_new_count > 0) {
15991603
qg->rfer += num_bytes;
@@ -1683,6 +1687,9 @@ btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans,
16831687
goto out_free;
16841688
BUG_ON(!fs_info->quota_root);
16851689

1690+
trace_btrfs_qgroup_account_extent(bytenr, num_bytes, nr_old_roots,
1691+
nr_new_roots);
1692+
16861693
qgroups = ulist_alloc(GFP_NOFS);
16871694
if (!qgroups) {
16881695
ret = -ENOMEM;
@@ -1752,6 +1759,8 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans,
17521759
record = rb_entry(node, struct btrfs_qgroup_extent_record,
17531760
node);
17541761

1762+
trace_btrfs_qgroup_account_extents(record);
1763+
17551764
if (!ret) {
17561765
/*
17571766
* Use (u64)-1 as time_seq to do special search, which

include/trace/events/btrfs.h

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct map_lookup;
2323
struct extent_buffer;
2424
struct btrfs_work;
2525
struct __btrfs_workqueue;
26-
struct btrfs_qgroup_operation;
26+
struct btrfs_qgroup_extent_record;
2727

2828
#define show_ref_type(type) \
2929
__print_symbolic(type, \
@@ -1231,6 +1231,93 @@ DEFINE_EVENT(btrfs__qgroup_delayed_ref, btrfs_qgroup_free_delayed_ref,
12311231

12321232
TP_ARGS(ref_root, reserved)
12331233
);
1234+
1235+
DECLARE_EVENT_CLASS(btrfs_qgroup_extent,
1236+
TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1237+
1238+
TP_ARGS(rec),
1239+
1240+
TP_STRUCT__entry(
1241+
__field( u64, bytenr )
1242+
__field( u64, num_bytes )
1243+
),
1244+
1245+
TP_fast_assign(
1246+
__entry->bytenr = rec->bytenr,
1247+
__entry->num_bytes = rec->num_bytes;
1248+
),
1249+
1250+
TP_printk("bytenr = %llu, num_bytes = %llu",
1251+
(unsigned long long)__entry->bytenr,
1252+
(unsigned long long)__entry->num_bytes)
1253+
);
1254+
1255+
DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_account_extents,
1256+
1257+
TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1258+
1259+
TP_ARGS(rec)
1260+
);
1261+
1262+
DEFINE_EVENT(btrfs_qgroup_extent, btrfs_qgroup_insert_dirty_extent,
1263+
1264+
TP_PROTO(struct btrfs_qgroup_extent_record *rec),
1265+
1266+
TP_ARGS(rec)
1267+
);
1268+
1269+
TRACE_EVENT(btrfs_qgroup_account_extent,
1270+
1271+
TP_PROTO(u64 bytenr, u64 num_bytes, u64 nr_old_roots, u64 nr_new_roots),
1272+
1273+
TP_ARGS(bytenr, num_bytes, nr_old_roots, nr_new_roots),
1274+
1275+
TP_STRUCT__entry(
1276+
__field( u64, bytenr )
1277+
__field( u64, num_bytes )
1278+
__field( u64, nr_old_roots )
1279+
__field( u64, nr_new_roots )
1280+
),
1281+
1282+
TP_fast_assign(
1283+
__entry->bytenr = bytenr;
1284+
__entry->num_bytes = num_bytes;
1285+
__entry->nr_old_roots = nr_old_roots;
1286+
__entry->nr_new_roots = nr_new_roots;
1287+
),
1288+
1289+
TP_printk("bytenr = %llu, num_bytes = %llu, nr_old_roots = %llu, "
1290+
"nr_new_roots = %llu",
1291+
__entry->bytenr,
1292+
__entry->num_bytes,
1293+
__entry->nr_old_roots,
1294+
__entry->nr_new_roots)
1295+
);
1296+
1297+
TRACE_EVENT(qgroup_update_counters,
1298+
1299+
TP_PROTO(u64 qgid, u64 cur_old_count, u64 cur_new_count),
1300+
1301+
TP_ARGS(qgid, cur_old_count, cur_new_count),
1302+
1303+
TP_STRUCT__entry(
1304+
__field( u64, qgid )
1305+
__field( u64, cur_old_count )
1306+
__field( u64, cur_new_count )
1307+
),
1308+
1309+
TP_fast_assign(
1310+
__entry->qgid = qgid;
1311+
__entry->cur_old_count = cur_old_count;
1312+
__entry->cur_new_count = cur_new_count;
1313+
),
1314+
1315+
TP_printk("qgid = %llu, cur_old_count = %llu, cur_new_count = %llu",
1316+
__entry->qgid,
1317+
__entry->cur_old_count,
1318+
__entry->cur_new_count)
1319+
);
1320+
12341321
#endif /* _TRACE_BTRFS_H */
12351322

12361323
/* This part must be outside protection */

0 commit comments

Comments
 (0)