Kernel: Switch Inode to IntrusiveList from InlineLinkedList

This commit is contained in:
Brian Gianforcaro 2021-05-26 02:18:23 -07:00 committed by Andreas Kling
parent 971f4ca71c
commit 493d4d1cd7
Notes: sideshowbarker 2024-07-18 17:21:42 +09:00
2 changed files with 10 additions and 19 deletions

View file

@ -21,14 +21,9 @@
namespace Kernel {
static SpinLock s_all_inodes_lock;
static AK::Singleton<InlineLinkedList<Inode>> s_list;
static AK::Singleton<Inode::List> s_list;
SpinLock<u32>& Inode::all_inodes_lock()
{
return s_all_inodes_lock;
}
InlineLinkedList<Inode>& 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());

View file

@ -9,7 +9,7 @@
#include <AK/Function.h>
#include <AK/HashTable.h>
#include <AK/InlineLinkedList.h>
#include <AK/IntrusiveList.h>
#include <AK/RefCounted.h>
#include <AK/String.h>
#include <AK/WeakPtr.h>
@ -24,8 +24,7 @@
namespace Kernel {
class Inode : public RefCounted<Inode>
, public Weakable<Inode>
, public InlineLinkedListNode<Inode> {
, public Weakable<Inode> {
friend class VFS;
friend class FS;
@ -91,7 +90,6 @@ public:
RefPtr<SharedInodeVMObject> shared_vmobject() const;
bool is_shared_vmobject(const SharedInodeVMObject&) const;
static InlineLinkedList<Inode>& all_with_lock();
static void sync();
bool has_watchers() const { return !m_watchers.is_empty(); }
@ -101,12 +99,6 @@ public:
NonnullRefPtr<FIFO> fifo();
// For InlineLinkedListNode.
Inode* m_next { nullptr };
Inode* m_prev { nullptr };
static SpinLock<u32>& all_inodes_lock();
protected:
Inode(FS& fs, InodeIndex);
void set_metadata_dirty(bool);
@ -127,6 +119,10 @@ private:
HashTable<InodeWatcher*> m_watchers;
bool m_metadata_dirty { false };
RefPtr<FIFO> m_fifo;
IntrusiveListNode<Inode> m_inode_list_node;
public:
using List = IntrusiveList<Inode, RawPtr<Inode>, &Inode::m_inode_list_node>;
};
}