Optimize extfs syncing inodes.
This commit is contained in:
parent
572481098a
commit
8f0db0f541
|
@ -50,6 +50,7 @@ Filesystem::Filesystem(Device* device)
|
||||||
block_size = device->block_size;
|
block_size = device->block_size;
|
||||||
mru_inode = NULL;
|
mru_inode = NULL;
|
||||||
lru_inode = NULL;
|
lru_inode = NULL;
|
||||||
|
dirty_inode = NULL;
|
||||||
inode_size = this->sb->s_inode_size;
|
inode_size = this->sb->s_inode_size;
|
||||||
num_blocks = sb->s_blocks_count;
|
num_blocks = sb->s_blocks_count;
|
||||||
num_groups = divup(this->sb->s_blocks_count, this->sb->s_blocks_per_group);
|
num_groups = divup(this->sb->s_blocks_count, this->sb->s_blocks_per_group);
|
||||||
|
@ -90,8 +91,8 @@ void Filesystem::Dirty()
|
||||||
|
|
||||||
void Filesystem::Sync()
|
void Filesystem::Sync()
|
||||||
{
|
{
|
||||||
for ( Inode* iter = mru_inode; iter; iter = iter->next_inode )
|
while ( dirty_inode )
|
||||||
iter->Sync();
|
dirty_inode->Sync();
|
||||||
for ( size_t i = 0; i < num_groups; i++ )
|
for ( size_t i = 0; i < num_groups; i++ )
|
||||||
if ( block_groups && block_groups[i] )
|
if ( block_groups && block_groups[i] )
|
||||||
block_groups[i]->Sync();
|
block_groups[i]->Sync();
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
uint32_t num_inodes;
|
uint32_t num_inodes;
|
||||||
Inode* mru_inode;
|
Inode* mru_inode;
|
||||||
Inode* lru_inode;
|
Inode* lru_inode;
|
||||||
|
Inode* dirty_inode;
|
||||||
time_t mtime_realtime;
|
time_t mtime_realtime;
|
||||||
time_t mtime_monotonic;
|
time_t mtime_monotonic;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
|
|
|
@ -53,6 +53,8 @@ Inode::Inode(Filesystem* filesystem, uint32_t inode_id)
|
||||||
{
|
{
|
||||||
this->prev_inode = NULL;
|
this->prev_inode = NULL;
|
||||||
this->next_inode = NULL;
|
this->next_inode = NULL;
|
||||||
|
this->prev_dirty = NULL;
|
||||||
|
this->next_dirty = NULL;
|
||||||
this->filesystem = filesystem;
|
this->filesystem = filesystem;
|
||||||
this->reference_count = 1;
|
this->reference_count = 1;
|
||||||
this->inode_id = inode_id;
|
this->inode_id = inode_id;
|
||||||
|
@ -969,15 +971,29 @@ void Inode::RemoteUnref()
|
||||||
|
|
||||||
void Inode::Dirty()
|
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();
|
data_block->Dirty();
|
||||||
Use();
|
Use();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inode::Sync()
|
void Inode::Sync()
|
||||||
{
|
{
|
||||||
if ( dirty )
|
if ( !dirty )
|
||||||
data_block->Sync();
|
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;
|
dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ public:
|
||||||
public:
|
public:
|
||||||
Inode* prev_inode;
|
Inode* prev_inode;
|
||||||
Inode* next_inode;
|
Inode* next_inode;
|
||||||
|
Inode* prev_dirty;
|
||||||
|
Inode* next_dirty;
|
||||||
Block* data_block;
|
Block* data_block;
|
||||||
struct ext_inode* data;
|
struct ext_inode* data;
|
||||||
Filesystem* filesystem;
|
Filesystem* filesystem;
|
||||||
|
|
Loading…
Reference in New Issue