summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_locking.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-08-11 19:36:24 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:38 -0400
commit4aba7d4569f70167edf183055e809a37cd73cdd1 (patch)
tree2078c37c1144867805ff9fff72fa5e0f7f230d93 /fs/bcachefs/btree_locking.h
parent11c1a62f3b872d2345c97e72700ed4d1b2511888 (diff)
downloadlinux-4aba7d4569f70167edf183055e809a37cd73cdd1.tar.gz
linux-4aba7d4569f70167edf183055e809a37cd73cdd1.tar.bz2
linux-4aba7d4569f70167edf183055e809a37cd73cdd1.zip
bcachefs: Rename lock_held_stats -> btree_transaction_stats
Going to be adding more things to this in the next patch. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_locking.h')
-rw-r--r--fs/bcachefs/btree_locking.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/fs/bcachefs/btree_locking.h b/fs/bcachefs/btree_locking.h
index 5e2cd170aea2..acc27c3c05d6 100644
--- a/fs/bcachefs/btree_locking.h
+++ b/fs/bcachefs/btree_locking.h
@@ -112,6 +112,26 @@ btree_lock_want(struct btree_path *path, int level)
return BTREE_NODE_UNLOCKED;
}
+static inline struct btree_transaction_stats *btree_trans_stats(struct btree_trans *trans)
+{
+ return trans->fn_idx < ARRAY_SIZE(trans->c->btree_transaction_stats)
+ ? &trans->c->btree_transaction_stats[trans->fn_idx]
+ : NULL;
+}
+
+static void btree_trans_lock_hold_time_update(struct btree_trans *trans,
+ struct btree_path *path, unsigned level)
+{
+#ifdef CONFIG_BCACHEFS_LOCK_TIME_STATS
+ struct btree_transaction_stats *s = btree_trans_stats(trans);
+
+ if (s)
+ __bch2_time_stats_update(&s->lock_hold_times,
+ path->l[level].lock_taken_time,
+ ktime_get_ns());
+#endif
+}
+
static inline void btree_node_unlock(struct btree_trans *trans,
struct btree_path *path, unsigned level)
{
@@ -121,15 +141,7 @@ static inline void btree_node_unlock(struct btree_trans *trans,
if (lock_type != BTREE_NODE_UNLOCKED) {
six_unlock_type(&path->l[level].b->c.lock, lock_type);
-#ifdef CONFIG_BCACHEFS_LOCK_TIME_STATS
- if (trans->lock_name_idx < BCH_LOCK_TIME_NR) {
- struct bch_fs *c = trans->c;
-
- __bch2_time_stats_update(&c->lock_held_stats.times[trans->lock_name_idx],
- path->l[level].lock_taken_time,
- ktime_get_ns());
- }
-#endif
+ btree_trans_lock_hold_time_update(trans, path, level);
}
mark_btree_node_unlocked(path, level);
}