diff options
| author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-09 23:53:57 -0400 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-23 07:59:43 -0400 |
| commit | b41ac97fe0a6876edbc6fc90dfd05513ba7332ed (patch) | |
| tree | 80da5cedf03bad7e75c63ce5e78327b39f51713d /fs/bcachefs/btree_locking.c | |
| parent | bcachefs: Simplify bch2_path_put() (diff) | |
| download | linux-b41ac97fe0a6876edbc6fc90dfd05513ba7332ed.tar.gz linux-b41ac97fe0a6876edbc6fc90dfd05513ba7332ed.zip | |
bcachefs: Path must be locked if trans->locked && should_be_locked
If path->should_be_locked is true, that means user code (of the btree
API) has seen, in this transaction, something guarded by the node this
path has locked, and we have to keep it locked until the end of the
transaction.
Assert that we're not violating this; should_be_locked should also be
cleared only in _very_ special situations.
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 | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 2cdc9a04f3e8..2f2aed0c9916 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -882,14 +882,15 @@ int __bch2_trans_mutex_lock(struct btree_trans *trans, void __bch2_btree_path_verify_locks(struct btree_trans *trans, struct btree_path *path) { - /* - * A path may be uptodate and yet have nothing locked if and only if - * there is no node at path->level, which generally means we were - * iterating over all nodes and got to the end of the btree - */ - BUG_ON(path->uptodate == BTREE_ITER_UPTODATE && - btree_path_node(path, path->level) && - !path->nodes_locked); + if (!path->nodes_locked && btree_path_node(path, path->level)) { + /* + * A path may be uptodate and yet have nothing locked if and only if + * there is no node at path->level, which generally means we were + * iterating over all nodes and got to the end of the btree + */ + BUG_ON(path->uptodate == BTREE_ITER_UPTODATE); + BUG_ON(path->should_be_locked && trans->locked && !trans->restarted); + } if (!path->nodes_locked) return; |
