diff --git a/Kernel/Ext2FileSystem.cpp b/Kernel/Ext2FileSystem.cpp index cac3049d01..8b813de1f3 100644 --- a/Kernel/Ext2FileSystem.cpp +++ b/Kernel/Ext2FileSystem.cpp @@ -20,7 +20,6 @@ Retained Ext2FS::create(Retained&& device) Ext2FS::Ext2FS(Retained&& device) : DiskBackedFS(move(device)) - , m_lock("Ext2FS") { } diff --git a/Kernel/Ext2FileSystem.h b/Kernel/Ext2FileSystem.h index c6c8b57575..cbd280a29e 100644 --- a/Kernel/Ext2FileSystem.h +++ b/Kernel/Ext2FileSystem.h @@ -133,7 +133,6 @@ private: mutable ByteBuffer m_cached_super_block; mutable ByteBuffer m_cached_group_descriptor_table; - mutable Lock m_lock; mutable HashMap> m_inode_cache; }; diff --git a/Kernel/FileSystem.cpp b/Kernel/FileSystem.cpp index 2b6758a9bf..d6ca427ec0 100644 --- a/Kernel/FileSystem.cpp +++ b/Kernel/FileSystem.cpp @@ -25,7 +25,8 @@ HashTable& 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> 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(); } } diff --git a/Kernel/FileSystem.h b/Kernel/FileSystem.h index 6cc2dca2b7..a186c4ff6d 100644 --- a/Kernel/FileSystem.h +++ b/Kernel/FileSystem.h @@ -25,6 +25,7 @@ class LocalSocket; class VMObject; class FS : public Retainable { + 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 { friend class VFS; + friend class FS; public: virtual ~Inode(); diff --git a/Kernel/SyntheticFileSystem.cpp b/Kernel/SyntheticFileSystem.cpp index 61dd4637d0..bcf37dcf0f 100644 --- a/Kernel/SyntheticFileSystem.cpp +++ b/Kernel/SyntheticFileSystem.cpp @@ -11,7 +11,6 @@ Retained SynthFS::create() } SynthFS::SynthFS() - : m_lock("SynthFS") { } diff --git a/Kernel/SyntheticFileSystem.h b/Kernel/SyntheticFileSystem.h index f0cebaedbf..c1b95e5fe6 100644 --- a/Kernel/SyntheticFileSystem.h +++ b/Kernel/SyntheticFileSystem.h @@ -37,7 +37,6 @@ protected: private: InodeIndex m_next_inode_index { 2 }; HashMap> m_inodes; - mutable Lock m_lock; }; struct SynthFSInodeCustomData {