BlockAllocator didn't update the freeBlocks field in the superblock. So after
unmounting and remounting the number of free blocks could be off. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37588 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
#include "checksumfs.h"
|
#include "checksumfs.h"
|
||||||
#include "DebugSupport.h"
|
#include "DebugSupport.h"
|
||||||
|
#include "SuperBlock.h"
|
||||||
#include "Volume.h"
|
#include "Volume.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -177,12 +178,18 @@ dprintf("BlockAllocator::Allocate(%llu, %llu)\n", baseHint, count);
|
|||||||
// search from base hint to end
|
// search from base hint to end
|
||||||
status_t error = _Allocate(baseHint, fTotalBlocks, count, transaction,
|
status_t error = _Allocate(baseHint, fTotalBlocks, count, transaction,
|
||||||
&_allocatedBase, _allocatedCount);
|
&_allocatedBase, _allocatedCount);
|
||||||
if (error == B_OK || baseHint == 0)
|
if (error == B_OK)
|
||||||
|
return _UpdateSuperBlock(transaction);
|
||||||
|
if (baseHint == 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
// search from 0 to hint
|
// search from 0 to hint
|
||||||
return _Allocate(0, baseHint, count, transaction, &_allocatedBase,
|
error = _Allocate(0, baseHint, count, transaction, &_allocatedBase,
|
||||||
_allocatedCount);
|
_allocatedCount);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return _UpdateSuperBlock(transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -204,7 +211,7 @@ dprintf("BlockAllocator::AllocateExactly(%llu, %llu)\n", base, count);
|
|||||||
return B_BUSY;
|
return B_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return _UpdateSuperBlock(transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -213,7 +220,11 @@ BlockAllocator::Free(uint64 base, uint64 count, Transaction& transaction)
|
|||||||
{
|
{
|
||||||
MutexLocker locker(fLock);
|
MutexLocker locker(fLock);
|
||||||
|
|
||||||
return _Free(base, count, transaction);
|
status_t error = _Free(base, count, transaction);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return _UpdateSuperBlock(transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -695,3 +706,22 @@ dprintf("BlockAllocator::_FreeInBitmapBlock(%llu, %lu)\n", base, count);
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BlockAllocator::_UpdateSuperBlock(Transaction& transaction)
|
||||||
|
{
|
||||||
|
// write the super block
|
||||||
|
Block block;
|
||||||
|
if (!block.GetWritable(fVolume, kCheckSumFSSuperBlockOffset / B_PAGE_SIZE,
|
||||||
|
transaction)) {
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
SuperBlock* superBlock = (SuperBlock*)block.Data();
|
||||||
|
superBlock->SetFreeBlocks(fFreeBlocks);
|
||||||
|
|
||||||
|
block.Put();
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ private:
|
|||||||
status_t _FreeInBitmapBlock(uint64 base, uint32 count,
|
status_t _FreeInBitmapBlock(uint64 base, uint32 count,
|
||||||
Transaction& transaction);
|
Transaction& transaction);
|
||||||
|
|
||||||
|
status_t _UpdateSuperBlock(Transaction& transaction);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutex fLock;
|
mutex fLock;
|
||||||
Volume* fVolume;
|
Volume* fVolume;
|
||||||
|
|||||||
@@ -45,3 +45,10 @@ SuperBlock::Initialize(Volume* volume)
|
|||||||
rootDir = volume->RootDirectory()->BlockIndex();
|
rootDir = volume->RootDirectory()->BlockIndex();
|
||||||
strlcpy(name, volume->Name(), kCheckSumFSNameLength);
|
strlcpy(name, volume->Name(), kCheckSumFSNameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SuperBlock::SetFreeBlocks(uint64 count)
|
||||||
|
{
|
||||||
|
freeBlocks = count;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public:
|
|||||||
|
|
||||||
bool Check(uint64 totalBlocks) const;
|
bool Check(uint64 totalBlocks) const;
|
||||||
void Initialize(Volume* volume);
|
void Initialize(Volume* volume);
|
||||||
|
|
||||||
|
void SetFreeBlocks(uint64 count);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user