mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:15:10 +00:00
Kernel: Switch Inode to IntrusiveList from InlineLinkedList
This commit is contained in:
parent
971f4ca71c
commit
493d4d1cd7
2 changed files with 10 additions and 19 deletions
|
@ -21,14 +21,9 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
static SpinLock s_all_inodes_lock;
|
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()
|
static Inode::List& all_with_lock()
|
||||||
{
|
|
||||||
return s_all_inodes_lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
InlineLinkedList<Inode>& Inode::all_with_lock()
|
|
||||||
{
|
{
|
||||||
VERIFY(s_all_inodes_lock.is_locked());
|
VERIFY(s_all_inodes_lock.is_locked());
|
||||||
|
|
||||||
|
@ -103,13 +98,13 @@ Inode::Inode(FS& fs, InodeIndex index)
|
||||||
, m_index(index)
|
, m_index(index)
|
||||||
{
|
{
|
||||||
ScopedSpinLock all_inodes_lock(s_all_inodes_lock);
|
ScopedSpinLock all_inodes_lock(s_all_inodes_lock);
|
||||||
all_with_lock().append(this);
|
all_with_lock().append(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Inode::~Inode()
|
Inode::~Inode()
|
||||||
{
|
{
|
||||||
ScopedSpinLock all_inodes_lock(s_all_inodes_lock);
|
ScopedSpinLock all_inodes_lock(s_all_inodes_lock);
|
||||||
all_with_lock().remove(this);
|
all_with_lock().remove(*this);
|
||||||
|
|
||||||
for (auto& watcher : m_watchers) {
|
for (auto& watcher : m_watchers) {
|
||||||
watcher->unregister_by_inode({}, identifier());
|
watcher->unregister_by_inode({}, identifier());
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/HashTable.h>
|
#include <AK/HashTable.h>
|
||||||
#include <AK/InlineLinkedList.h>
|
#include <AK/IntrusiveList.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/WeakPtr.h>
|
#include <AK/WeakPtr.h>
|
||||||
|
@ -24,8 +24,7 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class Inode : public RefCounted<Inode>
|
class Inode : public RefCounted<Inode>
|
||||||
, public Weakable<Inode>
|
, public Weakable<Inode> {
|
||||||
, public InlineLinkedListNode<Inode> {
|
|
||||||
friend class VFS;
|
friend class VFS;
|
||||||
friend class FS;
|
friend class FS;
|
||||||
|
|
||||||
|
@ -91,7 +90,6 @@ public:
|
||||||
RefPtr<SharedInodeVMObject> shared_vmobject() const;
|
RefPtr<SharedInodeVMObject> shared_vmobject() const;
|
||||||
bool is_shared_vmobject(const SharedInodeVMObject&) const;
|
bool is_shared_vmobject(const SharedInodeVMObject&) const;
|
||||||
|
|
||||||
static InlineLinkedList<Inode>& all_with_lock();
|
|
||||||
static void sync();
|
static void sync();
|
||||||
|
|
||||||
bool has_watchers() const { return !m_watchers.is_empty(); }
|
bool has_watchers() const { return !m_watchers.is_empty(); }
|
||||||
|
@ -101,12 +99,6 @@ public:
|
||||||
|
|
||||||
NonnullRefPtr<FIFO> fifo();
|
NonnullRefPtr<FIFO> fifo();
|
||||||
|
|
||||||
// For InlineLinkedListNode.
|
|
||||||
Inode* m_next { nullptr };
|
|
||||||
Inode* m_prev { nullptr };
|
|
||||||
|
|
||||||
static SpinLock<u32>& all_inodes_lock();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Inode(FS& fs, InodeIndex);
|
Inode(FS& fs, InodeIndex);
|
||||||
void set_metadata_dirty(bool);
|
void set_metadata_dirty(bool);
|
||||||
|
@ -127,6 +119,10 @@ private:
|
||||||
HashTable<InodeWatcher*> m_watchers;
|
HashTable<InodeWatcher*> m_watchers;
|
||||||
bool m_metadata_dirty { false };
|
bool m_metadata_dirty { false };
|
||||||
RefPtr<FIFO> m_fifo;
|
RefPtr<FIFO> m_fifo;
|
||||||
|
IntrusiveListNode<Inode> m_inode_list_node;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using List = IntrusiveList<Inode, RawPtr<Inode>, &Inode::m_inode_list_node>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue