From 843bd43c5be5b5d1b8bff8aa2a81b99ed232bc57 Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 6 Aug 2022 18:07:03 +0300 Subject: [PATCH] Kernel/FileSystem: Mark ext2 inode lookup cache non-const For the lookup cache, no method being declared const tried to modify it, so it was easy to drop the mutable declaration on the HashMap member. --- Kernel/FileSystem/Ext2FileSystem.cpp | 6 +++--- Kernel/FileSystem/Ext2FileSystem.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index b2f90f85ac..48aa3b4cdd 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -1499,9 +1499,9 @@ ErrorOr> Ext2FS::create_inode(Ext2FSInode& parent_inode return new_inode; } -ErrorOr Ext2FSInode::populate_lookup_cache() const +ErrorOr Ext2FSInode::populate_lookup_cache() { - MutexLocker locker(m_inode_lock); + VERIFY(m_inode_lock.is_exclusively_locked_by_current_thread()); if (!m_lookup_cache.is_empty()) return {}; HashMap, InodeIndex> children; @@ -1521,11 +1521,11 @@ ErrorOr> Ext2FSInode::lookup(StringView name) { VERIFY(is_directory()); dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): Looking up '{}'", identifier(), name); - TRY(populate_lookup_cache()); InodeIndex inode_index; { MutexLocker locker(m_inode_lock); + TRY(populate_lookup_cache()); auto it = m_lookup_cache.find(name); if (it == m_lookup_cache.end()) { dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): '{}' not found", identifier(), name); diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index e9b7de9fbd..8441fc70a3 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -53,7 +53,7 @@ private: virtual ErrorOr get_block_address(int) override; ErrorOr write_directory(Vector&); - ErrorOr populate_lookup_cache() const; + ErrorOr populate_lookup_cache(); ErrorOr resize(u64); ErrorOr write_indirect_block(BlockBasedFileSystem::BlockIndex, Span); ErrorOr grow_doubly_indirect_block(BlockBasedFileSystem::BlockIndex, size_t, Span, Vector&, unsigned&); @@ -71,7 +71,7 @@ private: Ext2FSInode(Ext2FS&, InodeIndex); mutable Vector m_block_list; - mutable HashMap, InodeIndex> m_lookup_cache; + HashMap, InodeIndex> m_lookup_cache; ext2_inode m_raw_inode {}; };