* Added a very simple way to fragment your disk.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33674 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-10-20 00:23:53 +00:00
parent 234d8e02b7
commit aeb099b317
3 changed files with 45 additions and 0 deletions

View File

@ -1062,6 +1062,37 @@ BlockAllocator::BitmapSize() const
}
#ifdef DEBUG_FRAGMENTER
void
BlockAllocator::Fragment()
{
AllocationBlock cached(fVolume);
MutexLocker lock(fLock);
// only leave 4 block holes
static const uint32 kMask = 0x0f0f0f0f;
uint32 valuesPerBlock = fVolume->BlockSize() / 4;
for (int32 i = 0; i < fNumGroups; i++) {
AllocationGroup& group = fGroups[i];
for (uint32 block = 0; block < group.NumBlocks(); block++) {
Transaction transaction(fVolume, 0);
if (cached.SetToWritable(transaction, group, block) != B_OK)
return;
for (int32 index = 0; index < valuesPerBlock; index++) {
cached.Block(index) |= HOST_ENDIAN_TO_BFS_INT32(kMask);
}
transaction.Done();
}
}
}
#endif // DEBUG_FRAGMENTER
#ifdef DEBUG_ALLOCATION_GROUPS
void
BlockAllocator::_CheckGroup(int32 groupIndex) const

View File

@ -21,6 +21,7 @@ struct check_cookie;
//#define DEBUG_ALLOCATION_GROUPS
//#define DEBUG_FRAGMENTER
class BlockAllocator {
@ -63,6 +64,9 @@ public:
#ifdef BFS_DEBUGGER_COMMANDS
void Dump(int32 index);
#endif
#ifdef DEBUG_FRAGMENTER
void Fragment();
#endif
private:
status_t _RemoveInvalidNode(Inode* parent, BPlusTree* tree,

View File

@ -682,6 +682,16 @@ bfs_ioctl(fs_volume* _volume, fs_vnode* _node, void* _cookie, ulong cmd,
return volume->WriteSuperBlock();
}
#ifdef DEBUG_FRAGMENTER
case 56741:
{
BlockAllocator& allocator = volume->Allocator();
allocator.Fragment();
return B_OK;
}
#endif
#ifdef DEBUG
case 56742:
{