[NTOSKRNL]

- Always use push locks within a critical region

svn path=/trunk/; revision=54692
This commit is contained in:
Cameron Gutman 2011-12-19 08:22:16 +00:00
parent 26f43d7060
commit 85ba8df340
2 changed files with 12 additions and 2 deletions

View file

@ -240,6 +240,7 @@ CcUnpinRepinnedBcb (
IoStatus->Information = 0; IoStatus->Information = 0;
if (WriteThrough) if (WriteThrough)
{ {
KeEnterCriticalRegion();
ExAcquirePushLockExclusive(&iBcb->CacheSegment->Lock); ExAcquirePushLockExclusive(&iBcb->CacheSegment->Lock);
if (iBcb->CacheSegment->Dirty) if (iBcb->CacheSegment->Dirty)
{ {
@ -250,6 +251,7 @@ CcUnpinRepinnedBcb (
IoStatus->Status = STATUS_SUCCESS; IoStatus->Status = STATUS_SUCCESS;
} }
ExReleasePushLockExclusive(&iBcb->CacheSegment->Lock); ExReleasePushLockExclusive(&iBcb->CacheSegment->Lock);
KeLeaveCriticalRegion();
} }
else else
{ {

View file

@ -448,6 +448,7 @@ CcRosReleaseCacheSegment(PBCB Bcb,
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock); KeReleaseGuardedMutex(&ViewLock);
ExReleasePushLock(&CacheSeg->Lock); ExReleasePushLock(&CacheSeg->Lock);
KeLeaveCriticalRegion();
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -476,6 +477,7 @@ CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset)
{ {
CcRosCacheSegmentIncRefCount(current); CcRosCacheSegmentIncRefCount(current);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
KeEnterCriticalRegion();
ExAcquirePushLockExclusive(&current->Lock); ExAcquirePushLockExclusive(&current->Lock);
return(current); return(current);
} }
@ -525,6 +527,7 @@ CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
CacheSeg->Dirty = TRUE; CacheSeg->Dirty = TRUE;
ExReleasePushLock(&CacheSeg->Lock); ExReleasePushLock(&CacheSeg->Lock);
KeLeaveCriticalRegion();
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -574,6 +577,8 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
ExReleasePushLock(&CacheSeg->Lock); ExReleasePushLock(&CacheSeg->Lock);
KeLeaveCriticalRegion();
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -621,6 +626,7 @@ CcRosCreateCacheSegment(PBCB Bcb,
current->DirtySegmentListEntry.Blink = NULL; current->DirtySegmentListEntry.Blink = NULL;
current->ReferenceCount = 1; current->ReferenceCount = 1;
ExInitializePushLock(&current->Lock); ExInitializePushLock(&current->Lock);
KeEnterCriticalRegion();
ExAcquirePushLockExclusive(&current->Lock); ExAcquirePushLockExclusive(&current->Lock);
KeAcquireGuardedMutex(&ViewLock); KeAcquireGuardedMutex(&ViewLock);
@ -655,7 +661,8 @@ CcRosCreateCacheSegment(PBCB Bcb,
KeReleaseGuardedMutex(&ViewLock); KeReleaseGuardedMutex(&ViewLock);
ExFreeToNPagedLookasideList(&CacheSegLookasideList, *CacheSeg); ExFreeToNPagedLookasideList(&CacheSegLookasideList, *CacheSeg);
*CacheSeg = current; *CacheSeg = current;
ExAcquirePushLockExclusive(&current->Lock); /* We're still in the critical region from above */
ExAcquirePushLockExclusive(&current->Lock);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
if (current->FileOffset < FileOffset) if (current->FileOffset < FileOffset)
@ -1040,8 +1047,9 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
IoStatus->Status = Status; IoStatus->Status = Status;
} }
} }
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
ExReleasePushLock(&current->Lock); ExReleasePushLock(&current->Lock);
KeLeaveCriticalRegion();
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
CcRosCacheSegmentDecRefCount(current); CcRosCacheSegmentDecRefCount(current);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
} }