From edac63079f5378f05cc83359857ee171faf88ce5 Mon Sep 17 00:00:00 2001 From: dalme Date: Sat, 16 Nov 2024 18:33:40 +0100 Subject: [PATCH] BFS: Be explicit about blocks_per_ag field meaning Superblock field blocks_per_ag is confusing, as it holds the number of bitmap blocks that are in each allocation group, not the number of disk blocks per allocation group. Try to clarify when possible. Change-Id: I60dad9d3c5245dd126ecfea817108e2cefa4cf02 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8566 Reviewed-by: waddlesplash Tested-by: Commit checker robot Haiku-Format: Haiku-format Bot --- src/add-ons/kernel/file_systems/bfs/Volume.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp b/src/add-ons/kernel/file_systems/bfs/Volume.cpp index 0404b74dc7..4c8f5441fc 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp @@ -82,7 +82,7 @@ disk_super_block::Initialize(const char* diskName, off_t numBlocks, int32 bitsPerBlock = blockSize << 3; off_t bitmapBlocks = (numBlocks + bitsPerBlock - 1) / bitsPerBlock; - int32 blocksPerGroup = 1; + int32 bitmapBlocksPerGroup = 1; int32 groupShift = 13; for (int32 i = 8192; i < bitsPerBlock; i *= 2) { @@ -97,19 +97,20 @@ disk_super_block::Initialize(const char* diskName, off_t numBlocks, int32 numGroups; while (true) { - numGroups = (bitmapBlocks + blocksPerGroup - 1) / blocksPerGroup; + numGroups = (bitmapBlocks + bitmapBlocksPerGroup - 1) / bitmapBlocksPerGroup; if (numGroups > kDesiredAllocationGroups) { if (groupShift == 16) break; groupShift++; - blocksPerGroup *= 2; + bitmapBlocksPerGroup *= 2; } else break; } num_ags = HOST_ENDIAN_TO_BFS_INT32(numGroups); - blocks_per_ag = HOST_ENDIAN_TO_BFS_INT32(blocksPerGroup); + // blocks_per_ag holds the number of bitmap blocks that are in each allocation group + blocks_per_ag = HOST_ENDIAN_TO_BFS_INT32(bitmapBlocksPerGroup); ag_shift = HOST_ENDIAN_TO_BFS_INT32(groupShift); }