Skip to content

Commit 87cb023

Browse files
author
Kent Overstreet
committed
bcachefs: btree node scan: handle encrypted nodes
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 031ad9e commit 87cb023

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fs/bcachefs/btree_node_scan.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,19 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca,
133133
if (le64_to_cpu(bn->magic) != bset_magic(c))
134134
return;
135135

136+
if (bch2_csum_type_is_encryption(BSET_CSUM_TYPE(&bn->keys))) {
137+
struct nonce nonce = btree_nonce(&bn->keys, 0);
138+
unsigned bytes = (void *) &bn->keys - (void *) &bn->flags;
139+
140+
bch2_encrypt(c, BSET_CSUM_TYPE(&bn->keys), nonce, &bn->flags, bytes);
141+
}
142+
136143
if (btree_id_is_alloc(BTREE_NODE_ID(bn)))
137144
return;
138145

146+
if (BTREE_NODE_LEVEL(bn) >= BTREE_MAX_DEPTH)
147+
return;
148+
139149
rcu_read_lock();
140150
struct found_btree_node n = {
141151
.btree_id = BTREE_NODE_ID(bn),

0 commit comments

Comments
 (0)