bcachefs: Set BTREE_NODE_SEQ() correctly in merge path
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 22 Feb 2022 22:16:45 +0000 (17:16 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:25 +0000 (17:09 -0400)
BTREE_NODE_SEQ() is supposed to give us a time ordering of btree nodes
on disk, so that we can tell which btree node is newer if we ever have
to scan the entire device to find btree nodes.

The btree node merge path wasn't setting it correctly on the new node -
oops.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/btree_update_interior.c

index 07bece908691efc485fc1cb057ea55b1bcf90f9c..644ac4e5d1d10122aee569e92b8a110e64bce309 100644 (file)
@@ -1697,6 +1697,10 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
        n = bch2_btree_node_alloc(as, b->c.level);
        bch2_btree_update_add_new_node(as, n);
 
+       SET_BTREE_NODE_SEQ(n->data,
+                          max(BTREE_NODE_SEQ(b->data),
+                              BTREE_NODE_SEQ(m->data)) + 1);
+
        btree_set_min(n, prev->data->min_key);
        btree_set_max(n, next->data->max_key);
        n->data->format         = new_f;