From a1d46e1a926b90d965ec87a034e504d4a4b41b58 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 10 Jun 2021 17:38:32 -0700 Subject: [PATCH] Fix mkfs btree item offset calculation mkfs was miscalculating the offset of the start of the free region in the center of blocks as it populated blocks with items. It was using the length of the free region as its offset in the block. To find the offset of the end of the free region in the block it has to be taken relative to the end of the item array. Signed-off-by: Zach Brown --- utils/src/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/btree.c b/utils/src/btree.c index 9224f9de..201c47a5 100644 --- a/utils/src/btree.c +++ b/utils/src/btree.c @@ -40,7 +40,7 @@ static void *alloc_val(struct scoutfs_btree_block *bt, int len) { le16_add_cpu(&bt->mid_free_len, -len); le16_add_cpu(&bt->total_item_bytes, len); - return (void *)bt + le16_to_cpu(bt->mid_free_len); + return (void *)&bt->items[le16_to_cpu(bt->nr_items)] + le16_to_cpu(bt->mid_free_len); } /*