ramfs: Avoid acquiring locks for suspend/resume of EntryIterator in more cases.

If we don't have an Entry to attach/detach from, then we don't need
to acquire any locks at all. Now that we return multiple dirents
from read_dir, it's much more likely that we wind up with
EntryIterators in such a state, so this avoids some lock contention.
This commit is contained in:
Augustin Cavalier 2025-01-14 21:37:43 -05:00
parent 3f73e6e934
commit 89dd4ee819

View File

@ -64,13 +64,13 @@ EntryIterator::Suspend()
if (fDirectory == NULL || fSuspended)
return B_ERROR;
if (!fDirectory->GetVolume()->IteratorLock())
return B_ERROR;
if (fEntry != NULL)
if (fEntry != NULL) {
if (!fDirectory->GetVolume()->IteratorLock())
return B_ERROR;
fEntry->AttachEntryIterator(this);
fDirectory->GetVolume()->IteratorUnlock();
}
fDirectory->GetVolume()->IteratorUnlock();
fSuspended = true;
return B_OK;
}
@ -82,14 +82,14 @@ EntryIterator::Resume()
if (fDirectory == NULL)
return B_ERROR;
if (!fDirectory->GetVolume()->IteratorLock())
return B_ERROR;
if (fSuspended && fEntry != NULL)
if (fSuspended && fEntry != NULL) {
if (!fDirectory->GetVolume()->IteratorLock())
return B_ERROR;
fEntry->DetachEntryIterator(this);
fDirectory->GetVolume()->IteratorUnlock();
}
fSuspended = false;
fDirectory->GetVolume()->IteratorUnlock();
return B_OK;
}