mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 18:12:25 -04:00
bcachefs: Don't downgrade iterators in bch2_trans_get_iter()
This fixes a livelock with btree node splits. 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
2527dd9158
commit
558509aa01
@@ -2038,13 +2038,18 @@ struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans,
|
||||
|
||||
iter->snapshot = pos.snapshot;
|
||||
|
||||
locks_want = min(locks_want, BTREE_MAX_DEPTH);
|
||||
/*
|
||||
* If the iterator has locks_want greater than requested, we explicitly
|
||||
* do not downgrade it here - on transaction restart because btree node
|
||||
* split needs to upgrade locks, we might be putting/getting the
|
||||
* iterator again. Downgrading iterators only happens via an explicit
|
||||
* bch2_trans_downgrade().
|
||||
*/
|
||||
|
||||
locks_want = min(locks_want, BTREE_MAX_DEPTH);
|
||||
if (locks_want > iter->locks_want) {
|
||||
iter->locks_want = locks_want;
|
||||
btree_iter_get_locks(iter, true, false);
|
||||
} else if (locks_want < iter->locks_want) {
|
||||
__bch2_btree_iter_downgrade(iter, locks_want);
|
||||
}
|
||||
|
||||
while (iter->level < depth) {
|
||||
|
||||
Reference in New Issue
Block a user