From d5fe839166f98c595cd3d85601b1160cbfeb30f7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 26 Feb 2020 15:23:55 +0100 Subject: [PATCH] Kernel: Remove unused artifacts of the Custody cache We'll probably want some kind of Custody caching in the future, but as it's not used at the moment, let's simplify things a bit. --- Kernel/FileSystem/Custody.cpp | 55 ------------------------- Kernel/FileSystem/Custody.h | 22 +--------- Kernel/FileSystem/VirtualFileSystem.cpp | 5 --- 3 files changed, 1 insertion(+), 81 deletions(-) diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index 36a7a25f84..71b5d38393 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -24,63 +24,23 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include #include -#include namespace Kernel { -static Lockable>& all_custodies() -{ - static Lockable>* list; - if (!list) - list = new Lockable>; - return *list; -} - -Custody* Custody::get_if_cached(Custody* parent, const StringView& name) -{ - LOCKER(all_custodies().lock()); - for (auto& custody : all_custodies().resource()) { - if (custody.is_deleted()) - continue; - if (custody.is_mounted_on()) - continue; - if (custody.parent() == parent && custody.name() == name) - return &custody; - } - return nullptr; -} - -NonnullRefPtr Custody::get_or_create(Custody* parent, const StringView& name, Inode& inode, int mount_flags) -{ - if (RefPtr cached_custody = get_if_cached(parent, name)) { - if (&cached_custody->inode() != &inode) { - dbg() << "WTF! Cached custody for name '" << name << "' has inode=" << cached_custody->inode().identifier() << ", new inode=" << inode.identifier(); - } - ASSERT(&cached_custody->inode() == &inode); - return *cached_custody; - } - return create(parent, name, inode, mount_flags); -} - Custody::Custody(Custody* parent, const StringView& name, Inode& inode, int mount_flags) : m_parent(parent) , m_name(name) , m_inode(inode) , m_mount_flags(mount_flags) { - LOCKER(all_custodies().lock()); - all_custodies().resource().append(this); } Custody::~Custody() { - LOCKER(all_custodies().lock()); - all_custodies().resource().remove(this); } String Custody::absolute_path() const @@ -98,19 +58,4 @@ String Custody::absolute_path() const return builder.to_string(); } -void Custody::did_delete(Badge) -{ - m_deleted = true; -} - -void Custody::did_mount_on(Badge) -{ - m_mounted_on = true; -} - -void Custody::did_rename(Badge, const String& name) -{ - m_name = name; -} - } diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h index a19211c4e9..45ccc403bf 100644 --- a/Kernel/FileSystem/Custody.h +++ b/Kernel/FileSystem/Custody.h @@ -26,7 +26,6 @@ #pragma once -#include #include #include #include @@ -37,15 +36,9 @@ namespace Kernel { // FIXME: Custody needs some locking. -class Custody - : public RefCounted - , public InlineLinkedListNode { - +class Custody : public RefCounted { MAKE_SLAB_ALLOCATED(Custody) - public: - static Custody* get_if_cached(Custody* parent, const StringView& name); - static NonnullRefPtr get_or_create(Custody* parent, const StringView& name, Inode&, int mount_flags); static NonnullRefPtr create(Custody* parent, const StringView& name, Inode& inode, int mount_flags) { return adopt(*new Custody(parent, name, inode, mount_flags)); @@ -60,27 +53,14 @@ public: const String& name() const { return m_name; } String absolute_path() const; - bool is_deleted() const { return m_deleted; } - bool is_mounted_on() const { return m_mounted_on; } - int mount_flags() const { return m_mount_flags; } - void did_delete(Badge); - void did_mount_on(Badge); - void did_rename(Badge, const String& name); - - // For InlineLinkedListNode. - Custody* m_next { nullptr }; - Custody* m_prev { nullptr }; - private: Custody(Custody* parent, const StringView& name, Inode&, int mount_flags); RefPtr m_parent; String m_name; NonnullRefPtr m_inode; - bool m_deleted { false }; - bool m_mounted_on { false }; int m_mount_flags { 0 }; }; diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 24bfd3f5f7..d1d9064c12 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -74,7 +74,6 @@ KResult VFS::mount(FS& file_system, Custody& mount_point, int flags) // FIXME: check that this is not already a mount point Mount mount { file_system, &mount_point, flags }; m_mounts.append(move(mount)); - mount_point.did_mount_on({}); return KSuccess; } @@ -84,7 +83,6 @@ KResult VFS::bind_mount(Custody& source, Custody& mount_point, int flags) // FIXME: check that this is not already a mount point Mount mount { source.inode(), mount_point, flags }; m_mounts.append(move(mount)); - mount_point.did_mount_on({}); return KSuccess; } @@ -471,7 +469,6 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base) auto result = new_parent_inode.remove_child(new_basename); if (result.is_error()) return result; - new_custody.did_delete({}); } auto result = new_parent_inode.add_child(old_inode.identifier(), new_basename, old_inode.mode()); @@ -481,7 +478,6 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base) result = old_parent_inode.remove_child(FileSystemPath(old_path).basename()); if (result.is_error()) return result; - old_custody.did_rename({}, new_basename); return KSuccess; } @@ -582,7 +578,6 @@ KResult VFS::unlink(StringView path, Custody& base) if (result.is_error()) return result; - custody.did_delete({}); return KSuccess; }