diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 9d428b4c13..e6cdc52490 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -507,6 +507,8 @@ void Ext2FS::flush_writes() DiskBackedFS::flush_writes(); // Uncache Inodes that are only kept alive by the index-to-inode lookup cache. + // We don't uncache Inodes that are being watched by at least one InodeWatcher. + // 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. @@ -514,6 +516,8 @@ void Ext2FS::flush_writes() for (auto& it : m_inode_cache) { if (it.value->ref_count() != 1) continue; + if (it.value->has_watchers()) + continue; unused_inodes.append(it.key); } for (auto index : unused_inodes) diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 131d83cbd8..6914563cea 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -77,6 +77,8 @@ public: static void sync(); + bool has_watchers() const { return !m_watchers.is_empty(); } + void register_watcher(Badge, InodeWatcher&); void unregister_watcher(Badge, InodeWatcher&);