1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:48:10 +00:00

Kernel: Make a copy of the dirty inode list before iterating in sync().

This commit is contained in:
Andreas Kling 2019-02-28 21:51:59 +01:00
parent bff5b71467
commit 6b581aff77
6 changed files with 18 additions and 8 deletions

View file

@ -20,7 +20,6 @@ Retained<Ext2FS> Ext2FS::create(Retained<DiskDevice>&& device)
Ext2FS::Ext2FS(Retained<DiskDevice>&& device) Ext2FS::Ext2FS(Retained<DiskDevice>&& device)
: DiskBackedFS(move(device)) : DiskBackedFS(move(device))
, m_lock("Ext2FS")
{ {
} }

View file

@ -133,7 +133,6 @@ private:
mutable ByteBuffer m_cached_super_block; mutable ByteBuffer m_cached_super_block;
mutable ByteBuffer m_cached_group_descriptor_table; mutable ByteBuffer m_cached_group_descriptor_table;
mutable Lock m_lock;
mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache; mutable HashMap<BlockIndex, RetainPtr<Ext2FSInode>> m_inode_cache;
}; };

View file

@ -25,7 +25,8 @@ HashTable<Inode*>& all_inodes()
} }
FS::FS() FS::FS()
: m_fsid(++s_lastFileSystemID) : m_lock("FS")
, m_fsid(++s_lastFileSystemID)
{ {
all_fses().set(m_fsid, this); all_fses().set(m_fsid, this);
} }
@ -143,9 +144,18 @@ int Inode::decrement_link_count()
void FS::sync() void FS::sync()
{ {
for (auto* inode : all_inodes()) { Vector<Retained<Inode>> inodes;
if (inode->is_metadata_dirty()) {
inode->flush_metadata(); 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();
} }
} }

View file

@ -25,6 +25,7 @@ class LocalSocket;
class VMObject; class VMObject;
class FS : public Retainable<FS> { class FS : public Retainable<FS> {
friend class Inode;
public: public:
virtual ~FS(); virtual ~FS();
@ -60,6 +61,8 @@ public:
protected: protected:
FS(); FS();
mutable Lock m_lock;
private: private:
unsigned m_fsid { 0 }; unsigned m_fsid { 0 };
bool m_readonly { false }; bool m_readonly { false };
@ -67,6 +70,7 @@ private:
class Inode : public Retainable<Inode> { class Inode : public Retainable<Inode> {
friend class VFS; friend class VFS;
friend class FS;
public: public:
virtual ~Inode(); virtual ~Inode();

View file

@ -11,7 +11,6 @@ Retained<SynthFS> SynthFS::create()
} }
SynthFS::SynthFS() SynthFS::SynthFS()
: m_lock("SynthFS")
{ {
} }

View file

@ -37,7 +37,6 @@ protected:
private: private:
InodeIndex m_next_inode_index { 2 }; InodeIndex m_next_inode_index { 2 };
HashMap<InodeIndex, RetainPtr<SynthFSInode>> m_inodes; HashMap<InodeIndex, RetainPtr<SynthFSInode>> m_inodes;
mutable Lock m_lock;
}; };
struct SynthFSInodeCustomData { struct SynthFSInodeCustomData {