mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel/Ext2FS: Cache the root inode in a member variable
We often get queried for the root inode, and it will always be cached in memory anyway, so let's make Ext2FS::root_inode() fast by keeping the root inode in a dedicated member variable.
This commit is contained in:
parent
9457d83986
commit
58c6d30f6a
Notes:
sideshowbarker
2024-07-18 08:50:45 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/58c6d30f6a2
4 changed files with 13 additions and 4 deletions
|
@ -145,12 +145,18 @@ bool Ext2FS::initialize()
|
|||
}
|
||||
}
|
||||
|
||||
m_root_inode = static_ptr_cast<Ext2FSInode>(get_inode({ fsid(), EXT2_ROOT_INO }));
|
||||
if (!m_root_inode) {
|
||||
dbgln("Ext2FS: failed to acquire root inode");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Inode> Ext2FS::root_inode() const
|
||||
{
|
||||
return *get_inode({ fsid(), EXT2_ROOT_INO });
|
||||
return *m_root_inode;
|
||||
}
|
||||
|
||||
bool Ext2FS::find_block_containing_inode(InodeIndex inode, BlockIndex& block_index, unsigned& offset) const
|
||||
|
@ -1778,7 +1784,7 @@ unsigned Ext2FS::free_inode_count() const
|
|||
return super_block().s_free_inodes_count;
|
||||
}
|
||||
|
||||
KResult Ext2FS::prepare_to_unmount() const
|
||||
KResult Ext2FS::prepare_to_unmount()
|
||||
{
|
||||
MutexLocker locker(m_lock);
|
||||
|
||||
|
@ -1788,6 +1794,7 @@ KResult Ext2FS::prepare_to_unmount() const
|
|||
}
|
||||
|
||||
m_inode_cache.clear();
|
||||
m_root_inode = nullptr;
|
||||
return KSuccess;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
virtual unsigned total_inode_count() const override;
|
||||
virtual unsigned free_inode_count() const override;
|
||||
|
||||
virtual KResult prepare_to_unmount() const override;
|
||||
virtual KResult prepare_to_unmount() override;
|
||||
|
||||
virtual bool supports_watchers() const override { return true; }
|
||||
|
||||
|
@ -183,6 +183,7 @@ private:
|
|||
KResult update_bitmap_block(BlockIndex bitmap_block, size_t bit_index, bool new_state, u32& super_block_counter, u16& group_descriptor_counter);
|
||||
|
||||
Vector<OwnPtr<CachedBitmap>> m_cached_bitmaps;
|
||||
RefPtr<Ext2FSInode> m_root_inode;
|
||||
};
|
||||
|
||||
inline Ext2FS& Ext2FSInode::fs()
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
virtual unsigned total_inode_count() const { return 0; }
|
||||
virtual unsigned free_inode_count() const { return 0; }
|
||||
|
||||
virtual KResult prepare_to_unmount() const { return KSuccess; }
|
||||
virtual KResult prepare_to_unmount() { return KSuccess; }
|
||||
|
||||
struct DirectoryEntryView {
|
||||
DirectoryEntryView(const StringView& name, InodeIdentifier, u8 file_type);
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
Inode& guest() { return *m_guest; }
|
||||
|
||||
FileSystem const& guest_fs() const { return *m_guest_fs; }
|
||||
FileSystem& guest_fs() { return *m_guest_fs; }
|
||||
|
||||
String absolute_path() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue