mirror of
https://github.com/reactos/reactos.git
synced 2024-06-28 17:01:28 +00:00
[NTOS:CC]
- Centralize VACB locking/unlocking into inline functions for easier instrumentation svn path=/trunk/; revision=71991
This commit is contained in:
parent
7c0554a53f
commit
2a6c4f1119
|
@ -187,7 +187,7 @@ CcPinRead (
|
|||
iBcb->Pinned = TRUE;
|
||||
if (InterlockedIncrement(&iBcb->Vacb->PinCount) == 1)
|
||||
{
|
||||
KeReleaseMutex(&iBcb->Vacb->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(iBcb->Vacb);
|
||||
}
|
||||
|
||||
if (Flags & PIN_EXCLUSIVE)
|
||||
|
@ -283,11 +283,7 @@ CcUnpinDataForThread (
|
|||
iBcb->Pinned = FALSE;
|
||||
if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0)
|
||||
{
|
||||
KeWaitForSingleObject(&iBcb->Vacb->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
CcRosAcquireVacbLock(iBcb->Vacb, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,11 +335,7 @@ CcUnpinRepinnedBcb (
|
|||
IoStatus->Information = 0;
|
||||
if (WriteThrough)
|
||||
{
|
||||
KeWaitForSingleObject(&iBcb->Vacb->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
CcRosAcquireVacbLock(iBcb->Vacb, NULL);
|
||||
if (iBcb->Vacb->Dirty)
|
||||
{
|
||||
IoStatus->Status = CcRosFlushVacb(iBcb->Vacb);
|
||||
|
@ -352,7 +344,7 @@ CcUnpinRepinnedBcb (
|
|||
{
|
||||
IoStatus->Status = STATUS_SUCCESS;
|
||||
}
|
||||
KeReleaseMutex(&iBcb->Vacb->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(iBcb->Vacb);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -365,11 +357,7 @@ CcUnpinRepinnedBcb (
|
|||
iBcb->Pinned = FALSE;
|
||||
if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0)
|
||||
{
|
||||
KeWaitForSingleObject(&iBcb->Vacb->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
CcRosAcquireVacbLock(iBcb->Vacb, NULL);
|
||||
}
|
||||
}
|
||||
ExDeleteResourceLite(&iBcb->Lock);
|
||||
|
|
|
@ -199,11 +199,8 @@ CcRosFlushDirtyPages (
|
|||
continue;
|
||||
}
|
||||
|
||||
Status = KeWaitForSingleObject(¤t->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
Wait ? NULL : &ZeroTimeout);
|
||||
Status = CcRosAcquireVacbLock(current,
|
||||
Wait ? NULL : &ZeroTimeout);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
|
||||
|
@ -217,7 +214,7 @@ CcRosFlushDirtyPages (
|
|||
/* One reference is added above */
|
||||
if (current->ReferenceCount > 2)
|
||||
{
|
||||
KeReleaseMutex(¤t->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(current);
|
||||
current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
|
||||
current->SharedCacheMap->LazyWriteContext);
|
||||
CcRosVacbDecRefCount(current);
|
||||
|
@ -228,7 +225,7 @@ CcRosFlushDirtyPages (
|
|||
|
||||
Status = CcRosFlushVacb(current);
|
||||
|
||||
KeReleaseMutex(¤t->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(current);
|
||||
current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
|
||||
current->SharedCacheMap->LazyWriteContext);
|
||||
|
||||
|
@ -427,7 +424,7 @@ CcRosReleaseVacb (
|
|||
KeReleaseGuardedMutex(&ViewLock);
|
||||
if (InterlockedCompareExchange(&Vacb->PinCount, 0, 0) == 0)
|
||||
{
|
||||
KeReleaseMutex(&Vacb->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(Vacb);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -467,11 +464,7 @@ CcRosLookupVacb (
|
|||
KeReleaseGuardedMutex(&ViewLock);
|
||||
if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0)
|
||||
{
|
||||
KeWaitForSingleObject(¤t->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
CcRosAcquireVacbLock(current, NULL);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
@ -527,7 +520,7 @@ CcRosMarkDirtyVacb (
|
|||
|
||||
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
|
||||
KeReleaseGuardedMutex(&ViewLock);
|
||||
KeReleaseMutex(&Vacb->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(Vacb);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -580,7 +573,7 @@ CcRosUnmapVacb (
|
|||
|
||||
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
|
||||
KeReleaseGuardedMutex(&ViewLock);
|
||||
KeReleaseMutex(&Vacb->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(Vacb);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -683,11 +676,7 @@ CcRosCreateVacb (
|
|||
current->ReferenceCount = 1;
|
||||
current->PinCount = 0;
|
||||
KeInitializeMutex(¤t->Mutex, 0);
|
||||
KeWaitForSingleObject(¤t->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
CcRosAcquireVacbLock(current, NULL);
|
||||
KeAcquireGuardedMutex(&ViewLock);
|
||||
|
||||
*Vacb = current;
|
||||
|
@ -719,17 +708,13 @@ CcRosCreateVacb (
|
|||
current);
|
||||
}
|
||||
#endif
|
||||
KeReleaseMutex(&(*Vacb)->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(*Vacb);
|
||||
KeReleaseGuardedMutex(&ViewLock);
|
||||
ExFreeToNPagedLookasideList(&VacbLookasideList, *Vacb);
|
||||
*Vacb = current;
|
||||
if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0)
|
||||
{
|
||||
KeWaitForSingleObject(¤t->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
CcRosAcquireVacbLock(current, NULL);
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -962,7 +947,7 @@ CcFlushCache (
|
|||
|
||||
if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0)
|
||||
{
|
||||
KeReleaseMutex(¤t->Mutex, FALSE);
|
||||
CcRosReleaseVacbLock(current);
|
||||
}
|
||||
|
||||
KeAcquireGuardedMutex(&ViewLock);
|
||||
|
|
|
@ -340,6 +340,29 @@ NTSTATUS
|
|||
NTAPI
|
||||
CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
|
||||
|
||||
FORCEINLINE
|
||||
NTSTATUS
|
||||
CcRosAcquireVacbLock(
|
||||
_Inout_ PROS_VACB Vacb,
|
||||
_In_ PLARGE_INTEGER Timeout)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
Status = KeWaitForSingleObject(&Vacb->Mutex,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
Timeout);
|
||||
return Status;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
VOID
|
||||
CcRosReleaseVacbLock(
|
||||
_Inout_ PROS_VACB Vacb)
|
||||
{
|
||||
KeReleaseMutex(&Vacb->Mutex, FALSE);
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
BOOLEAN
|
||||
DoRangesIntersect(
|
||||
|
|
Loading…
Reference in a new issue