The length of bset is variable, and is not fixed to a block size. To traverse bsets in a node, use set_bytes to help calculate the pointer to the next bset instead of block_bytes in bch_btree_node_read_done. Signed-off-by: Shenghui Wang <shhuiw@xxxxxxxxxxx> --- drivers/md/bcache/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index e7d4817681f2..86c94505a408 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -258,7 +258,7 @@ void bch_btree_node_read_done(struct btree *b) err = "corrupted btree"; for (i = write_block(b); bset_sector_offset(&b->keys, i) < KEY_SIZE(&b->key); - i = ((void *) i) + block_bytes(b->c)) + i = ((void *) i) + set_bytes(i)) if (i->seq == b->keys.set[0].data->seq) goto err; -- 2.18.0