mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-08 04:55:21 +00:00
scoutfs: add forest tracing
Add some tracing events to the forest subsystem. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "balloc.h"
|
||||
#include "block.h"
|
||||
#include "forest.h"
|
||||
#include "scoutfs_trace.h"
|
||||
|
||||
/*
|
||||
* scoutfs items are stored in a forest of btrees. Each mount writes
|
||||
@@ -342,6 +343,13 @@ static int refresh_bloom_roots(struct super_block *sb,
|
||||
|
||||
scoutfs_block_put(sb, bl);
|
||||
|
||||
trace_scoutfs_forest_bloom_search(sb, &lock->start,
|
||||
be64_to_cpu(ltk.rid),
|
||||
be64_to_cpu(ltk.nr),
|
||||
le64_to_cpu(ltv.bloom_ref.blkno),
|
||||
le64_to_cpu(ltv.bloom_ref.seq),
|
||||
i);
|
||||
|
||||
/* one of the bloom bits wasn't set */
|
||||
if (i != ARRAY_SIZE(bloom.nrs))
|
||||
continue;
|
||||
@@ -365,6 +373,10 @@ static int refresh_bloom_roots(struct super_block *sb,
|
||||
fr->nr = be64_to_cpu(ltk.nr);
|
||||
|
||||
list_add_tail(&fr->entry, &lpriv->roots);
|
||||
|
||||
trace_scoutfs_forest_add_root(sb, &lock->start, fr->rid,
|
||||
fr->nr, le64_to_cpu(fr->item_root.ref.blkno),
|
||||
le64_to_cpu(fr->item_root.ref.seq));
|
||||
}
|
||||
|
||||
/* add our current log root if a locked writer added it */
|
||||
@@ -754,6 +766,9 @@ retry:
|
||||
list_for_each_entry_safe(ip, tmp, &list, entry) {
|
||||
fr = ip->fr;
|
||||
|
||||
trace_scoutfs_forest_iter_search(sb, fr->rid, fr->nr,
|
||||
&ip->pos);
|
||||
|
||||
/* remove once we can't contain any more items */
|
||||
if (!forest_iter_key_before(&ip->pos, &found, fwd) ||
|
||||
!forest_iter_key_within(&ip->pos, end, fwd)) {
|
||||
@@ -784,6 +799,11 @@ retry:
|
||||
scoutfs_key_from_be(&ip->pos, iref.key);
|
||||
vers = item_vers(lpriv, fr, iref.val);
|
||||
|
||||
trace_scoutfs_forest_iter_found(sb, fr->rid, fr->nr,
|
||||
vers,
|
||||
item_flags(lpriv, fr, iref.val),
|
||||
&ip->pos);
|
||||
|
||||
/* record next earliest item and copy to caller */
|
||||
if (!item_is_deletion(lpriv, fr, iref.val) &&
|
||||
forest_iter_key_within(&ip->pos, end, fwd) &&
|
||||
@@ -818,6 +838,8 @@ unlock:
|
||||
}
|
||||
|
||||
out:
|
||||
trace_scoutfs_forest_iter_ret(sb, key, end, fwd, ret,
|
||||
found_vers, found_copied, &found);
|
||||
if (ret == 0) {
|
||||
/* _next/_prev interfaces modify caller's key :/ */
|
||||
if (found_vers > 0) {
|
||||
@@ -969,6 +991,7 @@ static int set_lock_bloom_bits(struct super_block *sb,
|
||||
struct scoutfs_bloom_block *bb;
|
||||
struct scoutfs_btree_ref *ref;
|
||||
struct forest_bloom_nrs bloom;
|
||||
int nr_set = 0;
|
||||
u64 blkno;
|
||||
int ret;
|
||||
int err;
|
||||
@@ -1042,9 +1065,17 @@ static int set_lock_bloom_bits(struct super_block *sb,
|
||||
for (i = 0; i < ARRAY_SIZE(bloom.nrs); i++) {
|
||||
if (!test_and_set_bit_le(bloom.nrs[i], bb->bits)) {
|
||||
le64_add_cpu(&bb->total_set, 1);
|
||||
nr_set++;
|
||||
}
|
||||
}
|
||||
|
||||
trace_scoutfs_forest_bloom_set(sb, &lock->start,
|
||||
le64_to_cpu(finf->our_log.rid),
|
||||
le64_to_cpu(finf->our_log.nr),
|
||||
le64_to_cpu(finf->our_log.bloom_ref.blkno),
|
||||
le64_to_cpu(finf->our_log.bloom_ref.seq),
|
||||
nr_set);
|
||||
|
||||
ret = 0;
|
||||
unlock:
|
||||
up_write(&finf->rwsem);
|
||||
|
||||
@@ -2006,6 +2006,145 @@ TRACE_EVENT(scoutfs_trans_seq_last,
|
||||
SCSB_TRACE_ARGS, __entry->s_rid, __entry->trans_seq)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(scoutfs_forest_bloom_class,
|
||||
TP_PROTO(struct super_block *sb, struct scoutfs_key *key,
|
||||
u64 rid, u64 nr, u64 blkno, u64 seq, unsigned int count),
|
||||
TP_ARGS(sb, key, rid, nr, blkno, seq, count),
|
||||
TP_STRUCT__entry(
|
||||
SCSB_TRACE_FIELDS
|
||||
sk_trace_define(key)
|
||||
__field(__u64, b_rid)
|
||||
__field(__u64, nr)
|
||||
__field(__u64, blkno)
|
||||
__field(__u64, seq)
|
||||
__field(unsigned int, count)
|
||||
),
|
||||
TP_fast_assign(
|
||||
SCSB_TRACE_ASSIGN(sb);
|
||||
sk_trace_assign(key, key);
|
||||
__entry->b_rid = rid;
|
||||
__entry->nr = nr;
|
||||
__entry->blkno = blkno;
|
||||
__entry->seq = seq;
|
||||
__entry->count = count;
|
||||
),
|
||||
TP_printk(SCSBF" key "SK_FMT" rid %016llx nr %llu blkno %llu seq %llx count %u",
|
||||
SCSB_TRACE_ARGS, sk_trace_args(key), __entry->b_rid,
|
||||
__entry->nr, __entry->blkno, __entry->seq, __entry->count)
|
||||
);
|
||||
DEFINE_EVENT(scoutfs_forest_bloom_class, scoutfs_forest_bloom_set,
|
||||
TP_PROTO(struct super_block *sb, struct scoutfs_key *key,
|
||||
u64 rid, u64 nr, u64 blkno, u64 seq, unsigned int count),
|
||||
TP_ARGS(sb, key, rid, nr, blkno, seq, count)
|
||||
);
|
||||
DEFINE_EVENT(scoutfs_forest_bloom_class, scoutfs_forest_bloom_search,
|
||||
TP_PROTO(struct super_block *sb, struct scoutfs_key *key,
|
||||
u64 rid, u64 nr, u64 blkno, u64 seq, unsigned int count),
|
||||
TP_ARGS(sb, key, rid, nr, blkno, seq, count)
|
||||
);
|
||||
|
||||
TRACE_EVENT(scoutfs_forest_add_root,
|
||||
TP_PROTO(struct super_block *sb, struct scoutfs_key *key, u64 rid,
|
||||
u64 nr, u64 blkno, u64 seq),
|
||||
TP_ARGS(sb, key, rid, nr, blkno, seq),
|
||||
TP_STRUCT__entry(
|
||||
SCSB_TRACE_FIELDS
|
||||
sk_trace_define(key)
|
||||
__field(__u64, b_rid)
|
||||
__field(__u64, nr)
|
||||
__field(__u64, blkno)
|
||||
__field(__u64, seq)
|
||||
),
|
||||
TP_fast_assign(
|
||||
SCSB_TRACE_ASSIGN(sb);
|
||||
sk_trace_assign(key, key);
|
||||
__entry->b_rid = rid;
|
||||
__entry->nr = nr;
|
||||
__entry->blkno = blkno;
|
||||
__entry->seq = seq;
|
||||
),
|
||||
TP_printk(SCSBF" key "SK_FMT" rid %016llx nr %llu blkno %llu seq %llx",
|
||||
SCSB_TRACE_ARGS, sk_trace_args(key),
|
||||
__entry->b_rid, __entry->nr, __entry->blkno, __entry->seq)
|
||||
);
|
||||
|
||||
TRACE_EVENT(scoutfs_forest_iter_search,
|
||||
TP_PROTO(struct super_block *sb, u64 rid, u64 nr,
|
||||
struct scoutfs_key *pos),
|
||||
TP_ARGS(sb, rid, nr, pos),
|
||||
TP_STRUCT__entry(
|
||||
SCSB_TRACE_FIELDS
|
||||
__field(__u64, b_rid)
|
||||
__field(__u64, nr)
|
||||
sk_trace_define(pos)
|
||||
),
|
||||
TP_fast_assign(
|
||||
SCSB_TRACE_ASSIGN(sb);
|
||||
__entry->b_rid = rid;
|
||||
__entry->nr = nr;
|
||||
sk_trace_assign(pos, pos);
|
||||
),
|
||||
TP_printk(SCSBF" rid %016llx nr %llu pos "SK_FMT,
|
||||
SCSB_TRACE_ARGS, __entry->b_rid, __entry->nr,
|
||||
sk_trace_args(pos))
|
||||
);
|
||||
|
||||
TRACE_EVENT(scoutfs_forest_iter_found,
|
||||
TP_PROTO(struct super_block *sb, u64 rid, u64 nr, u64 vers,
|
||||
u8 flags, struct scoutfs_key *key),
|
||||
TP_ARGS(sb, rid, nr, vers, flags, key),
|
||||
TP_STRUCT__entry(
|
||||
SCSB_TRACE_FIELDS
|
||||
__field(__u64, b_rid)
|
||||
__field(__u64, nr)
|
||||
__field(__u64, vers)
|
||||
__field(__u8, flags)
|
||||
sk_trace_define(key)
|
||||
),
|
||||
TP_fast_assign(
|
||||
SCSB_TRACE_ASSIGN(sb);
|
||||
__entry->b_rid = rid;
|
||||
__entry->nr = nr;
|
||||
__entry->vers = vers;
|
||||
__entry->flags = flags;
|
||||
sk_trace_assign(key, key);
|
||||
),
|
||||
TP_printk(SCSBF" rid %016llx nr %llu vers %llu flags %x key "SK_FMT,
|
||||
SCSB_TRACE_ARGS, __entry->b_rid, __entry->nr,
|
||||
__entry->vers, __entry->flags, sk_trace_args(key))
|
||||
);
|
||||
|
||||
TRACE_EVENT(scoutfs_forest_iter_ret,
|
||||
TP_PROTO(struct super_block *sb, struct scoutfs_key *key,
|
||||
struct scoutfs_key *end, bool forward, int ret,
|
||||
u64 found_vers, int found_copied, struct scoutfs_key *found),
|
||||
TP_ARGS(sb, key, end, forward, ret, found_vers, found_copied, found),
|
||||
TP_STRUCT__entry(
|
||||
SCSB_TRACE_FIELDS
|
||||
sk_trace_define(key)
|
||||
sk_trace_define(end)
|
||||
__field(char, forward)
|
||||
__field(int, ret)
|
||||
__field(__u64, found_vers)
|
||||
__field(int, found_copied)
|
||||
sk_trace_define(found)
|
||||
),
|
||||
TP_fast_assign(
|
||||
SCSB_TRACE_ASSIGN(sb);
|
||||
sk_trace_assign(key, key);
|
||||
sk_trace_assign(end, end);
|
||||
__entry->forward = !!forward;
|
||||
__entry->ret = ret;
|
||||
__entry->found_vers = found_vers;
|
||||
__entry->found_copied = found_copied;
|
||||
sk_trace_assign(found, found);
|
||||
),
|
||||
TP_printk(SCSBF" key "SK_FMT" end "SK_FMT" fwd %u ret %d fv %llu fc %d f "SK_FMT,
|
||||
SCSB_TRACE_ARGS, sk_trace_args(key), sk_trace_args(end),
|
||||
__entry->forward, __entry->ret, __entry->found_vers,
|
||||
__entry->found_copied, sk_trace_args(found))
|
||||
);
|
||||
|
||||
#endif /* _TRACE_SCOUTFS_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
||||
Reference in New Issue
Block a user