From cb04caa18e3ba433a79e0033a7607679f9444f00 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 17 Aug 2022 20:30:21 +0200 Subject: [PATCH] Kernel: Protect the Custody cache with a spinlock Protecting it with a mutex meant that anyone unref()'ing a Custody might need to block on said mutex. --- Kernel/FileSystem/Custody.cpp | 8 ++++---- Kernel/FileSystem/Custody.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index f3944b793b..7dca80c50c 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -13,16 +13,16 @@ namespace Kernel { -static Singleton> s_all_instances; +static Singleton> s_all_instances; -MutexProtected& Custody::all_instances() +SpinlockProtected& Custody::all_instances() { return s_all_instances; } ErrorOr> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags) { - return all_instances().with_exclusive([&](auto& all_custodies) -> ErrorOr> { + return all_instances().with([&](auto& all_custodies) -> ErrorOr> { for (Custody& custody : all_custodies) { if (custody.parent() == parent && custody.name() == name diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h index bdb4fcc6fd..5de67c1ed3 100644 --- a/Kernel/FileSystem/Custody.h +++ b/Kernel/FileSystem/Custody.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -12,11 +12,11 @@ #include #include #include -#include +#include namespace Kernel { -class Custody : public ListedRefCounted { +class Custody : public ListedRefCounted { public: static ErrorOr> try_create(Custody* parent, StringView name, Inode&, int mount_flags); @@ -44,7 +44,7 @@ private: public: using AllCustodiesList = IntrusiveList<&Custody::m_all_custodies_list_node>; - static MutexProtected& all_instances(); + static SpinlockProtected& all_instances(); }; }