summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-29 13:50:19 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-11-05 13:14:22 -0500
commit112e6afea516b520c70c3b0dc8eaffdde930dc17 (patch)
treed1e3315301b42b270c98a338420478a2d5b327aa
parentadfad898e14e85c8ee1677471e0f51ef8980ef37 (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.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index c2adf3fbb0b3..50493b784316 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -2971,6 +2971,8 @@ struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx)
struct btree_trans *trans;
struct btree_transaction_stats *s;
+ bch2_assert_btree_nodes_not_locked();
+
trans = bch2_trans_alloc(c);
memset(trans, 0, sizeof(*trans));