[haiku-commits] haiku: hrev56221 - src/add-ons/kernel/file_systems/bfs

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 28 Jun 2022 06:02:22 +0000 (UTC)

hrev56221 adds 1 changeset to branch 'master'
old head: 1e68c512dab5b5601325479cdd9b0a533763cbb1
new head: b5417d2089cd46d9ce92aeec2339d1831f715737
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b5417d2089cd+%5E1e68c512dab5

----------------------------------------------------------------------------

b5417d2089cd: 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@xxxxxxxxx>
  Tested-by: Commit checker robot <no-reply+buildbot@xxxxxxxxxxxx>

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev56221
Commit:      b5417d2089cd46d9ce92aeec2339d1831f715737
URL:         https://git.haiku-os.org/haiku/commit/?id=b5417d2089cd
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Mon Jun 27 15:37:44 2022 UTC

Ticket:      https://dev.haiku-os.org/ticket/11753

----------------------------------------------------------------------------

1 file changed, 10 insertions(+), 4 deletions(-)
src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp | 14 ++++++++++----

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp 
b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
index af0bdaa831..949e9a67ea 100644
--- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
@@ -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);


Other related posts:

  • » [haiku-commits] haiku: hrev56221 - src/add-ons/kernel/file_systems/bfs - Jérôme Duval