From 493d4d1cd7305192362b570b615efb12eb8da4e3 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Wed, 26 May 2021 02:18:23 -0700 Subject: [PATCH] Kernel: Switch Inode to IntrusiveList from InlineLinkedList --- Kernel/FileSystem/Inode.cpp | 13 ++++--------- Kernel/FileSystem/Inode.h | 16 ++++++---------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index e1fcee8eb28..a5f058f0690 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -21,14 +21,9 @@ namespace Kernel { static SpinLock s_all_inodes_lock; -static AK::Singleton> s_list; +static AK::Singleton s_list; -SpinLock& Inode::all_inodes_lock() -{ - return s_all_inodes_lock; -} - -InlineLinkedList& Inode::all_with_lock() +static Inode::List& all_with_lock() { VERIFY(s_all_inodes_lock.is_locked()); @@ -103,13 +98,13 @@ Inode::Inode(FS& fs, InodeIndex index) , m_index(index) { ScopedSpinLock all_inodes_lock(s_all_inodes_lock); - all_with_lock().append(this); + all_with_lock().append(*this); } Inode::~Inode() { ScopedSpinLock all_inodes_lock(s_all_inodes_lock); - all_with_lock().remove(this); + all_with_lock().remove(*this); for (auto& watcher : m_watchers) { watcher->unregister_by_inode({}, identifier()); diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 3b027402e60..ed96e9be9e6 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -24,8 +24,7 @@ namespace Kernel { class Inode : public RefCounted - , public Weakable - , public InlineLinkedListNode { + , public Weakable { friend class VFS; friend class FS; @@ -91,7 +90,6 @@ public: RefPtr shared_vmobject() const; bool is_shared_vmobject(const SharedInodeVMObject&) const; - static InlineLinkedList& all_with_lock(); static void sync(); bool has_watchers() const { return !m_watchers.is_empty(); } @@ -101,12 +99,6 @@ public: NonnullRefPtr fifo(); - // For InlineLinkedListNode. - Inode* m_next { nullptr }; - Inode* m_prev { nullptr }; - - static SpinLock& all_inodes_lock(); - protected: Inode(FS& fs, InodeIndex); void set_metadata_dirty(bool); @@ -127,6 +119,10 @@ private: HashTable m_watchers; bool m_metadata_dirty { false }; RefPtr m_fifo; + IntrusiveListNode m_inode_list_node; + +public: + using List = IntrusiveList, &Inode::m_inode_list_node>; }; }