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:
parent
284f17739e
commit
1e0016e1a9
@ -15,6 +15,7 @@
|
||||
#include "Block.h"
|
||||
#include "checksumfs.h"
|
||||
#include "DebugSupport.h"
|
||||
#include "SuperBlock.h"
|
||||
#include "Volume.h"
|
||||
|
||||
|
||||
@ -177,12 +178,18 @@ dprintf("BlockAllocator::Allocate(%llu, %llu)\n", baseHint, count);
|
||||
// search from base hint to end
|
||||
status_t error = _Allocate(baseHint, fTotalBlocks, count, transaction,
|
||||
&_allocatedBase, _allocatedCount);
|
||||
if (error == B_OK || baseHint == 0)
|
||||
if (error == B_OK)
|
||||
return _UpdateSuperBlock(transaction);
|
||||
if (baseHint == 0)
|
||||
return error;
|
||||
|
||||
// search from 0 to hint
|
||||
return _Allocate(0, baseHint, count, transaction, &_allocatedBase,
|
||||
error = _Allocate(0, baseHint, count, transaction, &_allocatedBase,
|
||||
_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_OK;
|
||||
return _UpdateSuperBlock(transaction);
|
||||
}
|
||||
|
||||
|
||||
@ -213,7 +220,11 @@ BlockAllocator::Free(uint64 base, uint64 count, Transaction& transaction)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
Transaction& transaction);
|
||||
|
||||
status_t _UpdateSuperBlock(Transaction& transaction);
|
||||
|
||||
private:
|
||||
mutex fLock;
|
||||
Volume* fVolume;
|
||||
|
@ -45,3 +45,10 @@ SuperBlock::Initialize(Volume* volume)
|
||||
rootDir = volume->RootDirectory()->BlockIndex();
|
||||
strlcpy(name, volume->Name(), kCheckSumFSNameLength);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SuperBlock::SetFreeBlocks(uint64 count)
|
||||
{
|
||||
freeBlocks = count;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ public:
|
||||
|
||||
bool Check(uint64 totalBlocks) const;
|
||||
void Initialize(Volume* volume);
|
||||
|
||||
void SetFreeBlocks(uint64 count);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user