[NTOSKRNL] Avoid private cache map allocation for the first handle

Standard shared cache map provides space for a private cache map, do the same
and make it available for the first handle. It avoids two allocations in a row.
This commit is contained in:
Pierre Schweitzer 2018-02-09 21:52:41 +01:00
parent 5d93941d31
commit a6e080bd3d
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B
2 changed files with 18 additions and 2 deletions

View file

@ -1194,7 +1194,14 @@ CcRosReleaseFileCache (
KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql);
/* And free it. */
ExFreePoolWithTag(PrivateMap, TAG_PRIVATE_CACHE_MAP);
if (PrivateMap != &SharedCacheMap->PrivateCacheMap)
{
ExFreePoolWithTag(PrivateMap, TAG_PRIVATE_CACHE_MAP);
}
else
{
PrivateMap->NodeTypeCode = 0;
}
if (SharedCacheMap->OpenCount > 0)
{
@ -1271,7 +1278,15 @@ CcRosInitializeFileCache (
PPRIVATE_CACHE_MAP PrivateMap;
/* Allocate the private cache map for this handle */
PrivateMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(PRIVATE_CACHE_MAP), TAG_PRIVATE_CACHE_MAP);
if (SharedCacheMap->PrivateCacheMap.NodeTypeCode != 0)
{
PrivateMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(PRIVATE_CACHE_MAP), TAG_PRIVATE_CACHE_MAP);
}
else
{
PrivateMap = &SharedCacheMap->PrivateCacheMap;
}
if (PrivateMap == NULL)
{
/* If we also allocated the shared cache map for this file, kill it */

View file

@ -169,6 +169,7 @@ typedef struct _ROS_SHARED_CACHE_MAP
PVOID LazyWriteContext;
LIST_ENTRY PrivateList;
ULONG DirtyPageThreshold;
PRIVATE_CACHE_MAP PrivateCacheMap;
/* ROS specific */
LIST_ENTRY CacheMapVacbListHead;