History

bcachefs: btree_node_scan: don't re-read before initializing found_btree_node

If the btree node is encrypted, this caused us to initialize found_btree_node from the encrypted header.

Kent Overstreet committed 1 year ago

Commit eef91701 parent 89edfcf1 file · +8 −8Browse files

Unified · Split

fs/bcachefs/btree_node_scan.c+8−8
@@ -168,14 +168,6 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca, · 167 unmodified lines
168 if (BTREE_NODE_ID(bn) >= BTREE_ID_NR_MAX)168 if (BTREE_NODE_ID(bn) >= BTREE_ID_NR_MAX)
169 return;169 return;
170 170
171 bio_reset(bio, ca->disk_sb.bdev, REQ_OP_READ);
172 bio->bi_iter.bi_sector = offset;
173 bch2_bio_map(bio, b->data, c->opts.btree_node_size);
174
175 submit_time = local_clock();
176 submit_bio_wait(bio);
177 bch2_account_io_completion(ca, BCH_MEMBER_ERROR_read, submit_time, !bio->bi_status);
178
179 rcu_read_lock();171 rcu_read_lock();
180 struct found_btree_node n = {172 struct found_btree_node n = {
181 .btree_id = BTREE_NODE_ID(bn),173 .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, · 10 unmodified lines
192 };184 };
193 rcu_read_unlock();185 rcu_read_unlock();
194 186
187 bio_reset(bio, ca->disk_sb.bdev, REQ_OP_READ);
188 bio->bi_iter.bi_sector = offset;
189 bch2_bio_map(bio, b->data, c->opts.btree_node_size);
190
191 submit_time = local_clock();
192 submit_bio_wait(bio);
193 bch2_account_io_completion(ca, BCH_MEMBER_ERROR_read, submit_time, !bio->bi_status);
194
195 found_btree_node_to_key(&b->key, &n);195 found_btree_node_to_key(&b->key, &n);
196 196
197 CLASS(printbuf, buf)();197 CLASS(printbuf, buf)();