Author: pschweitzer
Date: Mon May 23 19:47:39 2016
New Revision: 71387
URL:
http://svn.reactos.org/svn/reactos?rev=71387&view=rev
Log:
[NTOSKRNL]
In Cc, replace the Vacb mutex by a Bcb resource.
Note that the resource is still placed in the Vacb by it belongs to the Bcb.
This is required to really implement CcSetBcbOwnerPointer().
CORE-11310
Modified:
trunk/reactos/ntoskrnl/cc/pin.c
trunk/reactos/ntoskrnl/cc/view.c
trunk/reactos/ntoskrnl/include/internal/cc.h
trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/cc/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=7138…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Mon May 23 19:47:39 2016
@@ -290,11 +290,7 @@
IoStatus->Information = 0;
if (WriteThrough)
{
- KeWaitForSingleObject(&iBcb->Vacb->Mutex,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ ExAcquireResourceExclusiveLite(&iBcb->Vacb->Lock, TRUE);
if (iBcb->Vacb->Dirty)
{
IoStatus->Status = CcRosFlushVacb(iBcb->Vacb);
@@ -303,7 +299,7 @@
{
IoStatus->Status = STATUS_SUCCESS;
}
- KeReleaseMutex(&iBcb->Vacb->Mutex, FALSE);
+ ExReleaseResourceLite(&iBcb->Vacb->Lock);
}
else
{
Modified: trunk/reactos/ntoskrnl/cc/view.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=713…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Mon May 23 19:47:39 2016
@@ -166,12 +166,10 @@
PROS_VACB current;
BOOLEAN Locked;
NTSTATUS Status;
- LARGE_INTEGER ZeroTimeout;
DPRINT("CcRosFlushDirtyPages(Target %lu)\n", Target);
(*Count) = 0;
- ZeroTimeout.QuadPart = 0;
KeEnterCriticalRegion();
KeAcquireGuardedMutex(&ViewLock);
@@ -199,12 +197,8 @@
continue;
}
- Status = KeWaitForSingleObject(¤t->Mutex,
- Executive,
- KernelMode,
- FALSE,
- Wait ? NULL : &ZeroTimeout);
- if (Status != STATUS_SUCCESS)
+ Locked = ExAcquireResourceExclusiveLite(¤t->Lock, Wait);
+ if (!Locked)
{
current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
current->SharedCacheMap->LazyWriteContext);
@@ -217,7 +211,7 @@
/* One reference is added above */
if (current->ReferenceCount > 2)
{
- KeReleaseMutex(¤t->Mutex, FALSE);
+ ExReleaseResourceLite(¤t->Lock);
current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
current->SharedCacheMap->LazyWriteContext);
CcRosVacbDecRefCount(current);
@@ -228,7 +222,7 @@
Status = CcRosFlushVacb(current);
- KeReleaseMutex(¤t->Mutex, FALSE);
+ ExReleaseResourceLite(¤t->Lock);
current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite(
current->SharedCacheMap->LazyWriteContext);
@@ -425,7 +419,7 @@
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- KeReleaseMutex(&Vacb->Mutex, FALSE);
+ ExReleaseResourceLite(&Vacb->Lock);
return STATUS_SUCCESS;
}
@@ -462,11 +456,7 @@
CcRosVacbIncRefCount(current);
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- KeWaitForSingleObject(¤t->Mutex,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ ExAcquireResourceExclusiveLite(¤t->Lock, TRUE);
return current;
}
if (current->FileOffset.QuadPart > FileOffset)
@@ -521,7 +511,7 @@
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- KeReleaseMutex(&Vacb->Mutex, FALSE);
+ ExReleaseResourceLite(&Vacb->Lock);
return STATUS_SUCCESS;
}
@@ -574,7 +564,7 @@
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql);
KeReleaseGuardedMutex(&ViewLock);
- KeReleaseMutex(&Vacb->Mutex, FALSE);
+ ExReleaseResourceLite(&Vacb->Lock);
return STATUS_SUCCESS;
}
@@ -675,12 +665,8 @@
current->DirtyVacbListEntry.Flink = NULL;
current->DirtyVacbListEntry.Blink = NULL;
current->ReferenceCount = 1;
- KeInitializeMutex(¤t->Mutex, 0);
- KeWaitForSingleObject(¤t->Mutex,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ ExInitializeResourceLite(¤t->Lock);
+ ExAcquireResourceExclusiveLite(¤t->Lock, TRUE);
KeAcquireGuardedMutex(&ViewLock);
*Vacb = current;
@@ -712,15 +698,11 @@
current);
}
#endif
- KeReleaseMutex(&(*Vacb)->Mutex, FALSE);
+ ExReleaseResourceLite(&(*Vacb)->Lock);
KeReleaseGuardedMutex(&ViewLock);
ExFreeToNPagedLookasideList(&VacbLookasideList, *Vacb);
*Vacb = current;
- KeWaitForSingleObject(¤t->Mutex,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ ExAcquireResourceExclusiveLite(¤t->Lock, TRUE);
return STATUS_SUCCESS;
}
if (current->FileOffset.QuadPart < FileOffset)
@@ -886,6 +868,7 @@
CcFreeCachePage,
NULL);
MmUnlockAddressSpace(MmGetKernelAddressSpace());
+ ExDeleteResourceLite(&Vacb->Lock);
ExFreeToNPagedLookasideList(&VacbLookasideList, Vacb);
return STATUS_SUCCESS;
@@ -949,7 +932,7 @@
IoStatus->Status = Status;
}
}
- KeReleaseMutex(¤t->Mutex, FALSE);
+ ExReleaseResourceLite(¤t->Lock);
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 May 23 19:47:39 2016
@@ -164,6 +164,8 @@
PVOID BaseAddress;
/* Memory area representing the region where the view's data is mapped. */
struct _MEMORY_AREA* MemoryArea;
+ /* Lock */
+ ERESOURCE Lock;
/* Are the contents of the view valid. */
BOOLEAN Valid;
/* Are the contents of the view newer than those on disk. */
@@ -179,8 +181,6 @@
LIST_ENTRY VacbLruListEntry;
/* Offset in the file which this view maps. */
LARGE_INTEGER FileOffset;
- /* Mutex */
- KMUTEX Mutex;
/* Number of references. */
ULONG ReferenceCount;
/* Pointer to the shared cache map for the file which this view maps data for. */
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Mon May 23 19:47:39 2016
@@ -1110,6 +1110,7 @@
* filesystems do because it is safe for us to use an offset with an
* alignment less than the file system block size.
*/
+ KeEnterCriticalRegion();
Status = CcRosGetVacb(SharedCacheMap,
FileOffset,
&BaseOffset,
@@ -1118,6 +1119,7 @@
&Vacb);
if (!NT_SUCCESS(Status))
{
+ KeLeaveCriticalRegion();
return(Status);
}
if (!UptoDate)
@@ -1130,6 +1132,7 @@
if (!NT_SUCCESS(Status))
{
CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
+ KeLeaveCriticalRegion();
return Status;
}
}
@@ -1144,6 +1147,7 @@
FileOffset - BaseOffset).LowPart >>
PAGE_SHIFT;
CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, TRUE);
+ KeLeaveCriticalRegion();
}
else
{
@@ -1163,6 +1167,7 @@
{
return(Status);
}
+ KeEnterCriticalRegion();
Status = CcRosGetVacb(SharedCacheMap,
FileOffset,
&BaseOffset,
@@ -1171,6 +1176,7 @@
&Vacb);
if (!NT_SUCCESS(Status))
{
+ KeLeaveCriticalRegion();
return(Status);
}
if (!UptoDate)
@@ -1183,6 +1189,7 @@
if (!NT_SUCCESS(Status))
{
CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
+ KeLeaveCriticalRegion();
return Status;
}
}
@@ -1212,6 +1219,7 @@
&Vacb);
if (!NT_SUCCESS(Status))
{
+ KeLeaveCriticalRegion();
return(Status);
}
if (!UptoDate)
@@ -1224,6 +1232,7 @@
if (!NT_SUCCESS(Status))
{
CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE);
+ KeLeaveCriticalRegion();
return Status;
}
}
@@ -1239,6 +1248,7 @@
}
MiUnmapPageInHyperSpace(Process, PageAddr, Irql);
CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE);
+ KeLeaveCriticalRegion();
}
return(STATUS_SUCCESS);
}
@@ -3232,10 +3242,12 @@
BufferSize = PAGE_ROUND_UP(BufferSize);
/* Flush data since we're about to perform a non-cached read */
+ KeEnterCriticalRegion();
CcFlushCache(FileObject->SectionObjectPointer,
&FileOffset,
BufferSize,
&Iosb);
+ KeLeaveCriticalRegion();
/*
* It's ok to use paged pool, because this is a temporary buffer only used in