[NTOSKRNL] Use interlocked operations when dealing with map count.

CORE-14349
This commit is contained in:
Pierre Schweitzer 2018-04-08 18:58:15 +02:00
parent 1b672981e2
commit 40017a54f9

View file

@ -344,7 +344,7 @@ retry:
CcRosVacbIncRefCount(current); CcRosVacbIncRefCount(current);
/* Check if it's mapped and not dirty */ /* Check if it's mapped and not dirty */
if (current->MappedCount > 0 && !current->Dirty) if (InterlockedCompareExchange((PLONG)&current->MappedCount, 0, 0) > 0 && !current->Dirty)
{ {
/* We have to break these locks because Cc sucks */ /* We have to break these locks because Cc sucks */
KeReleaseSpinLock(&current->SharedCacheMap->CacheMapLock, oldIrql); KeReleaseSpinLock(&current->SharedCacheMap->CacheMapLock, oldIrql);
@ -448,14 +448,13 @@ CcRosReleaseVacb (
if (Mapped) if (Mapped)
{ {
Vacb->MappedCount++; if (InterlockedIncrement((PLONG)&Vacb->MappedCount) == 1)
} {
Refs = CcRosVacbDecRefCount(Vacb); CcRosVacbIncRefCount(Vacb);
if (Mapped && (Vacb->MappedCount == 1)) }
{
CcRosVacbIncRefCount(Vacb);
} }
Refs = CcRosVacbDecRefCount(Vacb);
ASSERT(Refs > 0); ASSERT(Refs > 0);
CcRosReleaseVacbLock(Vacb); CcRosReleaseVacbLock(Vacb);
@ -630,9 +629,7 @@ CcRosUnmapVacb (
} }
ASSERT(Vacb->MappedCount != 0); ASSERT(Vacb->MappedCount != 0);
Vacb->MappedCount--; if (InterlockedDecrement((PLONG)&Vacb->MappedCount) == 0)
if (Vacb->MappedCount == 0)
{ {
CcRosVacbDecRefCount(Vacb); CcRosVacbDecRefCount(Vacb);
} }