mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 11:55:12 +00:00
Kernel: Fick infinite recursion when filling up disk cache
We can't be calling the virtual FS::flush_writes() in order to flush the disk cache from within the disk cache, since an FS subclass may try to do cache stuff in its flush_writes() implementation. Instead, separate out the implementation of DiskBackedFS's flushing logic into a flush_writes_impl() and call that from the cache code.
This commit is contained in:
parent
1e36d899f1
commit
dcf8d359f3
2 changed files with 12 additions and 4 deletions
|
@ -50,7 +50,9 @@ public:
|
|||
}
|
||||
if (!oldest_clean_entry) {
|
||||
// Not a single clean entry! Flush writes and try again.
|
||||
m_fs.flush_writes();
|
||||
// NOTE: We want to make sure we only call DiskBackedFS flush here,
|
||||
// not some DiskBackedFS subclass flush!
|
||||
m_fs.flush_writes_impl();
|
||||
return get(block_index);
|
||||
}
|
||||
|
||||
|
@ -148,7 +150,7 @@ bool DiskBackedFS::read_blocks(unsigned index, unsigned count, u8* buffer) const
|
|||
return true;
|
||||
}
|
||||
|
||||
void DiskBackedFS::flush_writes()
|
||||
void DiskBackedFS::flush_writes_impl()
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
if (!cache().is_dirty())
|
||||
|
@ -163,8 +165,12 @@ void DiskBackedFS::flush_writes()
|
|||
entry.is_dirty = false;
|
||||
});
|
||||
cache().set_dirty(false);
|
||||
dbg() << class_name() << ": "
|
||||
<< "Flushed " << count << " blocks to disk";
|
||||
dbg() << class_name() << ": Flushed " << count << " blocks to disk";
|
||||
}
|
||||
|
||||
void DiskBackedFS::flush_writes()
|
||||
{
|
||||
flush_writes_impl();
|
||||
}
|
||||
|
||||
DiskCache& DiskBackedFS::cache() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue