mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NTOSKRNL] When pinning data, try to find an already pinned BCB
If found, attempt to lock it and return it. This fixes a lot of CcPinRead tests (and seems to speed up a bit ReactOS)
This commit is contained in:
parent
9fc75c1132
commit
7fd2751c87
1 changed files with 42 additions and 9 deletions
|
@ -299,6 +299,9 @@ CcPinRead (
|
||||||
OUT PVOID * Bcb,
|
OUT PVOID * Bcb,
|
||||||
OUT PVOID * Buffer)
|
OUT PVOID * Buffer)
|
||||||
{
|
{
|
||||||
|
KIRQL OldIrql;
|
||||||
|
BOOLEAN Result;
|
||||||
|
PINTERNAL_BCB iBcb;
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap;
|
PROS_SHARED_CACHE_MAP SharedCacheMap;
|
||||||
|
|
||||||
CCTRACE(CC_API_DEBUG, "FileOffset=%p FileOffset=%p Length=%lu Flags=0x%lx\n",
|
CCTRACE(CC_API_DEBUG, "FileOffset=%p FileOffset=%p Length=%lu Flags=0x%lx\n",
|
||||||
|
@ -320,17 +323,47 @@ CcPinRead (
|
||||||
++CcPinReadNoWait;
|
++CcPinReadNoWait;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map first */
|
KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
|
||||||
if (!CcpMapData(SharedCacheMap, FileOffset, Length, Flags, Bcb, Buffer))
|
iBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, TRUE);
|
||||||
{
|
KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pin then */
|
if (iBcb == NULL)
|
||||||
if (!CcPinMappedData(FileObject, FileOffset, Length, Flags, Bcb))
|
|
||||||
{
|
{
|
||||||
CcUnpinData(*Bcb);
|
/* Map first */
|
||||||
return FALSE;
|
if (!CcpMapData(SharedCacheMap, FileOffset, Length, Flags, Bcb, Buffer))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pin then */
|
||||||
|
if (!CcPinMappedData(FileObject, FileOffset, Length, Flags, Bcb))
|
||||||
|
{
|
||||||
|
CcUnpinData(*Bcb);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* We found a BCB, lock it and return it */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (BooleanFlagOn(Flags, PIN_EXCLUSIVE))
|
||||||
|
{
|
||||||
|
Result = ExAcquireResourceExclusiveLite(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = ExAcquireSharedStarveExclusive(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Result)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
++iBcb->PinCount;
|
||||||
|
++iBcb->RefCount;
|
||||||
|
|
||||||
|
*Bcb = iBcb;
|
||||||
|
*Buffer = (PUCHAR)iBcb->Vacb->BaseAddress + FileOffset->QuadPart % VACB_MAPPING_GRANULARITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in a new issue