]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: btree_node_scan: don't re-read before initializing found_btree_node
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 20 Jul 2025 00:47:09 +0000 (20:47 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 20 Jul 2025 17:26:08 +0000 (13:26 -0400)
If the btree node is encrypted, this caused us to initialize
found_btree_node from the encrypted header.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_node_scan.c

index 42c9eb2c786e05ce5cfafaf2d54d44b5c91550b3..a3fb07c60e25f0960b6a8d46965604919648cd90 100644 (file)
@@ -168,14 +168,6 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca,
        if (BTREE_NODE_ID(bn) >= BTREE_ID_NR_MAX)
                return;
 
-       bio_reset(bio, ca->disk_sb.bdev, REQ_OP_READ);
-       bio->bi_iter.bi_sector  = offset;
-       bch2_bio_map(bio, b->data, c->opts.btree_node_size);
-
-       submit_time = local_clock();
-       submit_bio_wait(bio);
-       bch2_account_io_completion(ca, BCH_MEMBER_ERROR_read, submit_time, !bio->bi_status);
-
        rcu_read_lock();
        struct found_btree_node n = {
                .btree_id       = BTREE_NODE_ID(bn),
@@ -192,6 +184,14 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca,
        };
        rcu_read_unlock();
 
+       bio_reset(bio, ca->disk_sb.bdev, REQ_OP_READ);
+       bio->bi_iter.bi_sector  = offset;
+       bch2_bio_map(bio, b->data, c->opts.btree_node_size);
+
+       submit_time = local_clock();
+       submit_bio_wait(bio);
+       bch2_account_io_completion(ca, BCH_MEMBER_ERROR_read, submit_time, !bio->bi_status);
+
        found_btree_node_to_key(&b->key, &n);
 
        CLASS(printbuf, buf)();