Commit 74644030 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: count_event()

Small helper for event counters.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent cb13f471
...@@ -1674,7 +1674,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans, ...@@ -1674,7 +1674,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
if (ret) if (ret)
goto out; goto out;
this_cpu_inc(c->counters[BCH_COUNTER_bucket_discard]); count_event(c, bucket_discard);
(*discarded)++; (*discarded)++;
out: out:
(*seen)++; (*seen)++;
......
...@@ -223,9 +223,11 @@ ...@@ -223,9 +223,11 @@
#define race_fault(...) dynamic_fault("bcachefs:race") #define race_fault(...) dynamic_fault("bcachefs:race")
#define count_event(_c, _name) this_cpu_inc((_c)->counters[BCH_COUNTER_##_name])
#define trace_and_count(_c, _name, ...) \ #define trace_and_count(_c, _name, ...) \
do { \ do { \
this_cpu_inc((_c)->counters[BCH_COUNTER_##_name]); \ count_event(_c, _name); \
trace_##_name(__VA_ARGS__); \ trace_##_name(__VA_ARGS__); \
} while (0) } while (0)
......
...@@ -321,7 +321,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans, ...@@ -321,7 +321,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
&m->stats->sectors_raced); &m->stats->sectors_raced);
} }
this_cpu_inc(c->counters[BCH_COUNTER_move_extent_fail]); count_event(c, move_extent_fail);
bch2_btree_iter_advance(&iter); bch2_btree_iter_advance(&iter);
goto next; goto next;
......
...@@ -349,7 +349,8 @@ int bch2_move_extent(struct moving_context *ctxt, ...@@ -349,7 +349,8 @@ int bch2_move_extent(struct moving_context *ctxt,
bch2_err_matches(ret, BCH_ERR_transaction_restart)) bch2_err_matches(ret, BCH_ERR_transaction_restart))
return ret; return ret;
this_cpu_inc(c->counters[BCH_COUNTER_move_extent_start_fail]); count_event(c, move_extent_start_fail);
if (trace_move_extent_start_fail_enabled()) { if (trace_move_extent_start_fail_enabled()) {
struct printbuf buf = PRINTBUF; struct printbuf buf = PRINTBUF;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment