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.
This commit is contained in:
Augustin Cavalier
2022-08-03 17:44:59 -04:00
parent 25866ebeeb
commit 3a19a89f1a
+1 -1
View File
@@ -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;