From 85ba8df340ca1aa594fa3fa5113cdc5e1d03654c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 19 Dec 2011 08:22:16 +0000 Subject: [PATCH] [NTOSKRNL] - Always use push locks within a critical region svn path=/trunk/; revision=54692 --- reactos/ntoskrnl/cc/pin.c | 2 ++ reactos/ntoskrnl/cc/view.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/cc/pin.c b/reactos/ntoskrnl/cc/pin.c index 193de339e4d..2fb8f71e8e8 100644 --- a/reactos/ntoskrnl/cc/pin.c +++ b/reactos/ntoskrnl/cc/pin.c @@ -240,6 +240,7 @@ CcUnpinRepinnedBcb ( IoStatus->Information = 0; if (WriteThrough) { + KeEnterCriticalRegion(); ExAcquirePushLockExclusive(&iBcb->CacheSegment->Lock); if (iBcb->CacheSegment->Dirty) { @@ -250,6 +251,7 @@ CcUnpinRepinnedBcb ( IoStatus->Status = STATUS_SUCCESS; } ExReleasePushLockExclusive(&iBcb->CacheSegment->Lock); + KeLeaveCriticalRegion(); } else { diff --git a/reactos/ntoskrnl/cc/view.c b/reactos/ntoskrnl/cc/view.c index bd52296509c..89167bfde3f 100644 --- a/reactos/ntoskrnl/cc/view.c +++ b/reactos/ntoskrnl/cc/view.c @@ -448,6 +448,7 @@ CcRosReleaseCacheSegment(PBCB Bcb, KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); ExReleasePushLock(&CacheSeg->Lock); + KeLeaveCriticalRegion(); return(STATUS_SUCCESS); } @@ -476,6 +477,7 @@ CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset) { CcRosCacheSegmentIncRefCount(current); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); + KeEnterCriticalRegion(); ExAcquirePushLockExclusive(¤t->Lock); return(current); } @@ -525,6 +527,7 @@ CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset) CacheSeg->Dirty = TRUE; ExReleasePushLock(&CacheSeg->Lock); + KeLeaveCriticalRegion(); return(STATUS_SUCCESS); } @@ -574,6 +577,8 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty) KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); ExReleasePushLock(&CacheSeg->Lock); + KeLeaveCriticalRegion(); + return(STATUS_SUCCESS); } @@ -621,6 +626,7 @@ CcRosCreateCacheSegment(PBCB Bcb, current->DirtySegmentListEntry.Blink = NULL; current->ReferenceCount = 1; ExInitializePushLock(¤t->Lock); + KeEnterCriticalRegion(); ExAcquirePushLockExclusive(¤t->Lock); KeAcquireGuardedMutex(&ViewLock); @@ -655,7 +661,8 @@ CcRosCreateCacheSegment(PBCB Bcb, KeReleaseGuardedMutex(&ViewLock); ExFreeToNPagedLookasideList(&CacheSegLookasideList, *CacheSeg); *CacheSeg = current; - ExAcquirePushLockExclusive(¤t->Lock); + /* We're still in the critical region from above */ + ExAcquirePushLockExclusive(¤t->Lock); return STATUS_SUCCESS; } if (current->FileOffset < FileOffset) @@ -1040,8 +1047,9 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers, IoStatus->Status = Status; } } - KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql); ExReleasePushLock(¤t->Lock); + KeLeaveCriticalRegion(); + KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql); CcRosCacheSegmentDecRefCount(current); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); }