Author: tfaber
Date: Sun Jul 24 17:10:30 2016
New Revision: 71991
URL:
http://svn.reactos.org/svn/reactos?rev=71991&view=rev
Log:
[NTOS:CC]
- Centralize VACB locking/unlocking into inline functions for easier instrumentation
Modified:
trunk/reactos/ntoskrnl/cc/pin.c
trunk/reactos/ntoskrnl/cc/view.c
trunk/reactos/ntoskrnl/include/internal/cc.h
Modified: trunk/reactos/ntoskrnl/cc/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=7199…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Sun Jul 24 17:10:30 2016
@@ -187,7 +187,7 @@
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 @@
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 @@
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 @@
{
IoStatus->Status = STATUS_SUCCESS;
}
- KeReleaseMutex(&iBcb->Vacb->Mutex, FALSE);
+ CcRosReleaseVacbLock(iBcb->Vacb);
}
else
{
@@ -365,11 +357,7 @@
iBcb->Pinned = FALSE;
if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0)
{
- KeWaitForSingleObject(&iBcb->Vacb->Mutex,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ CcRosAcquireVacbLock(iBcb->Vacb, NULL);
}
}
ExDeleteResourceLite(&iBcb->Lock);
Modified: trunk/reactos/ntoskrnl/cc/view.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=719…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Sun Jul 24 17:10:30 2016
@@ -199,11 +199,8 @@
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 @@
/* 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 @@
Status = CcRosFlushVacb(current);
- KeReleaseMutex(¤t->Mutex, FALSE);
+ CcRosReleaseVacbLock(current);
current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
current->SharedCacheMap->LazyWriteContext);
@@ -427,7 +424,7 @@
KeReleaseGuardedMutex(&ViewLock);
if (InterlockedCompareExchange(&Vacb->PinCount, 0, 0) == 0)
{
- KeReleaseMutex(&Vacb->Mutex, FALSE);
+ CcRosReleaseVacbLock(Vacb);
}
return STATUS_SUCCESS;
@@ -467,11 +464,7 @@
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 @@
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- KeReleaseMutex(&Vacb->Mutex, FALSE);
+ CcRosReleaseVacbLock(Vacb);
return STATUS_SUCCESS;
}
@@ -580,7 +573,7 @@
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- KeReleaseMutex(&Vacb->Mutex, FALSE);
+ CcRosReleaseVacbLock(Vacb);
return STATUS_SUCCESS;
}
@@ -683,11 +676,7 @@
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 @@
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 @@
if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0)
{
- KeReleaseMutex(¤t->Mutex, FALSE);
+ CcRosReleaseVacbLock(current);
}
KeAcquireGuardedMutex(&ViewLock);
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] Sun Jul 24 17:10:30 2016
@@ -341,6 +341,29 @@
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(
_In_ LONGLONG Offset1,