mirror of
https://github.com/RGBCube/serenity
synced 2025-06-29 22:02:08 +00:00
Ext2FS: Don't uncache inodes while they are being watched
If an inode is observed by watch_file(), we won't uncache it. This allows a program to watch a file without keeping it open.
This commit is contained in:
parent
56bbf30f28
commit
721585473b
2 changed files with 6 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue