Skip to content

Commit eb34365

Browse files
author
Kent Overstreet
committed
bcachefs: Clear should_be_locked before unlock in key_cache_drop()
We're adding new should_be_locked assertions, also add a comment explaining why clearing should_be_locked is safe here. Signed-off-by: Kent Overstreet <[email protected]>
1 parent be9fecd commit eb34365

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/bcachefs/btree_key_cache.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,16 @@ void bch2_btree_key_cache_drop(struct btree_trans *trans,
646646
unsigned i;
647647
trans_for_each_path(trans, path2, i)
648648
if (path2->l[0].b == (void *) ck) {
649+
/*
650+
* It's safe to clear should_be_locked here because
651+
* we're evicting from the key cache, and we still have
652+
* the underlying btree locked: filling into the key
653+
* cache would require taking a write lock on the btree
654+
* node
655+
*/
656+
path2->should_be_locked = false;
649657
__bch2_btree_path_unlock(trans, path2);
650658
path2->l[0].b = ERR_PTR(-BCH_ERR_no_btree_node_drop);
651-
path2->should_be_locked = false;
652659
btree_path_set_dirty(path2, BTREE_ITER_NEED_TRAVERSE);
653660
}
654661

0 commit comments

Comments
 (0)