diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-12-24 07:08:45 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-06 07:24:19 +0300 |
commit | 83322e8ca8b687528765d7f4acf55ef3855004c4 (patch) | |
tree | c72bf8d2cde850eb4a2b5e15cc758ac9b5876b4d /fs | |
parent | 0d529663f04be744d6af879889c5b16e46286ce1 (diff) | |
download | linux-83322e8ca8b687528765d7f4acf55ef3855004c4.tar.xz |
bcachefs: btree_trans always has stats
reserve slot 0 for unknown (when we overflow), to avoid some branches
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 14 | ||||
-rw-r--r-- | fs/bcachefs/btree_locking.h | 9 | ||||
-rw-r--r-- | fs/bcachefs/btree_update.c | 4 |
3 files changed, 8 insertions, 19 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index d9a9e84a2a28..fa29f00e9350 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1476,9 +1476,6 @@ static void bch2_trans_update_max_paths(struct btree_trans *trans) struct printbuf buf = PRINTBUF; size_t nr = bitmap_weight(trans->paths_allocated, trans->nr_paths); - if (!s) - return; - bch2_trans_paths_to_text(&buf, trans); if (!buf.allocation_failure) { @@ -2781,8 +2778,7 @@ void *__bch2_trans_kmalloc(struct btree_trans *trans, size_t size) WARN_ON_ONCE(new_bytes > BTREE_TRANS_MEM_MAX); struct btree_transaction_stats *s = btree_trans_stats(trans); - if (s) - s->max_mem = max(s->max_mem, new_bytes); + s->max_mem = max(s->max_mem, new_bytes); new_mem = krealloc(trans->mem, new_bytes, GFP_NOWAIT|__GFP_NOWARN); if (unlikely(!new_mem)) { @@ -2919,13 +2915,11 @@ u32 bch2_trans_begin(struct btree_trans *trans) return trans->restart_count; } -const char *bch2_btree_transaction_fns[BCH_TRANSACTIONS_NR]; +const char *bch2_btree_transaction_fns[BCH_TRANSACTIONS_NR] = { "(unknown)" }; unsigned bch2_trans_get_fn_idx(const char *fn) { - unsigned i; - - for (i = 0; i < ARRAY_SIZE(bch2_btree_transaction_fns); i++) + for (unsigned i = 0; i < ARRAY_SIZE(bch2_btree_transaction_fns); i++) if (!bch2_btree_transaction_fns[i] || bch2_btree_transaction_fns[i] == fn) { bch2_btree_transaction_fns[i] = fn; @@ -2933,7 +2927,7 @@ unsigned bch2_trans_get_fn_idx(const char *fn) } pr_warn_once("BCH_TRANSACTIONS_NR not big enough!"); - return i; + return 0; } struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx) diff --git a/fs/bcachefs/btree_locking.h b/fs/bcachefs/btree_locking.h index 64810ea544c9..cc5500a957a1 100644 --- a/fs/bcachefs/btree_locking.h +++ b/fs/bcachefs/btree_locking.h @@ -122,12 +122,9 @@ 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, - local_clock()); + __bch2_time_stats_update(&btree_trans_stats(trans)->lock_hold_times, + path->l[level].lock_taken_time, + local_clock()); #endif } diff --git a/fs/bcachefs/btree_update.c b/fs/bcachefs/btree_update.c index 83aa0fb8ba93..c3ff365acce9 100644 --- a/fs/bcachefs/btree_update.c +++ b/fs/bcachefs/btree_update.c @@ -557,9 +557,7 @@ struct jset_entry *__bch2_trans_jset_entry_alloc(struct btree_trans *trans, unsi if (new_top > trans->journal_entries_size) { trans->journal_entries_size = roundup_pow_of_two(new_top); - struct btree_transaction_stats *s = btree_trans_stats(trans); - if (s) - s->journal_entries_size = trans->journal_entries_size; + btree_trans_stats(trans)->journal_entries_size = trans->journal_entries_size; } struct jset_entry *n = |