Author: tfaber
Date: Mon Jul 25 08:48:50 2016
New Revision: 71993
URL:
http://svn.reactos.org/svn/reactos?rev=71993&view=rev
Log:
[NTOS:CC]
- Unconditionally acquire the VACB lock during map/pin/unpin operations and release it
appropriately
CORE-11555 #resolve
CORE-11654 CORE-11504 CORE-11328 #comment This might be fixed with r71993. Could you retry
please?
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] Mon Jul 25 08:48:50 2016
@@ -185,10 +185,8 @@
ASSERT(iBcb->Pinned == FALSE);
iBcb->Pinned = TRUE;
- if (InterlockedIncrement(&iBcb->Vacb->PinCount) == 1)
- {
- CcRosReleaseVacbLock(iBcb->Vacb);
- }
+ iBcb->Vacb->PinCount++;
+ CcRosReleaseVacbLock(iBcb->Vacb);
if (Flags & PIN_EXCLUSIVE)
{
@@ -281,10 +279,8 @@
{
ExReleaseResourceForThreadLite(&iBcb->Lock, ResourceThreadId);
iBcb->Pinned = FALSE;
- if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0)
- {
- CcRosAcquireVacbLock(iBcb->Vacb, NULL);
- }
+ CcRosAcquireVacbLock(iBcb->Vacb, NULL);
+ iBcb->Vacb->PinCount--;
}
CcRosReleaseVacb(iBcb->Vacb->SharedCacheMap,
@@ -355,10 +351,8 @@
{
ExReleaseResourceLite(&iBcb->Lock);
iBcb->Pinned = FALSE;
- if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0)
- {
- CcRosAcquireVacbLock(iBcb->Vacb, NULL);
- }
+ CcRosAcquireVacbLock(iBcb->Vacb, NULL);
+ iBcb->Vacb->PinCount--;
}
ExDeleteResourceLite(&iBcb->Lock);
ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
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] Mon Jul 25 08:48:50 2016
@@ -422,10 +422,7 @@
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- if (InterlockedCompareExchange(&Vacb->PinCount, 0, 0) == 0)
- {
- CcRosReleaseVacbLock(Vacb);
- }
+ CcRosReleaseVacbLock(Vacb);
return STATUS_SUCCESS;
}
@@ -462,10 +459,7 @@
CcRosVacbIncRefCount(current);
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0)
- {
- CcRosAcquireVacbLock(current, NULL);
- }
+ CcRosAcquireVacbLock(current, NULL);
return current;
}
if (current->FileOffset.QuadPart > FileOffset)
@@ -712,10 +706,7 @@
KeReleaseGuardedMutex(&ViewLock);
ExFreeToNPagedLookasideList(&VacbLookasideList, *Vacb);
*Vacb = current;
- if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0)
- {
- CcRosAcquireVacbLock(current, NULL);
- }
+ CcRosAcquireVacbLock(current, NULL);
return STATUS_SUCCESS;
}
if (current->FileOffset.QuadPart < FileOffset)
@@ -945,10 +936,7 @@
}
}
- if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0)
- {
- CcRosReleaseVacbLock(current);
- }
+ CcRosReleaseVacbLock(current);
KeAcquireGuardedMutex(&ViewLock);
KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql);
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] Mon Jul 25 08:48:50 2016
@@ -185,7 +185,8 @@
/* Number of references. */
ULONG ReferenceCount;
/* How many times was it pinned? */
- volatile LONG PinCount;
+ _Guarded_by_(Mutex)
+ LONG PinCount;
/* Pointer to the shared cache map for the file which this view maps data for. */
PROS_SHARED_CACHE_MAP SharedCacheMap;
/* Pointer to the next VACB in a chain. */