bfs: don't allocate more than the maximum in an AllocationGroup
* The reserved blocks could exhaust the first allocation group, so iterate as much as needed. * fix #11753 Change-Id: Ib1d7f87946f7b96dfcade8f5778a14065d965f6b Reviewed-on: https://review.haiku-os.org/c/haiku/+/5417 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -597,10 +597,16 @@ BlockAllocator::InitializeAndClearBitmap(Transaction& transaction)
|
|||||||
|
|
||||||
// reserve the boot block, the log area, and the block bitmap itself
|
// reserve the boot block, the log area, and the block bitmap itself
|
||||||
uint32 reservedBlocks = fVolume->Log().Start() + fVolume->Log().Length();
|
uint32 reservedBlocks = fVolume->Log().Start() + fVolume->Log().Length();
|
||||||
|
uint32 blocksToReserve = reservedBlocks;
|
||||||
if (fGroups[0].Allocate(transaction, 0, reservedBlocks) < B_OK) {
|
for (int32 i = 0; i < fNumGroups; i++) {
|
||||||
FATAL(("could not allocate reserved space for block bitmap/log!\n"));
|
int32 reservedBlocksInGroup = min_c(blocksToReserve, numBits);
|
||||||
return B_ERROR;
|
if (fGroups[i].Allocate(transaction, 0, reservedBlocksInGroup) < B_OK) {
|
||||||
|
FATAL(("could not allocate reserved space for block bitmap/log!\n"));
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
blocksToReserve -= reservedBlocksInGroup;
|
||||||
|
if (blocksToReserve == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
fVolume->SuperBlock().used_blocks
|
fVolume->SuperBlock().used_blocks
|
||||||
= HOST_ENDIAN_TO_BFS_INT64(reservedBlocks);
|
= HOST_ENDIAN_TO_BFS_INT64(reservedBlocks);
|
||||||
|
|||||||
Reference in New Issue
Block a user