diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-12-29 13:50:19 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-02-17 02:19:59 -0500 |
commit | be30be94e6f519864ad7283694928dbcc17007ee (patch) | |
tree | d64a1afa48fc840c47a20785d6e7e3d8afc7ff8f | |
parent | e8b0ae8923064ce13c9c825a8a450836ed451f64 (diff) |
bcachefs: Check for btree locks held on transaction init
Ideally we would disallow multiple btree_trans being initialized within
the same process - and hopefully we will at some point, the stack usage
is excessive - but for now there are a couple places where we do this:
- transaction commit error path -> journal reclaim - btree key cache
flush
- move data path -> do_pending_writes -> write path -> bucket
allocation (in the near future when bucket allocation switches to
using a freespace btree)
In order to avoid deadlocking the first btree_trans must have been
unlocked with bch2_trans_unlock() before using the second btree_trans -
this patch adds an assertion to bch2_trans_init() that verifies that
this has been done when lockdep is enabled.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/btree_iter.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 39db0d08063f..565c811703ca 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3076,6 +3076,8 @@ void __bch2_trans_init(struct btree_trans *trans, struct bch_fs *c, const char *fn) __acquires(&c->btree_trans_barrier) { + BUG_ON(lock_class_is_held(&bch2_btree_node_lock_key)); + memset(trans, 0, sizeof(*trans)); trans->c = c; trans->fn = fn; |