From c70e2f25197650bfce3cb9bf5f952cd83e15bc95 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 18 Aug 2021 00:43:16 +0200 Subject: [PATCH] Kernel: Protect the Custody cache with a mutex instead of a spinlock We don't need to access the Custody cache in IRQs or anything like that, so it should be fine to use a regular Mutex (via ProtectedValue.) This allows threads to block while waiting for the custody cache. Thanks to Sergey for pointing this out. :^) --- Kernel/FileSystem/Custody.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index 2b92f15cb8..b3c7876f34 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -10,20 +10,20 @@ #include #include #include -#include +#include namespace Kernel { -static Singleton> s_all_custodies; +static Singleton> s_all_custodies; -static SpinLockProtectedValue& all_custodies() +static ProtectedValue& all_custodies() { return s_all_custodies; } KResultOr> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags) { - return all_custodies().with([&](auto& all_custodies) -> KResultOr> { + return all_custodies().with_exclusive([&](auto& all_custodies) -> KResultOr> { for (Custody& custody : all_custodies) { if (custody.parent() == parent && custody.name() == name @@ -47,7 +47,7 @@ KResultOr> Custody::try_create(Custody* parent, StringVie bool Custody::unref() const { - bool should_destroy = all_custodies().with([&](auto&) { + bool should_destroy = all_custodies().with_exclusive([&](auto&) { if (deref_base()) return false; m_all_custodies_list_node.remove();