mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Make a copy of the dirty inode list before iterating in sync().
This commit is contained in:
parent
bff5b71467
commit
6b581aff77
Notes:
sideshowbarker
2024-07-19 15:35:05 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6b581aff773
6 changed files with 18 additions and 8 deletions
|
@ -20,7 +20,6 @@ Retained<Ext2FS> Ext2FS::create(Retained<DiskDevice>&& device)
|
|||
|
||||
Ext2FS::Ext2FS(Retained<DiskDevice>&& device)
|
||||
: DiskBackedFS(move(device))
|
||||
, m_lock("Ext2FS")
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,6 @@ private:
|
|||
mutable ByteBuffer m_cached_super_block;
|
||||
mutable ByteBuffer m_cached_group_descriptor_table;
|
||||
|
||||
mutable Lock m_lock;
|
||||
mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ HashTable<Inode*>& all_inodes()
|
|||
}
|
||||
|
||||
FS::FS()
|
||||
: m_fsid(++s_lastFileSystemID)
|
||||
: m_lock("FS")
|
||||
, m_fsid(++s_lastFileSystemID)
|
||||
{
|
||||
all_fses().set(m_fsid, this);
|
||||
}
|
||||
|
@ -143,9 +144,18 @@ int Inode::decrement_link_count()
|
|||
|
||||
void FS::sync()
|
||||
{
|
||||
for (auto* inode : all_inodes()) {
|
||||
if (inode->is_metadata_dirty())
|
||||
inode->flush_metadata();
|
||||
Vector<Retained<Inode>> inodes;
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
for (auto* inode : all_inodes()) {
|
||||
if (inode->is_metadata_dirty())
|
||||
inodes.unchecked_append(*inode);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& inode : inodes) {
|
||||
ASSERT(inode->is_metadata_dirty());
|
||||
inode->flush_metadata();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ class LocalSocket;
|
|||
class VMObject;
|
||||
|
||||
class FS : public Retainable<FS> {
|
||||
friend class Inode;
|
||||
public:
|
||||
virtual ~FS();
|
||||
|
||||
|
@ -60,6 +61,8 @@ public:
|
|||
protected:
|
||||
FS();
|
||||
|
||||
mutable Lock m_lock;
|
||||
|
||||
private:
|
||||
unsigned m_fsid { 0 };
|
||||
bool m_readonly { false };
|
||||
|
@ -67,6 +70,7 @@ private:
|
|||
|
||||
class Inode : public Retainable<Inode> {
|
||||
friend class VFS;
|
||||
friend class FS;
|
||||
public:
|
||||
virtual ~Inode();
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ Retained<SynthFS> SynthFS::create()
|
|||
}
|
||||
|
||||
SynthFS::SynthFS()
|
||||
: m_lock("SynthFS")
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ protected:
|
|||
private:
|
||||
InodeIndex m_next_inode_index { 2 };
|
||||
HashMap<InodeIndex, RetainPtr<SynthFSInode>> m_inodes;
|
||||
mutable Lock m_lock;
|
||||
};
|
||||
|
||||
struct SynthFSInodeCustomData {
|
||||
|
|
Loading…
Reference in a new issue