mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 21:25:07 +00:00
Ext2FS: Cache block bitmaps instead of always reading/writing disk
Add a simple cache to Ext2FS where we keep block bitmaps along with a dirty bit. This allows us to coalesce bitmap flushes, giving us a nice ~3x improvement in disk_benchmark write speeds.
This commit is contained in:
parent
3a8b5b405c
commit
1ae9d85de9
2 changed files with 52 additions and 19 deletions
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Bitmap.h>
|
||||
#include <Kernel/FileSystem/DiskBackedFileSystem.h>
|
||||
#include <Kernel/FileSystem/Inode.h>
|
||||
#include <Kernel/FileSystem/ext2_fs.h>
|
||||
|
@ -135,6 +136,22 @@ private:
|
|||
|
||||
bool m_super_block_dirty { false };
|
||||
bool m_block_group_descriptors_dirty { false };
|
||||
|
||||
struct CachedBitmap {
|
||||
CachedBitmap(BlockIndex bi, ByteBuffer&& buf)
|
||||
: bitmap_block_index(bi)
|
||||
, buffer(buf)
|
||||
{}
|
||||
BlockIndex bitmap_block_index { 0 };
|
||||
bool dirty { false };
|
||||
ByteBuffer buffer;
|
||||
Bitmap bitmap(u32 blocks_per_group) { return Bitmap::wrap(buffer.data(), blocks_per_group); }
|
||||
};
|
||||
|
||||
CachedBitmap& get_block_bitmap(BlockIndex bitmap_block_index);
|
||||
CachedBitmap& get_inode_bitmap(InodeIndex bitmap_block_index);
|
||||
|
||||
Vector<OwnPtr<CachedBitmap>> m_cached_bitmaps;
|
||||
};
|
||||
|
||||
inline Ext2FS& Ext2FSInode::fs()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue