mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:48:13 +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) {
|
if (!oldest_clean_entry) {
|
||||||
// Not a single clean entry! Flush writes and try again.
|
// 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);
|
return get(block_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +150,7 @@ bool DiskBackedFS::read_blocks(unsigned index, unsigned count, u8* buffer) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiskBackedFS::flush_writes()
|
void DiskBackedFS::flush_writes_impl()
|
||||||
{
|
{
|
||||||
LOCKER(m_lock);
|
LOCKER(m_lock);
|
||||||
if (!cache().is_dirty())
|
if (!cache().is_dirty())
|
||||||
|
@ -163,8 +165,12 @@ void DiskBackedFS::flush_writes()
|
||||||
entry.is_dirty = false;
|
entry.is_dirty = false;
|
||||||
});
|
});
|
||||||
cache().set_dirty(false);
|
cache().set_dirty(false);
|
||||||
dbg() << class_name() << ": "
|
dbg() << class_name() << ": Flushed " << count << " blocks to disk";
|
||||||
<< "Flushed " << count << " blocks to disk";
|
}
|
||||||
|
|
||||||
|
void DiskBackedFS::flush_writes()
|
||||||
|
{
|
||||||
|
flush_writes_impl();
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskCache& DiskBackedFS::cache() const
|
DiskCache& DiskBackedFS::cache() const
|
||||||
|
|
|
@ -16,6 +16,8 @@ public:
|
||||||
|
|
||||||
virtual void flush_writes() override;
|
virtual void flush_writes() override;
|
||||||
|
|
||||||
|
void flush_writes_impl();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue