mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 06:41:06 -04:00
bcachefs: Fix spurious transaction restarts
The check for whether locking a btree node would deadlock was wrong - we have to check that interior nodes are locked before descendents, but this check was wrong when consider cached vs. non cached iterators. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
committed by
Kent Overstreet
parent
a301dc38ef
commit
dcf141b9e1
@@ -244,6 +244,7 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos,
|
||||
* we're about to lock, it must have the ancestors locked too:
|
||||
*/
|
||||
if (linked->btree_id == iter->btree_id &&
|
||||
btree_iter_is_cached(linked) == btree_iter_is_cached(iter) &&
|
||||
level > __fls(linked->nodes_locked)) {
|
||||
if (!(trans->nounlock)) {
|
||||
linked->locks_want =
|
||||
|
||||
@@ -283,6 +283,11 @@ btree_iter_type(const struct btree_iter *iter)
|
||||
return iter->flags & BTREE_ITER_TYPE;
|
||||
}
|
||||
|
||||
static inline bool btree_iter_is_cached(const struct btree_iter *iter)
|
||||
{
|
||||
return btree_iter_type(iter) == BTREE_ITER_CACHED;
|
||||
}
|
||||
|
||||
static inline struct btree_iter_level *iter_l(struct btree_iter *iter)
|
||||
{
|
||||
return iter->l + iter->level;
|
||||
|
||||
Reference in New Issue
Block a user