summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-04 12:23:19 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-04 12:23:19 +0100
commitc538648465d1a35f1eb6d059245537e186a7e855 (patch)
tree996ba966922bd961141796574e551d247b6d9a43 /Kernel
parent19398cd7d586bc3500ce63486ac10bde5c4489a9 (diff)
downloadserenity-c538648465d1a35f1eb6d059245537e186a7e855.zip
Ext2FS: Uncache unused Inodes after flushing contents to disk
Don't keep Inodes around in memory forever after we've interacted with them once. This is a slight performance pessimization when accessing the same file repeatedly, but closing it for a while in between. Longer term we should find a way to keep a limited number of unused Inodes cached, whichever ones we think are likely to be used again.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index 096d444223..9d428b4c13 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -503,7 +503,21 @@ void Ext2FS::flush_writes()
#endif
}
}
+
DiskBackedFS::flush_writes();
+
+ // Uncache Inodes that are only kept alive by the index-to-inode lookup cache.
+ // FIXME: It would be better to keep a capped number of Inodes around.
+ // The problem is that they are quite heavy objects, and use a lot of heap memory
+ // for their (child name lookup) and (block list) caches.
+ Vector<InodeIndex> unused_inodes;
+ for (auto& it : m_inode_cache) {
+ if (it.value->ref_count() != 1)
+ continue;
+ unused_inodes.append(it.key);
+ }
+ for (auto index : unused_inodes)
+ uncache_inode(index);
}
Ext2FSInode::Ext2FSInode(Ext2FS& fs, unsigned index)