Skip to content

Commit

Permalink
bcachefs: Always rebuild aux search trees when node boundaries change
Browse files Browse the repository at this point in the history
Topology repair may change btree node min/max keys: when it does so, we
need to always rebuild eytzinger search trees because nodes directly
depend on those values.

This fixes a bug found by the 'kill_btree_node' test, where we'd pop an
assertion in bch2_bset_search_linear().

Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
koverstreet authored and Kent Overstreet committed Oct 22, 2023
1 parent 15bc094 commit bbf4288
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/bcachefs/btree_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ void bch2_btree_node_drop_keys_outside_node(struct btree *b)
(u64 *) vstruct_end(i) - (u64 *) k);
i->u64s = cpu_to_le16(le16_to_cpu(i->u64s) - shift);
set_btree_bset_end(b, t);
bch2_bset_set_no_aux_tree(b, t);
}

for (k = i->start; k != vstruct_last(i); k = bkey_next(k))
Expand All @@ -621,10 +620,14 @@ void bch2_btree_node_drop_keys_outside_node(struct btree *b)
if (k != vstruct_last(i)) {
i->u64s = cpu_to_le16((u64 *) k - (u64 *) i->start);
set_btree_bset_end(b, t);
bch2_bset_set_no_aux_tree(b, t);
}
}

/*
* Always rebuild search trees: eytzinger search tree nodes directly
* depend on the values of min/max key:
*/
bch2_bset_set_no_aux_tree(b, b->set);
bch2_btree_build_aux_trees(b);

for_each_btree_node_key_unpack(b, k, &iter, &unpacked) {
Expand Down

0 comments on commit bbf4288

Please sign in to comment.