mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[NTOSKRNL] When allocating a new BCB, save it in a list
This list is stored in the shared map. Later, this will allow reusing BCB when appropriate
This commit is contained in:
parent
ea5912e4d1
commit
e17f61138c
3 changed files with 25 additions and 1 deletions
|
@ -51,6 +51,7 @@ CcMapData (
|
|||
NTSTATUS Status;
|
||||
PINTERNAL_BCB iBcb;
|
||||
LONGLONG ROffset;
|
||||
KIRQL OldIrql;
|
||||
|
||||
DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %lu, Flags 0x%lx,"
|
||||
" pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart,
|
||||
|
@ -156,6 +157,10 @@ CcMapData (
|
|||
ExInitializeResourceLite(&iBcb->Lock);
|
||||
*pBcb = (PVOID)iBcb;
|
||||
|
||||
KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
|
||||
InsertTailList(&SharedCacheMap->BcbList, &iBcb->BcbEntry);
|
||||
KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
|
||||
|
||||
CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> TRUE Bcb=%p\n",
|
||||
FileObject, FileOffset, Length, Flags, iBcb);
|
||||
return TRUE;
|
||||
|
@ -340,12 +345,20 @@ CcUnpinDataForThread (
|
|||
|
||||
if (--iBcb->RefCount == 0)
|
||||
{
|
||||
CcRosReleaseVacb(iBcb->Vacb->SharedCacheMap,
|
||||
KIRQL OldIrql;
|
||||
PROS_SHARED_CACHE_MAP SharedCacheMap;
|
||||
|
||||
SharedCacheMap = iBcb->Vacb->SharedCacheMap;
|
||||
CcRosReleaseVacb(SharedCacheMap,
|
||||
iBcb->Vacb,
|
||||
TRUE,
|
||||
iBcb->Dirty,
|
||||
FALSE);
|
||||
|
||||
KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
|
||||
RemoveEntryList(&iBcb->BcbEntry);
|
||||
KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
|
||||
|
||||
ExDeleteResourceLite(&iBcb->Lock);
|
||||
ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
|
||||
}
|
||||
|
@ -377,6 +390,8 @@ CcUnpinRepinnedBcb (
|
|||
IN PIO_STATUS_BLOCK IoStatus)
|
||||
{
|
||||
PINTERNAL_BCB iBcb = Bcb;
|
||||
KIRQL OldIrql;
|
||||
PROS_SHARED_CACHE_MAP SharedCacheMap;
|
||||
|
||||
CCTRACE(CC_API_DEBUG, "Bcb=%p WriteThrough=%d\n", Bcb, WriteThrough);
|
||||
|
||||
|
@ -408,12 +423,17 @@ CcUnpinRepinnedBcb (
|
|||
ASSERT(iBcb->Vacb->PinCount == 0);
|
||||
}
|
||||
|
||||
SharedCacheMap = iBcb->Vacb->SharedCacheMap;
|
||||
CcRosReleaseVacb(iBcb->Vacb->SharedCacheMap,
|
||||
iBcb->Vacb,
|
||||
TRUE,
|
||||
iBcb->Dirty,
|
||||
FALSE);
|
||||
|
||||
KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql);
|
||||
RemoveEntryList(&iBcb->BcbEntry);
|
||||
KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
|
||||
|
||||
ExDeleteResourceLite(&iBcb->Lock);
|
||||
ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
|
||||
}
|
||||
|
|
|
@ -1417,6 +1417,7 @@ CcRosInitializeFileCache (
|
|||
InitializeListHead(&SharedCacheMap->PrivateList);
|
||||
KeInitializeSpinLock(&SharedCacheMap->CacheMapLock);
|
||||
InitializeListHead(&SharedCacheMap->CacheMapVacbListHead);
|
||||
InitializeListHead(&SharedCacheMap->BcbList);
|
||||
}
|
||||
|
||||
KeAcquireGuardedMutex(&ViewLock);
|
||||
|
|
|
@ -172,6 +172,7 @@ typedef struct _ROS_SHARED_CACHE_MAP
|
|||
CSHORT NodeByteSize;
|
||||
ULONG OpenCount;
|
||||
LARGE_INTEGER FileSize;
|
||||
LIST_ENTRY BcbList;
|
||||
LARGE_INTEGER SectionSize;
|
||||
PFILE_OBJECT FileObject;
|
||||
ULONG DirtyPages;
|
||||
|
@ -181,6 +182,7 @@ typedef struct _ROS_SHARED_CACHE_MAP
|
|||
PVOID LazyWriteContext;
|
||||
LIST_ENTRY PrivateList;
|
||||
ULONG DirtyPageThreshold;
|
||||
KSPIN_LOCK BcbSpinLock;
|
||||
PRIVATE_CACHE_MAP PrivateCacheMap;
|
||||
|
||||
/* ROS specific */
|
||||
|
@ -235,6 +237,7 @@ typedef struct _INTERNAL_BCB
|
|||
BOOLEAN Dirty;
|
||||
BOOLEAN Pinned;
|
||||
CSHORT RefCount; /* (At offset 0x34 on WinNT4) */
|
||||
LIST_ENTRY BcbEntry;
|
||||
} INTERNAL_BCB, *PINTERNAL_BCB;
|
||||
|
||||
typedef struct _LAZY_WRITER
|
||||
|
|
Loading…
Reference in a new issue