mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-22 02:49:29 +03: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
Notes:
sideshowbarker
2024-07-19 11:27:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/dcf8d359f36
@ -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
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
|
||||
virtual void flush_writes() override;
|
||||
|
||||
void flush_writes_impl();
|
||||
|
||||
protected:
|
||||
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user