diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-08-23 04:05:31 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:39 +0300 |
commit | 131dcd5af7e2f1b13c2c0baf3095d7e449eb9859 (patch) | |
tree | 6a69d5c203e63d9b1a637f38519c5b4486a881fb /fs/bcachefs/btree_locking.c | |
parent | c240c3a94427346f27a7ff48f02cbe03f2c2ebd6 (diff) | |
download | linux-131dcd5af7e2f1b13c2c0baf3095d7e449eb9859.tar.xz |
bcachefs: Track held write locks
The upcoming lock cycle detection code will need to know precisely which
locks every btree_trans is holding, including write locks - this patch
updates btree_node_locked_type to include write locks.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_locking.c')
-rw-r--r-- | fs/bcachefs/btree_locking.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 84d1e37a0741..be288fb96ea2 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -246,6 +246,8 @@ bool bch2_btree_node_upgrade(struct btree_trans *trans, return bch2_btree_node_relock(trans, path, level); case BTREE_NODE_INTENT_LOCKED: break; + case BTREE_NODE_WRITE_LOCKED: + BUG(); } if (btree_node_intent_locked(path, level)) @@ -448,9 +450,17 @@ void bch2_btree_path_verify_locks(struct btree_path *path) return; } - for (l = 0; btree_path_node(path, l); l++) - BUG_ON(btree_lock_want(path, l) != - btree_node_locked_type(path, l)); + for (l = 0; l < BTREE_MAX_DEPTH; l++) { + int want = btree_lock_want(path, l); + int have = btree_node_locked_type(path, l); + + BUG_ON(!is_btree_node(path, l) && have != BTREE_NODE_UNLOCKED); + + BUG_ON(is_btree_node(path, l) && + (want == BTREE_NODE_UNLOCKED || + have != BTREE_NODE_WRITE_LOCKED) && + want != have); + } } void bch2_trans_verify_locks(struct btree_trans *trans) |