Author: tfaber
Date: Mon Sep 30 20:06:18 2013
New Revision: 60484
URL:
http://svn.reactos.org/svn/reactos?rev=60484&view=rev
Log:
[NTOS:CC]
- Remove CacheSegmentSize
- Misc simplifications and style improvements
CORE-7491
Modified:
trunk/reactos/ntoskrnl/cc/copy.c
trunk/reactos/ntoskrnl/cc/fs.c
trunk/reactos/ntoskrnl/cc/pin.c
trunk/reactos/ntoskrnl/cc/view.c
trunk/reactos/ntoskrnl/include/internal/cc.h
trunk/reactos/ntoskrnl/include/internal/tag.h
Modified: trunk/reactos/ntoskrnl/cc/copy.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/copy.c?rev=604…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/copy.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/copy.c [iso-8859-1] Mon Sep 30 20:06:18 2013
@@ -19,6 +19,7 @@
#define MAX_ZERO_LENGTH (256 * 1024)
#define MAX_RW_LENGTH (256 * 1024)
+C_ASSERT(MAX_RW_LENGTH <= VACB_MAPPING_GRANULARITY);
ULONG CcFastMdlReadWait;
ULONG CcFastMdlReadNotPossible;
@@ -88,7 +89,7 @@
if (current->Valid)
{
TempLength = min(VACB_MAPPING_GRANULARITY, Length);
- memcpy(Buffer, current->BaseAddress, TempLength);
+ RtlCopyMemory(Buffer, current->BaseAddress, TempLength);
Buffer = (PVOID)((ULONG_PTR)Buffer + TempLength);
@@ -130,7 +131,7 @@
while ((current2 != NULL) && !current2->Valid &&
(current_size < MAX_RW_LENGTH))
{
PVOID address = current2->BaseAddress;
- for (i = 0; i < (VACB_MAPPING_GRANULARITY / PAGE_SIZE); i++, address =
RVA(address, PAGE_SIZE))
+ for (i = 0; i < VACB_MAPPING_GRANULARITY / PAGE_SIZE; i++, address =
RVA(address, PAGE_SIZE))
{
*MdlPages++ = MmGetPfnForProcess(NULL, address);
}
@@ -173,7 +174,7 @@
previous = current;
current = current->NextInChain;
TempLength = min(VACB_MAPPING_GRANULARITY, Length);
- memcpy(Buffer, previous->BaseAddress, TempLength);
+ RtlCopyMemory(Buffer, previous->BaseAddress, TempLength);
Buffer = (PVOID)((ULONG_PTR)Buffer + TempLength);
@@ -229,7 +230,7 @@
return Status;
}
- if (VACB_MAPPING_GRANULARITY > Size)
+ if (Size < VACB_MAPPING_GRANULARITY)
{
RtlZeroMemory((char*)CacheSeg->BaseAddress + Size,
VACB_MAPPING_GRANULARITY - Size);
@@ -381,10 +382,10 @@
TempLength = ReadOffset % VACB_MAPPING_GRANULARITY;
if (TempLength != 0)
{
- TempLength = min (Length, VACB_MAPPING_GRANULARITY - TempLength);
+ TempLength = min(Length, VACB_MAPPING_GRANULARITY - TempLength);
Status = CcRosRequestCacheSegment(Bcb,
ROUND_DOWN(ReadOffset,
- VACB_MAPPING_GRANULARITY),
+ VACB_MAPPING_GRANULARITY),
&BaseAddress, &Valid, &CacheSeg);
if (!NT_SUCCESS(Status))
{
@@ -404,8 +405,9 @@
return FALSE;
}
}
- memcpy (Buffer, (char*)BaseAddress + ReadOffset % VACB_MAPPING_GRANULARITY,
- TempLength);
+ RtlCopyMemory(Buffer,
+ (char*)BaseAddress + ReadOffset % VACB_MAPPING_GRANULARITY,
+ TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
ReadLength += TempLength;
Length -= TempLength;
@@ -415,7 +417,7 @@
while (Length > 0)
{
- TempLength = min(max(VACB_MAPPING_GRANULARITY, MAX_RW_LENGTH), Length);
+ TempLength = min(VACB_MAPPING_GRANULARITY, Length);
Status = ReadCacheSegmentChain(Bcb, ReadOffset, TempLength, Buffer);
if (!NT_SUCCESS(Status))
{
@@ -498,7 +500,7 @@
{
ULONG ROffset;
ROffset = ROUND_DOWN(WriteOffset, VACB_MAPPING_GRANULARITY);
- TempLength = min (Length, VACB_MAPPING_GRANULARITY - TempLength);
+ TempLength = min(Length, VACB_MAPPING_GRANULARITY - TempLength);
Status = CcRosRequestCacheSegment(Bcb, ROffset,
&BaseAddress, &Valid, &CacheSeg);
if (!NT_SUCCESS(Status))
@@ -512,8 +514,9 @@
return FALSE;
}
}
- memcpy ((char*)BaseAddress + WriteOffset % VACB_MAPPING_GRANULARITY,
- Buffer, TempLength);
+ RtlCopyMemory((char*)BaseAddress + WriteOffset % VACB_MAPPING_GRANULARITY,
+ Buffer,
+ TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
Length -= TempLength;
@@ -524,7 +527,7 @@
while (Length > 0)
{
- TempLength = min (VACB_MAPPING_GRANULARITY, Length);
+ TempLength = min(VACB_MAPPING_GRANULARITY, Length);
Status = CcRosRequestCacheSegment(Bcb,
WriteOffset,
&BaseAddress,
@@ -542,7 +545,7 @@
return FALSE;
}
}
- memcpy (BaseAddress, Buffer, TempLength);
+ RtlCopyMemory(BaseAddress, Buffer, TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
Length -= TempLength;
WriteOffset += TempLength;
@@ -749,13 +752,14 @@
Status);
}
}
- TempLength = min (CurrentLength, VACB_MAPPING_GRANULARITY - Offset);
+ TempLength = min(CurrentLength, VACB_MAPPING_GRANULARITY - Offset);
}
else
{
TempLength = VACB_MAPPING_GRANULARITY;
}
- memset ((PUCHAR)current->BaseAddress + Offset, 0, TempLength);
+ RtlZeroMemory((PUCHAR)current->BaseAddress + Offset,
+ TempLength);
WriteOffset.QuadPart += TempLength;
CurrentLength -= TempLength;
Modified: trunk/reactos/ntoskrnl/cc/fs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/fs.c?rev=60484…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/fs.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/fs.c [iso-8859-1] Mon Sep 30 20:06:18 2013
@@ -87,7 +87,7 @@
/* Call old ROS cache init function */
CcRosInitializeFileCache(FileObject,
- /*PAGE_SIZE*/ VACB_MAPPING_GRANULARITY, CallBacks,
+ CallBacks,
LazyWriterContext);
}
Modified: trunk/reactos/ntoskrnl/cc/pin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=6048…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Mon Sep 30 20:06:18 2013
@@ -88,7 +88,7 @@
}
}
- *pBuffer = (PVOID)((ULONG_PTR)(*pBuffer) + (ReadOffset % VACB_MAPPING_GRANULARITY));
+ *pBuffer = (PVOID)((ULONG_PTR)(*pBuffer) + ReadOffset % VACB_MAPPING_GRANULARITY);
iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList);
if (iBcb == NULL)
{
@@ -96,7 +96,7 @@
return FALSE;
}
- memset(iBcb, 0, sizeof(INTERNAL_BCB));
+ RtlZeroMemory(iBcb, sizeof(*iBcb));
iBcb->PFCB.NodeTypeCode = 0xDE45; /* Undocumented
(CAPTIVE_PUBLIC_BCB_NODETYPECODE) */
iBcb->PFCB.NodeByteSize = sizeof(PUBLIC_BCB);
iBcb->PFCB.MappedLength = Length;
Modified: trunk/reactos/ntoskrnl/cc/view.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=604…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Mon Sep 30 20:06:18 2013
@@ -53,7 +53,7 @@
static LIST_ENTRY CacheSegmentListHead;
static LIST_ENTRY CacheSegmentLRUListHead;
static LIST_ENTRY ClosedListHead;
-ULONG DirtyPageCount=0;
+ULONG DirtyPageCount = 0;
KGUARDED_MUTEX ViewLock;
@@ -171,7 +171,7 @@
KeReleaseGuardedMutex(&ViewLock);
}
- return(Status);
+ return Status;
}
NTSTATUS
@@ -273,7 +273,7 @@
KeLeaveCriticalRegion();
DPRINT("CcRosFlushDirtyPages() finished\n");
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -396,7 +396,7 @@
DPRINT("Evicted %lu cache pages\n", (*NrFreed));
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -448,7 +448,7 @@
KeReleaseGuardedMutex(&ViewLock);
KeReleaseMutex(&CacheSeg->Mutex, FALSE);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
/* Returns with Cache Segment Lock Held! */
@@ -540,7 +540,7 @@
KeReleaseGuardedMutex(&ViewLock);
KeReleaseMutex(&CacheSeg->Mutex, FALSE);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -562,7 +562,7 @@
CacheSeg = CcRosLookupCacheSegment(Bcb, FileOffset);
if (CacheSeg == NULL)
{
- return(STATUS_UNSUCCESSFUL);
+ return STATUS_UNSUCCESSFUL;
}
KeAcquireGuardedMutex(&ViewLock);
@@ -593,7 +593,7 @@
KeReleaseGuardedMutex(&ViewLock);
KeReleaseMutex(&CacheSeg->Mutex, FALSE);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
static
@@ -713,7 +713,9 @@
#ifdef CACHE_BITMAP
KeAcquireSpinLock(&CiCacheSegMappingRegionLock, &oldIrql);
- StartingOffset = RtlFindClearBitsAndSet(&CiCacheSegMappingRegionAllocMap,
VACB_MAPPING_GRANULARITY / PAGE_SIZE, CiCacheSegMappingRegionHint);
+ StartingOffset = RtlFindClearBitsAndSet(&CiCacheSegMappingRegionAllocMap,
+ VACB_MAPPING_GRANULARITY / PAGE_SIZE,
+ CiCacheSegMappingRegionHint);
if (StartingOffset == 0xffffffff)
{
@@ -764,7 +766,7 @@
MmMapMemoryArea(current->BaseAddress, VACB_MAPPING_GRANULARITY,
MC_CACHE, PAGE_READWRITE);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -815,7 +817,7 @@
}
}
- for (i = 0; i < (Length / VACB_MAPPING_GRANULARITY); i++)
+ for (i = 0; i < Length / VACB_MAPPING_GRANULARITY; i++)
{
if (i == 0)
{
@@ -831,7 +833,7 @@
ASSERT(Previous);
Previous->NextInChain = NULL;
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -883,7 +885,7 @@
DPRINT("*BaseAddress %p\n", *BaseAddress);
*CacheSeg = current;
*BaseOffset = current->FileOffset;
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -902,19 +904,19 @@
ASSERT(Bcb);
- if ((FileOffset % VACB_MAPPING_GRANULARITY) != 0)
+ if (FileOffset % VACB_MAPPING_GRANULARITY != 0)
{
DPRINT1("Bad fileoffset %x should be multiple of %x",
FileOffset, VACB_MAPPING_GRANULARITY);
KeBugCheck(CACHE_MANAGER);
}
- return(CcRosGetCacheSegment(Bcb,
+ return CcRosGetCacheSegment(Bcb,
FileOffset,
&BaseOffset,
BaseAddress,
UptoDate,
- CacheSeg));
+ CacheSeg);
}
#ifdef CACHE_BITMAP
#else
@@ -977,7 +979,7 @@
RtlClearBits(&CiCacheSegMappingRegionAllocMap, Base, RegionSize);
- CiCacheSegMappingRegionHint = min (CiCacheSegMappingRegionHint, Base);
+ CiCacheSegMappingRegionHint = min(CiCacheSegMappingRegionHint, Base);
KeReleaseSpinLock(&CiCacheSegMappingRegionLock, oldIrql);
#else
@@ -989,7 +991,7 @@
MmUnlockAddressSpace(MmGetKernelAddressSpace());
#endif
ExFreeToNPagedLookasideList(&CacheSegLookasideList, CacheSeg);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
/*
@@ -1143,7 +1145,7 @@
ExFreeToNPagedLookasideList(&BcbLookasideList, Bcb);
KeAcquireGuardedMutex(&ViewLock);
}
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
VOID
@@ -1243,7 +1245,7 @@
}
}
KeReleaseGuardedMutex(&ViewLock);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
NTSTATUS
@@ -1286,7 +1288,6 @@
NTAPI
CcRosInitializeFileCache (
PFILE_OBJECT FileObject,
- ULONG CacheSegmentSize,
PCACHE_MANAGER_CALLBACKS CallBacks,
PVOID LazyWriterContext)
/*
@@ -1296,8 +1297,8 @@
PBCB Bcb;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
- DPRINT("CcRosInitializeFileCache(FileObject 0x%p, Bcb 0x%p, CacheSegmentSize
%lu)\n",
- FileObject, Bcb, CacheSegmentSize);
+ DPRINT("CcRosInitializeFileCache(FileObject 0x%p, Bcb 0x%p)\n",
+ FileObject, Bcb);
KeAcquireGuardedMutex(&ViewLock);
if (Bcb == NULL)
@@ -1306,15 +1307,14 @@
if (Bcb == NULL)
{
KeReleaseGuardedMutex(&ViewLock);
- return(STATUS_UNSUCCESSFUL);
- }
- memset(Bcb, 0, sizeof(BCB));
+ return STATUS_UNSUCCESSFUL;
+ }
+ RtlZeroMemory(Bcb, sizeof(*Bcb));
ObReferenceObjectByPointer(FileObject,
FILE_ALL_ACCESS,
NULL,
KernelMode);
Bcb->FileObject = FileObject;
- Bcb->CacheSegmentSize = CacheSegmentSize;
Bcb->Callbacks = CallBacks;
Bcb->LazyWriteContext = LazyWriterContext;
if (FileObject->FsContext)
@@ -1340,7 +1340,7 @@
}
KeReleaseGuardedMutex(&ViewLock);
- return(STATUS_SUCCESS);
+ return STATUS_SUCCESS;
}
/*
@@ -1396,13 +1396,17 @@
KeBugCheck(CACHE_MANAGER);
}
- Buffer = ExAllocatePool(NonPagedPool, CI_CACHESEG_MAPPING_REGION_SIZE / (PAGE_SIZE *
8));
+ Buffer = ExAllocatePoolWithTag(NonPagedPool,
+ CI_CACHESEG_MAPPING_REGION_SIZE / (PAGE_SIZE * 8),
+ TAG_CC);
if (!Buffer)
{
KeBugCheck(CACHE_MANAGER);
}
- RtlInitializeBitMap(&CiCacheSegMappingRegionAllocMap, Buffer,
CI_CACHESEG_MAPPING_REGION_SIZE / PAGE_SIZE);
+ RtlInitializeBitMap(&CiCacheSegMappingRegionAllocMap,
+ Buffer,
+ CI_CACHESEG_MAPPING_REGION_SIZE / PAGE_SIZE);
RtlClearAllBits(&CiCacheSegMappingRegionAllocMap);
KeInitializeSpinLock(&CiCacheSegMappingRegionLock);
@@ -1441,11 +1445,3 @@
}
/* EOF */
-
-
-
-
-
-
-
-
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 Sep 30 20:06:18 2013
@@ -108,7 +108,6 @@
BOOLEAN RemoveOnClose;
ULONG TimeStamp;
PFILE_OBJECT FileObject;
- ULONG CacheSegmentSize;
LARGE_INTEGER AllocationSize;
LARGE_INTEGER FileSize;
PCACHE_MANAGER_CALLBACKS Callbacks;
@@ -294,7 +293,6 @@
NTAPI
CcRosInitializeFileCache(
PFILE_OBJECT FileObject,
- ULONG CacheSegmentSize,
PCACHE_MANAGER_CALLBACKS CallBacks,
PVOID LazyWriterContext
);
Modified: trunk/reactos/ntoskrnl/include/internal/tag.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/tag.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/tag.h [iso-8859-1] Mon Sep 30 20:06:18 2013
@@ -1,6 +1,7 @@
#pragma once
/* formerly located in cc/view.c */
+#define TAG_CC ' cC'
#define TAG_CSEG 'GESC'
#define TAG_BCB ' BCB'
#define TAG_IBCB 'BCBi'