mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
Ext2FS: Flush the super block and block group descriptors lazily
Keep dirty bits for these and override flush_writes() so that we can coalesce writes. Looks like a ~5x write performance bump on the disk_benchmark.
This commit is contained in:
parent
f2a9bbe96e
commit
e4b7786b66
Notes:
sideshowbarker
2024-07-19 11:28:39 +09:00
Author: https://github.com/awesomekling
Commit: e4b7786b66
2 changed files with 23 additions and 6 deletions
|
@ -501,7 +501,7 @@ void Ext2FS::free_inode(Ext2FSInode& inode)
|
|||
auto& bgd = const_cast<ext2_group_desc&>(group_descriptor(group_index_from_inode(inode.index())));
|
||||
--bgd.bg_used_dirs_count;
|
||||
dbgprintf("Ext2FS: decremented bg_used_dirs_count %u -> %u\n", bgd.bg_used_dirs_count - 1, bgd.bg_used_dirs_count);
|
||||
flush_block_group_descriptor_table();
|
||||
m_block_group_descriptors_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,6 +513,19 @@ void Ext2FS::flush_block_group_descriptor_table()
|
|||
write_blocks(first_block_of_bgdt, blocks_to_write, m_cached_group_descriptor_table.data());
|
||||
}
|
||||
|
||||
void Ext2FS::flush_writes()
|
||||
{
|
||||
if (m_super_block_dirty) {
|
||||
write_super_block(super_block());
|
||||
m_super_block_dirty = false;
|
||||
}
|
||||
if (m_block_group_descriptors_dirty) {
|
||||
flush_block_group_descriptor_table();
|
||||
m_block_group_descriptors_dirty = false;
|
||||
}
|
||||
DiskBackedFS::flush_writes();
|
||||
}
|
||||
|
||||
Ext2FSInode::Ext2FSInode(Ext2FS& fs, unsigned index)
|
||||
: Inode(fs, index)
|
||||
{
|
||||
|
@ -1188,7 +1201,7 @@ bool Ext2FS::set_inode_allocation_state(InodeIndex inode_index, bool new_state)
|
|||
--sb.s_free_inodes_count;
|
||||
else
|
||||
++sb.s_free_inodes_count;
|
||||
write_super_block(sb);
|
||||
m_super_block_dirty = true;
|
||||
|
||||
// Update BGD
|
||||
auto& mutable_bgd = const_cast<ext2_group_desc&>(bgd);
|
||||
|
@ -1200,7 +1213,7 @@ bool Ext2FS::set_inode_allocation_state(InodeIndex inode_index, bool new_state)
|
|||
dbgprintf("Ext2FS: group free inode count %u -> %u\n", bgd.bg_free_inodes_count, bgd.bg_free_inodes_count - 1);
|
||||
#endif
|
||||
|
||||
flush_block_group_descriptor_table();
|
||||
m_block_group_descriptors_dirty = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1252,7 +1265,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
|
|||
--sb.s_free_blocks_count;
|
||||
else
|
||||
++sb.s_free_blocks_count;
|
||||
write_super_block(sb);
|
||||
m_super_block_dirty = true;
|
||||
|
||||
// Update BGD
|
||||
auto& mutable_bgd = const_cast<ext2_group_desc&>(bgd);
|
||||
|
@ -1264,7 +1277,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
|
|||
dbgprintf("Ext2FS: group %u free block count %u -> %u\n", group_index, bgd.bg_free_blocks_count, bgd.bg_free_blocks_count - 1);
|
||||
#endif
|
||||
|
||||
flush_block_group_descriptor_table();
|
||||
m_block_group_descriptors_dirty = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1306,7 +1319,7 @@ RefPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String&
|
|||
dbgprintf("Ext2FS: incremented bg_used_dirs_count %u -> %u\n", bgd.bg_used_dirs_count - 1, bgd.bg_used_dirs_count);
|
||||
#endif
|
||||
|
||||
flush_block_group_descriptor_table();
|
||||
m_block_group_descriptors_dirty = true;
|
||||
|
||||
error = 0;
|
||||
return inode;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue