Kernel: Decrease the number of syncs done by ext2 inodes
Each allocated inode used to call sync(). Each sync reads and writes a block from the filesystem. Doing a 1 MiB write ended up syncing around 257 times
This commit is contained in:
@@ -84,6 +84,26 @@ namespace Kernel
|
||||
{}
|
||||
static BAN::ErrorOr<BAN::RefPtr<Ext2Inode>> create(Ext2FS&, uint32_t);
|
||||
|
||||
private:
|
||||
struct ScopedSync
|
||||
{
|
||||
ScopedSync(Ext2Inode& inode)
|
||||
: inode(inode)
|
||||
, inode_info(inode.m_inode)
|
||||
{ }
|
||||
|
||||
~ScopedSync()
|
||||
{
|
||||
if (memcmp(&inode.m_inode, &inode_info, sizeof(Ext2::Inode)) == 0)
|
||||
return;
|
||||
if (auto ret = inode.sync(); ret.is_error())
|
||||
dwarnln("failed to sync inode: {}", ret.error());
|
||||
}
|
||||
|
||||
Ext2Inode& inode;
|
||||
Ext2::Inode inode_info;
|
||||
};
|
||||
|
||||
private:
|
||||
Ext2FS& m_fs;
|
||||
Ext2::Inode m_inode;
|
||||
|
||||
Reference in New Issue
Block a user