diff --git a/kmod/src/alloc.c b/kmod/src/alloc.c index 48307ebc..184493c9 100644 --- a/kmod/src/alloc.c +++ b/kmod/src/alloc.c @@ -20,6 +20,7 @@ #include "treap.h" #include "cmp.h" #include "alloc.h" +#include "counters.h" /* * scoutfs allocates segments by storing regions of a bitmap in treap @@ -165,6 +166,8 @@ int scoutfs_alloc_segno(struct super_block *sb, u64 *segno) ret = 0; out: + if (ret == 0) + scoutfs_inc_counter(sb, alloc_alloc); up_write(&sal->rwsem); trace_printk("segno %llu ret %d\n", *segno, ret); @@ -201,6 +204,7 @@ int scoutfs_alloc_free(struct super_block *sb, u64 segno) } set_bit_le(nr, pend->reg.bits); + scoutfs_inc_counter(sb, alloc_free); ret = 0; out: up_write(&sal->rwsem); diff --git a/kmod/src/compact.c b/kmod/src/compact.c index 8e00b576..dd62debf 100644 --- a/kmod/src/compact.c +++ b/kmod/src/compact.c @@ -23,6 +23,7 @@ #include "compact.h" #include "manifest.h" #include "trans.h" +#include "counters.h" #include "scoutfs_trace.h" /* @@ -131,6 +132,7 @@ static int read_segments(struct super_block *sb, struct compact_cursor *curs) } cseg->seg = seg; + scoutfs_inc_counter(sb, compact_segment_read); } list_for_each_entry(cseg, &curs->csegs, entry) { @@ -165,6 +167,7 @@ static int write_segments(struct super_block *sb, struct list_head *results) ret = scoutfs_seg_submit_write(sb, cseg->seg, &comp); if (ret) break; + scoutfs_inc_counter(sb, compact_segment_write); } err = scoutfs_bio_wait_comp(sb, &comp); @@ -475,6 +478,8 @@ static void scoutfs_compact_func(struct work_struct *work) if (ret <= 0) goto out; + scoutfs_inc_counter(sb, compact_compactions); + ret = read_segments(sb, &curs) ?: compact_segments(sb, &curs, &results) ?: write_segments(sb, &results) ?: diff --git a/kmod/src/counters.h b/kmod/src/counters.h index f6d630c1..09d48252 100644 --- a/kmod/src/counters.h +++ b/kmod/src/counters.h @@ -12,11 +12,18 @@ * other places by this macro. Don't forget to update LAST_COUNTER. */ #define EXPAND_EACH_COUNTER \ + EXPAND_COUNTER(alloc_alloc) \ + EXPAND_COUNTER(alloc_free) \ EXPAND_COUNTER(block_mem_alloc) \ - EXPAND_COUNTER(block_mem_free) + EXPAND_COUNTER(block_mem_free) \ + EXPAND_COUNTER(trans_level0_seg_write) \ + EXPAND_COUNTER(manifest_compact_migrate) \ + EXPAND_COUNTER(compact_compactions) \ + EXPAND_COUNTER(compact_segment_read) \ + EXPAND_COUNTER(compact_segment_write) #define FIRST_COUNTER block_mem_alloc -#define LAST_COUNTER block_mem_free +#define LAST_COUNTER compact_segment_write #undef EXPAND_COUNTER #define EXPAND_COUNTER(which) struct percpu_counter which; diff --git a/kmod/src/manifest.c b/kmod/src/manifest.c index 7ad89c35..2f586466 100644 --- a/kmod/src/manifest.c +++ b/kmod/src/manifest.c @@ -25,6 +25,7 @@ #include "compact.h" #include "manifest.h" #include "trans.h" +#include "counters.h" #include "scoutfs_trace.h" /* @@ -762,6 +763,7 @@ int scoutfs_manifest_next_compact(struct super_block *sb, void *data) goto out; } + scoutfs_inc_counter(sb, manifest_compact_migrate); goto done; } diff --git a/kmod/src/trans.c b/kmod/src/trans.c index adbab3cb..bbd543ff 100644 --- a/kmod/src/trans.c +++ b/kmod/src/trans.c @@ -29,6 +29,7 @@ #include "alloc.h" #include "treap.h" #include "compact.h" +#include "counters.h" #include "scoutfs_trace.h" /* @@ -116,6 +117,8 @@ void scoutfs_trans_write_func(struct work_struct *work) scoutfs_seg_put(seg); if (ret) goto out; + + scoutfs_inc_counter(sb, trans_level0_seg_write); } if (scoutfs_manifest_has_dirty(sb) || scoutfs_alloc_has_dirty(sb)) {