nfs4: Fix _LoadSnapshot comparison logic

* If a ".." entry is present in fNameCache, don't look for a matching
  entry in the DirectoryCacheSnapshot.
* Fixes an assert failure reported incidentally in the #19656 ticket,
  but is not related to the original reported bug.

This is a correction to 258fce50e0.

The comparison added in that patch is between 2 different types of
directory entry caches that exist in the DirectoryCache class.  One of
them caches "..", and the other one doesn't.

Change-Id: I56335271436be18e363f6b164e1fc2de24193bfb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9498
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Jim906
2025-07-17 15:52:26 +00:00
committed by waddlesplash
parent 46e9a93eea
commit 23835bdf84
@@ -224,6 +224,7 @@ DirectoryCache::_LoadSnapshot(bool trash)
// obtained snapshot that might indicate stale nodes. // obtained snapshot that might indicate stale nodes.
while (!fNameCache.IsEmpty()) { while (!fNameCache.IsEmpty()) {
NameCacheEntry* current = fNameCache.RemoveHead(); NameCacheEntry* current = fNameCache.RemoveHead();
if (strcmp(current->fName, "..") != 0) {
bool nodeFound = false; bool nodeFound = false;
for (SinglyLinkedList<NameCacheEntry>::ConstIterator it for (SinglyLinkedList<NameCacheEntry>::ConstIterator it
= newSnapshot->fEntries.GetIterator(); = newSnapshot->fEntries.GetIterator();
@@ -238,7 +239,9 @@ DirectoryCache::_LoadSnapshot(bool trash)
// The inode-name association that was cached in 'current' is no longer valid. // The inode-name association that was cached in 'current' is no longer valid.
result = fInode->GetFileSystem()->TrashStaleNode(current->fNode); result = fInode->GetFileSystem()->TrashStaleNode(current->fNode);
if (result != B_OK) if (result != B_OK)
INFORM("_LoadSnapshot: Couldn't free stale node.\n"); INFORM("_LoadSnapshot: Couldn't free stale node %" B_PRIdINO "\n",
current->fNode);
}
} }
delete current; delete current;
} }