mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Optimize extfs syncing inodes.
This commit is contained in:
parent
572481098a
commit
8f0db0f541
4 changed files with 25 additions and 5 deletions
|
@ -50,6 +50,7 @@ Filesystem::Filesystem(Device* device)
|
|||
block_size = device->block_size;
|
||||
mru_inode = NULL;
|
||||
lru_inode = NULL;
|
||||
dirty_inode = NULL;
|
||||
inode_size = this->sb->s_inode_size;
|
||||
num_blocks = sb->s_blocks_count;
|
||||
num_groups = divup(this->sb->s_blocks_count, this->sb->s_blocks_per_group);
|
||||
|
@ -90,8 +91,8 @@ void Filesystem::Dirty()
|
|||
|
||||
void Filesystem::Sync()
|
||||
{
|
||||
for ( Inode* iter = mru_inode; iter; iter = iter->next_inode )
|
||||
iter->Sync();
|
||||
while ( dirty_inode )
|
||||
dirty_inode->Sync();
|
||||
for ( size_t i = 0; i < num_groups; i++ )
|
||||
if ( block_groups && block_groups[i] )
|
||||
block_groups[i]->Sync();
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
uint32_t num_inodes;
|
||||
Inode* mru_inode;
|
||||
Inode* lru_inode;
|
||||
Inode* dirty_inode;
|
||||
time_t mtime_realtime;
|
||||
time_t mtime_monotonic;
|
||||
bool dirty;
|
||||
|
|
|
@ -53,6 +53,8 @@ Inode::Inode(Filesystem* filesystem, uint32_t inode_id)
|
|||
{
|
||||
this->prev_inode = NULL;
|
||||
this->next_inode = NULL;
|
||||
this->prev_dirty = NULL;
|
||||
this->next_dirty = NULL;
|
||||
this->filesystem = filesystem;
|
||||
this->reference_count = 1;
|
||||
this->inode_id = inode_id;
|
||||
|
@ -969,15 +971,29 @@ void Inode::RemoteUnref()
|
|||
|
||||
void Inode::Dirty()
|
||||
{
|
||||
dirty = true;
|
||||
if ( !dirty )
|
||||
{
|
||||
dirty = true;
|
||||
prev_dirty = NULL;
|
||||
next_dirty = filesystem->dirty_inode;
|
||||
if ( next_dirty )
|
||||
next_dirty->prev_dirty = this;
|
||||
filesystem->dirty_inode = this;
|
||||
}
|
||||
data_block->Dirty();
|
||||
Use();
|
||||
}
|
||||
|
||||
void Inode::Sync()
|
||||
{
|
||||
if ( dirty )
|
||||
data_block->Sync();
|
||||
if ( !dirty )
|
||||
return;
|
||||
data_block->Sync();
|
||||
(prev_dirty ? prev_dirty->next_dirty : filesystem->dirty_inode) = next_dirty;
|
||||
if ( next_dirty )
|
||||
next_dirty->prev_dirty = prev_dirty;
|
||||
prev_dirty = NULL;
|
||||
next_dirty = NULL;
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
public:
|
||||
Inode* prev_inode;
|
||||
Inode* next_inode;
|
||||
Inode* prev_dirty;
|
||||
Inode* next_dirty;
|
||||
Block* data_block;
|
||||
struct ext_inode* data;
|
||||
Filesystem* filesystem;
|
||||
|
|
Loading…
Add table
Reference in a new issue