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:
@@ -224,21 +224,24 @@ DirectoryCache::_LoadSnapshot(bool trash)
|
||||
// obtained snapshot that might indicate stale nodes.
|
||||
while (!fNameCache.IsEmpty()) {
|
||||
NameCacheEntry* current = fNameCache.RemoveHead();
|
||||
bool nodeFound = false;
|
||||
for (SinglyLinkedList<NameCacheEntry>::ConstIterator it
|
||||
= newSnapshot->fEntries.GetIterator();
|
||||
NameCacheEntry* snapshotEntry = it.Next();) {
|
||||
if (current->fNode == snapshotEntry->fNode
|
||||
&& strcmp(current->fName, snapshotEntry->fName) == 0) {
|
||||
nodeFound = true;
|
||||
break;
|
||||
if (strcmp(current->fName, "..") != 0) {
|
||||
bool nodeFound = false;
|
||||
for (SinglyLinkedList<NameCacheEntry>::ConstIterator it
|
||||
= newSnapshot->fEntries.GetIterator();
|
||||
NameCacheEntry* snapshotEntry = it.Next();) {
|
||||
if (current->fNode == snapshotEntry->fNode
|
||||
&& strcmp(current->fName, snapshotEntry->fName) == 0) {
|
||||
nodeFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nodeFound) {
|
||||
// The inode-name association that was cached in 'current' is no longer valid.
|
||||
result = fInode->GetFileSystem()->TrashStaleNode(current->fNode);
|
||||
if (result != B_OK)
|
||||
INFORM("_LoadSnapshot: Couldn't free stale node %" B_PRIdINO "\n",
|
||||
current->fNode);
|
||||
}
|
||||
}
|
||||
if (!nodeFound) {
|
||||
// The inode-name association that was cached in 'current' is no longer valid.
|
||||
result = fInode->GetFileSystem()->TrashStaleNode(current->fNode);
|
||||
if (result != B_OK)
|
||||
INFORM("_LoadSnapshot: Couldn't free stale node.\n");
|
||||
}
|
||||
delete current;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user