Forráskód Böngészése

ProcFS: Take the "all inodes" lock when generating /proc/inodes

Otherwise the kernel asserts.
Andreas Kling 4 éve
szülő
commit
dfce9051fa

+ 5 - 0
Kernel/FileSystem/Inode.cpp

@@ -41,6 +41,11 @@ namespace Kernel {
 static SpinLock s_all_inodes_lock;
 static SpinLock s_all_inodes_lock;
 static AK::Singleton<InlineLinkedList<Inode>> s_list;
 static AK::Singleton<InlineLinkedList<Inode>> s_list;
 
 
+SpinLock<u32>& Inode::all_inodes_lock()
+{
+    return s_all_inodes_lock;
+}
+
 InlineLinkedList<Inode>& Inode::all_with_lock()
 InlineLinkedList<Inode>& Inode::all_with_lock()
 {
 {
     ASSERT(s_all_inodes_lock.is_locked());
     ASSERT(s_all_inodes_lock.is_locked());

+ 2 - 0
Kernel/FileSystem/Inode.h

@@ -120,6 +120,8 @@ public:
     Inode* m_next { nullptr };
     Inode* m_next { nullptr };
     Inode* m_prev { nullptr };
     Inode* m_prev { nullptr };
 
 
+    static SpinLock<u32>& all_inodes_lock();
+
 protected:
 protected:
     Inode(FS& fs, unsigned index);
     Inode(FS& fs, unsigned index);
     void set_metadata_dirty(bool);
     void set_metadata_dirty(bool);

+ 1 - 0
Kernel/FileSystem/ProcFS.cpp

@@ -914,6 +914,7 @@ static Optional<KBuffer> procfs$inodes(InodeIdentifier)
 {
 {
     KBufferBuilder builder;
     KBufferBuilder builder;
     InterruptDisabler disabler;
     InterruptDisabler disabler;
+    ScopedSpinLock all_inodes_lock(Inode::all_inodes_lock());
     for (auto& inode : Inode::all_with_lock()) {
     for (auto& inode : Inode::all_with_lock()) {
         builder.appendf("Inode{K%x} %02u:%08u (%u)\n", &inode, inode.fsid(), inode.index(), inode.ref_count());
         builder.appendf("Inode{K%x} %02u:%08u (%u)\n", &inode, inode.fsid(), inode.index(), inode.ref_count());
     }
     }