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

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 20 Jul 2012 01:02:40 +0200 (CEST)

hrev44359 adds 2 changesets to branch 'master'
old head: 173f54f1473bd6a6511c5fc6dc899c91fb8dd667
new head: 02378956042046a9fc635820f73d2cbeb7a4b5df

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

d9879ed: A duplicate array with a single value is not allowed
  
  Such arrays could be created by the BFS code between hrev43837 and
  hrev43924, and cause the array to not be free'd when the entry is
  removed.
  
  The check in _InsertDuplicate() is not changed, as doing an insertion
  will actually repair this problem.
  
  Potentially, the code could be modified to handle this state instead,
  but since checkfs can fix it, it doesn't seem necessary.
  
  Signed-off-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

0237895: CheckBlocks() calculated the group block incorrectly
  
  Signed-off-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

                                      [ ahenriksson <sausageboy@xxxxxxxxx> ]

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

2 files changed, 7 insertions(+), 5 deletions(-)
src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp  |    4 ++--
.../kernel/file_systems/bfs/BlockAllocator.cpp     |    8 +++++---

############################################################################

Commit:      d9879eddbf9e4b01f07679af1769e9f439d4e0ef
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d9879ed
Author:      ahenriksson <sausageboy@xxxxxxxxx>
Date:        Tue Jul 17 19:11:18 2012 UTC
Committer:   Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Commit-Date: Thu Jul 19 23:02:03 2012 UTC

A duplicate array with a single value is not allowed

Such arrays could be created by the BFS code between hrev43837 and
hrev43924, and cause the array to not be free'd when the entry is
removed.

The check in _InsertDuplicate() is not changed, as doing an insertion
will actually repair this problem.

Potentially, the code could be modified to handle this state instead,
but since checkfs can fix it, it doesn't seem necessary.

Signed-off-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

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

diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 
b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
index 90972f3..51b896a 100644
--- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
@@ -1782,7 +1782,7 @@ BPlusTree::_RemoveDuplicate(Transaction& transaction,
                        bplustree_node::FragmentIndex(oldValue));
                int32 arrayCount = array->Count();
 
-               if (arrayCount > NUM_FRAGMENT_VALUES || arrayCount < 1) {
+               if (arrayCount > NUM_FRAGMENT_VALUES || arrayCount <= 1) {
                        FATAL(("_RemoveDuplicate: Invalid array[%d] size in 
fragment %"
                                B_PRIdOFF " == %" B_PRId32 ", inode %" 
B_PRIdOFF "!\n",
                                (int)bplustree_node::FragmentIndex(oldValue), 
duplicateOffset,
@@ -2361,7 +2361,7 @@ BPlusTree::_ValidateChildren(TreeCheck& check, uint32 
level, off_t offset,
                                }
                                int32 arrayCount = array->Count();
 
-                               if (arrayCount < 1 || arrayCount > maxSize) {
+                               if (arrayCount <= 1 || arrayCount > maxSize) {
                                        dprintf("inode %" B_PRIdOFF ": 
duplicate at %" B_PRIdOFF
                                                " has invalid array size %" 
B_PRId32 "!\n",
                                                fStream->ID(), duplicateOffset, 
arrayCount);

############################################################################

Revision:    hrev44359
Commit:      02378956042046a9fc635820f73d2cbeb7a4b5df
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0237895
Author:      ahenriksson <sausageboy@xxxxxxxxx>
Date:        Tue Jul 17 19:23:22 2012 UTC
Committer:   Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Commit-Date: Thu Jul 19 23:02:05 2012 UTC

CheckBlocks() calculated the group block incorrectly

Signed-off-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

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

diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp 
b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
index 8dc8f3f..b0d446f 100644
--- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
@@ -1699,9 +1699,11 @@ BlockAllocator::CheckBlocks(off_t start, off_t length, 
bool allocated)
        if (start < 0 || start + length > fVolume->NumBlocks())
                return B_BAD_VALUE;
 
-       uint32 group = start >> fVolume->AllocationGroupShift();
-       uint32 groupBlock = start / (fVolume->BlockSize() << 3);
-       uint32 blockOffset = start % fVolume->BlockSize();
+       int32 group = start >> fVolume->AllocationGroupShift();
+       uint32 bitmapBlock = start / (fVolume->BlockSize() << 3);
+       uint32 blockOffset = start % (fVolume->BlockSize() << 3);
+
+       uint32 groupBlock = bitmapBlock % fBlocksPerGroup;
 
        AllocationBlock cached(fVolume);
 


Other related posts:

  • » [haiku-commits] haiku: hrev44359 - src/add-ons/kernel/file_systems/bfs - axeld