1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

Ext2FS: Remove the inode cache lock in favor of one big lock instead.

This commit is contained in:
Andreas Kling 2019-02-20 21:41:53 +01:00
parent 266e77259e
commit e0b81ee4c9
2 changed files with 6 additions and 12 deletions

View file

@ -399,16 +399,16 @@ void Ext2FSInode::flush_metadata()
RetainPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const RetainPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
{ {
LOCKER(m_lock);
ASSERT(inode.fsid() == fsid()); ASSERT(inode.fsid() == fsid());
{ {
LOCKER(m_inode_cache_lock);
auto it = m_inode_cache.find(inode.index()); auto it = m_inode_cache.find(inode.index());
if (it != m_inode_cache.end()) if (it != m_inode_cache.end())
return (*it).value; return (*it).value;
} }
if (!get_inode_allocation_state(inode.index())) { if (!get_inode_allocation_state(inode.index())) {
LOCKER(m_inode_cache_lock);
m_inode_cache.set(inode.index(), nullptr); m_inode_cache.set(inode.index(), nullptr);
return nullptr; return nullptr;
} }
@ -419,7 +419,6 @@ RetainPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
if (!block) if (!block)
return { }; return { };
LOCKER(m_inode_cache_lock);
auto it = m_inode_cache.find(inode.index()); auto it = m_inode_cache.find(inode.index());
if (it != m_inode_cache.end()) if (it != m_inode_cache.end())
return (*it).value; return (*it).value;
@ -1199,11 +1198,9 @@ RetainPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& n
success = write_ext2_inode(inode_id, e2inode); success = write_ext2_inode(inode_id, e2inode);
ASSERT(success); ASSERT(success);
{ // We might have cached the fact that this inode didn't exist. Wipe the slate.
// We might have cached the fact that this inode didn't exist. Wipe the slate. m_inode_cache.remove(inode_id);
LOCKER(m_inode_cache_lock);
m_inode_cache.remove(inode_id);
}
return get_inode({ fsid(), inode_id }); return get_inode({ fsid(), inode_id });
} }
@ -1338,8 +1335,7 @@ int Ext2FSInode::decrement_link_count()
void Ext2FS::uncache_inode(InodeIndex index) void Ext2FS::uncache_inode(InodeIndex index)
{ {
LOCKER(m_inode_cache_lock); LOCKER(m_lock);
m_inode_cache.remove(index);
} }
size_t Ext2FSInode::directory_entry_count() const size_t Ext2FSInode::directory_entry_count() const

View file

@ -128,8 +128,6 @@ private:
mutable ByteBuffer m_cached_group_descriptor_table; mutable ByteBuffer m_cached_group_descriptor_table;
mutable Lock m_lock; mutable Lock m_lock;
mutable Lock m_inode_cache_lock;
mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache; mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache;
}; };