From 3a19a89f1a6bf36f24fc5132b26a4fb772a925b8 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 3 Aug 2022 17:44:59 -0400 Subject: [PATCH] kernel/fs: Fix generation reference in EntryCache. We are trying to add the enty to the current generation, so we need to use the current generation's next_index, not the previous. This was apparently broken since this code was imported. The "miss" here meant we always acquired the write-lock and then ran the more expensive add operation, which performs this same check (correctly). Slight performance improvement seen in basic testing, but nothing too drastic. --- src/system/kernel/fs/EntryCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/kernel/fs/EntryCache.cpp b/src/system/kernel/fs/EntryCache.cpp index cb8973e6a3..1552e055cd 100644 --- a/src/system/kernel/fs/EntryCache.cpp +++ b/src/system/kernel/fs/EntryCache.cpp @@ -189,7 +189,7 @@ EntryCache::Lookup(ino_t dirID, const char* name, ino_t& _nodeID, entry->index = kEntryNotInArray; // add to the current generation - const int32 index = atomic_add(&fGenerations[oldGeneration].next_index, 1); + const int32 index = atomic_add(&fGenerations[fCurrentGeneration].next_index, 1); if (index < fGenerations[fCurrentGeneration].entries_size) { fGenerations[fCurrentGeneration].entries[index] = entry; entry->index = index;