Skip to content

Commit 5510a4a

Browse files
author
Kent Overstreet
committed
bcachefs: Fix split_race livelock
bch2_btree_update_start() calculates which nodes are going to have to be split/rewritten, so that we know how many nodes to reserve and how deep in the tree we have to take locks. But btree node merges require inserting two keys into the parent node, not just splits. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 03013bb commit 5510a4a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/bcachefs/btree_update_interior.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,12 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
10711071
break;
10721072
}
10731073

1074+
/*
1075+
* Always check for space for two keys, even if we won't have to
1076+
* split at prior level - it might have been a merge instead:
1077+
*/
10741078
if (bch2_btree_node_insert_fits(c, path->l[update_level].b,
1075-
BKEY_BTREE_PTR_U64s_MAX * (1 + split)))
1079+
BKEY_BTREE_PTR_U64s_MAX * 2))
10761080
break;
10771081

10781082
split = path->l[update_level].b->nr.live_u64s > BTREE_SPLIT_THRESHOLD(c);

0 commit comments

Comments
 (0)