1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 04:17:34 +00:00

Ext2FS: Don't cache a full Ext2FSInode object for non-existent inodes.

This was a bit silly. We were always creating Ext2FSInode objects when
Ext2FSInode::get_inode() was called. They'd then sit and fatten up the
inode cache forever, despite not representing allocated inodes.

This patch consults the inode bitmap and if get_inode() is called with
an unallocated inode index, we simply cache a nullptr to represent the
fact that this index is unused.

This could be a lot better optimized, it will currently hit the disk for
every new inode index encountered.
This commit is contained in:
Andreas Kling 2019-01-01 03:35:33 +01:00
parent d07b08a287
commit 8f9542174f
2 changed files with 27 additions and 1 deletions

View file

@ -100,6 +100,7 @@ private:
bool add_inode_to_directory(InodeIndex parent, InodeIndex child, const String& name, byte fileType, int& error);
bool write_directory_inode(unsigned directoryInode, Vector<DirectoryEntry>&&);
bool get_inode_allocation_state(InodeIndex) const;
bool set_inode_allocation_state(unsigned inode, bool);
bool set_block_allocation_state(GroupIndex, BlockIndex, bool);