[haiku-commits] Change in haiku[master]: bfs: take in account the block_run allocation group when computing re...

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 29 Jun 2022 07:20:59 +0000

From Jérôme Duval <jerome.duval@xxxxxxxxx>:

Jérôme Duval has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/5420 ;)


Change subject: bfs: take in account the block_run allocation group when 
computing reserved blocks.
......................................................................

bfs: take in account the block_run allocation group when computing reserved 
blocks.

after hrev56221, the block bitmaps can span over multiple allocation groups.
Blocks would be allocated in the block bitmaps, especially root indexes (for 
instance 2.5TB, blocksize 2k).
---
M src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
M src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
2 files changed, 9 insertions(+), 4 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/20/5420/1

diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp 
b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
index 949e9a6..9c0383e 100644
--- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
@@ -596,7 +596,8 @@
        free(buffer);

        // reserve the boot block, the log area, and the block bitmap itself
-       uint32 reservedBlocks = fVolume->Log().Start() + 
fVolume->Log().Length();
+       uint32 reservedBlocks = numBits * fVolume->Log().AllocationGroup()
+               + fVolume->Log().Start() + fVolume->Log().Length();
        uint32 blocksToReserve = reservedBlocks;
        for (int32 i = 0; i < fNumGroups; i++) {
                int32 reservedBlocksInGroup = min_c(blocksToReserve, numBits);
@@ -680,7 +681,8 @@
        free(buffer);

        // check if block bitmap and log area are reserved
-       uint32 reservedBlocks = volume->Log().Start() + volume->Log().Length();
+       uint32 reservedBlocks = bitsPerGroup * volume->Log().AllocationGroup()
+               + volume->Log().Start() + volume->Log().Length();

        if (allocator->CheckBlocks(0, reservedBlocks) != B_OK) {
                if (volume->IsReadOnly()) {
diff --git a/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp 
b/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
index 1bd71c2..78bdce4 100644
--- a/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
@@ -63,10 +63,13 @@

        memset(&Control().stats, 0, sizeof(check_control::stats));

+       uint32 blocksPerGroup = 
GetVolume()->SuperBlock().BlocksPerAllocationGroup();
+       uint32 numBits = (blocksPerGroup << GetVolume()->BlockShift()) * 8;
+
        // initialize bitmap
        memset(fCheckBitmap, 0, size);
-       for (int32 block = GetVolume()->Log().Start() + 
GetVolume()->Log().Length();
-                       block-- > 0;) {
+       for (int32 block = numBits * GetVolume()->Log().AllocationGroup()
+               + GetVolume()->Log().Start() + GetVolume()->Log().Length(); 
block-- > 0;) {
                _SetCheckBitmapAt(block);
        }


--
To view, visit https://review.haiku-os.org/c/haiku/+/5420
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I35d21d48e84945e5f949a272d530c466ae6506ac
Gerrit-Change-Number: 5420
Gerrit-PatchSet: 1
Gerrit-Owner: Jérôme Duval <jerome.duval@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: bfs: take in account the block_run allocation group when computing re... - Gerrit