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 <[email protected]> Tested-by: Commit checker robot <[email protected]> Haiku-Format: Haiku-format Bot <[email protected]>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user