diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-17 07:03:11 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:44 -0400 |
commit | 307e3c13192002f684bdfc23865a57274e6bb4ad (patch) | |
tree | 56645bb36c8efcec63ed0aaa4f6db836ad5b81e2 /fs/bcachefs/btree_iter.h | |
parent | 29aa78f15e1bbd984cc14f395544d62b6f0a2a33 (diff) | |
download | lwn-307e3c13192002f684bdfc23865a57274e6bb4ad.tar.gz lwn-307e3c13192002f684bdfc23865a57274e6bb4ad.zip |
bcachefs: Optimize bch2_trans_init()
Now we store the transaction's fn idx in a local variable, instead of
redoing the lookup every time we call bch2_trans_init().
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_iter.h')
-rw-r--r-- | fs/bcachefs/btree_iter.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 2e94cd2657e9..cfbd07bc9366 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -587,10 +587,21 @@ void bch2_btree_path_to_text(struct printbuf *, struct btree_path *); void bch2_trans_paths_to_text(struct printbuf *, struct btree_trans *); void bch2_dump_trans_updates(struct btree_trans *); void bch2_dump_trans_paths_updates(struct btree_trans *); -void __bch2_trans_init(struct btree_trans *, struct bch_fs *, const char *); +void __bch2_trans_init(struct btree_trans *, struct bch_fs *, unsigned); void bch2_trans_exit(struct btree_trans *); -#define bch2_trans_init(_trans, _c, _nr_iters, _mem) __bch2_trans_init(_trans, _c, __func__) +extern const char *bch2_btree_transaction_fns[BCH_TRANSACTIONS_NR]; +unsigned bch2_trans_get_fn_idx(const char *); + +#define bch2_trans_init(_trans, _c, _nr_iters, _mem) \ +do { \ + static unsigned trans_fn_idx; \ + \ + if (unlikely(!trans_fn_idx)) \ + trans_fn_idx = bch2_trans_get_fn_idx(__func__); \ + \ + __bch2_trans_init(_trans, _c, trans_fn_idx); \ +} while (0) void bch2_btree_trans_to_text(struct printbuf *, struct btree_trans *); |