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 <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
parent
1e68c512da
commit
b5417d2089
@ -597,10 +597,16 @@ BlockAllocator::InitializeAndClearBitmap(Transaction& transaction)
|
||||
|
||||
// reserve the boot block, the log area, and the block bitmap itself
|
||||
uint32 reservedBlocks = fVolume->Log().Start() + fVolume->Log().Length();
|
||||
|
||||
if (fGroups[0].Allocate(transaction, 0, reservedBlocks) < B_OK) {
|
||||
FATAL(("could not allocate reserved space for block bitmap/log!\n"));
|
||||
return B_ERROR;
|
||||
uint32 blocksToReserve = reservedBlocks;
|
||||
for (int32 i = 0; i < fNumGroups; i++) {
|
||||
int32 reservedBlocksInGroup = min_c(blocksToReserve, numBits);
|
||||
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
|
||||
= HOST_ENDIAN_TO_BFS_INT64(reservedBlocks);
|
||||
|
Loading…
x
Reference in New Issue
Block a user