Author: mbosma
Date: Mon Mar 27 22:17:12 2006
New Revision: 21400
URL:
http://svn.reactos.ru/svn/reactos?rev=21400&view=rev
Log:
Unify coding style using GNU Indent
Modified:
branches/cache_manager_rewrite/reactos/ntoskrnl/cc/cacheman.c
branches/cache_manager_rewrite/reactos/ntoskrnl/cc/copy.c
branches/cache_manager_rewrite/reactos/ntoskrnl/cc/fs.c
branches/cache_manager_rewrite/reactos/ntoskrnl/cc/mdl.c
branches/cache_manager_rewrite/reactos/ntoskrnl/cc/pin.c
branches/cache_manager_rewrite/reactos/ntoskrnl/cc/view.c
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/cc/cacheman.c
URL:
http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nt…
==============================================================================
--- branches/cache_manager_rewrite/reactos/ntoskrnl/cc/cacheman.c (original)
+++ branches/cache_manager_rewrite/reactos/ntoskrnl/cc/cacheman.c Mon Mar 27 22:17:12
2006
@@ -16,41 +16,34 @@
/* FUNCTIONS *****************************************************************/
-VOID
-NTAPI
-CcInit(VOID)
+VOID NTAPI
+CcInit (VOID)
{
- CcInitView();
+ CcInitView ();
}
/*
* @unimplemented
*/
-LARGE_INTEGER
-STDCALL
-CcGetFlushedValidData (
- IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
- IN BOOLEAN BcbListHeld
- )
+LARGE_INTEGER STDCALL
+CcGetFlushedValidData (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
+ IN BOOLEAN BcbListHeld)
{
- LARGE_INTEGER i;
+ LARGE_INTEGER i;
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
- i.QuadPart = 0;
- return i;
+ i.QuadPart = 0;
+ return i;
}
/*
* @unimplemented
*/
-PVOID
-STDCALL
-CcRemapBcb (
- IN PVOID Bcb
- )
+PVOID STDCALL
+CcRemapBcb (IN PVOID Bcb)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
return 0;
}
@@ -58,66 +51,51 @@
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcScheduleReadAhead (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length
- )
+VOID STDCALL
+CcScheduleReadAhead (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcSetAdditionalCacheAttributes (
- IN PFILE_OBJECT FileObject,
- IN BOOLEAN DisableReadAhead,
- IN BOOLEAN DisableWriteBehind
- )
+VOID STDCALL
+CcSetAdditionalCacheAttributes (IN PFILE_OBJECT FileObject,
+ IN BOOLEAN DisableReadAhead,
+ IN BOOLEAN DisableWriteBehind)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcSetBcbOwnerPointer (
- IN PVOID Bcb,
- IN PVOID Owner
- )
+VOID STDCALL
+CcSetBcbOwnerPointer (IN PVOID Bcb,
+ IN PVOID Owner)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcSetDirtyPageThreshold (
- IN PFILE_OBJECT FileObject,
- IN ULONG DirtyPageThreshold
- )
+VOID STDCALL
+CcSetDirtyPageThreshold (IN PFILE_OBJECT FileObject,
+ IN ULONG DirtyPageThreshold)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcSetReadAheadGranularity (
- IN PFILE_OBJECT FileObject,
- IN ULONG Granularity
- )
+VOID STDCALL
+CcSetReadAheadGranularity (IN PFILE_OBJECT FileObject,
+ IN ULONG Granularity)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/cc/copy.c
URL:
http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nt…
==============================================================================
--- branches/cache_manager_rewrite/reactos/ntoskrnl/cc/copy.c (original)
+++ branches/cache_manager_rewrite/reactos/ntoskrnl/cc/copy.c Mon Mar 27 22:17:12 2006
@@ -18,13 +18,13 @@
static PFN_TYPE CcZeroPage = 0;
-#define MAX_ZERO_LENGTH (256 * 1024)
-#define MAX_RW_LENGTH (256 * 1024)
+#define MAX_ZERO_LENGTH (256 * 1024)
+#define MAX_RW_LENGTH (256 * 1024)
#if defined(__GNUC__)
/* void * alloca(size_t size); */
#elif defined(_MSC_VER)
-void* _alloca(size_t size);
+void *_alloca (size_t size);
#else
#error Unknown compiler for alloca intrinsic stack allocation "function"
#endif
@@ -41,600 +41,582 @@
/* FUNCTIONS *****************************************************************/
-NTSTATUS STDCALL
-MmMapViewInSystemCache(PCACHE_VIEW);
-
-
-VOID
-NTAPI
-CcInitCacheZeroPage(VOID)
-{
- NTSTATUS Status;
-
- Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &CcZeroPage);
- if (!NT_SUCCESS(Status))
- {
- DbgPrint("Can't allocate CcZeroPage.\n");
- KEBUGCHECKCC;
- }
- Status = MiZeroPage(CcZeroPage);
- if (!NT_SUCCESS(Status))
- {
- DbgPrint("Can't zero out CcZeroPage.\n");
- KEBUGCHECKCC;
- }
+NTSTATUS STDCALL MmMapViewInSystemCache (PCACHE_VIEW);
+
+
+VOID NTAPI
+CcInitCacheZeroPage (VOID)
+{
+ NTSTATUS Status;
+
+ Status = MmRequestPageMemoryConsumer (MC_NPPOOL, TRUE, &CcZeroPage);
+ if (!NT_SUCCESS (Status))
+ {
+ DbgPrint ("Can't allocate CcZeroPage.\n");
+ KEBUGCHECKCC;
+ }
+ Status = MiZeroPage (CcZeroPage);
+ if (!NT_SUCCESS (Status))
+ {
+ DbgPrint ("Can't zero out CcZeroPage.\n");
+ KEBUGCHECKCC;
+ }
}
/*
* @unimplemented
*/
BOOLEAN STDCALL
-CcCanIWrite (
- IN PFILE_OBJECT FileObject,
- IN ULONG BytesToWrite,
- IN BOOLEAN Wait,
- IN BOOLEAN Retrying)
-{
- UNIMPLEMENTED;
- return FALSE;
+CcCanIWrite (IN PFILE_OBJECT FileObject,
+ IN ULONG BytesToWrite,
+ IN BOOLEAN Wait,
+ IN BOOLEAN Retrying)
+{
+ UNIMPLEMENTED;
+ return FALSE;
}
BOOLEAN STDCALL
CcCopyRead (IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN BOOLEAN Wait,
- OUT PVOID Buffer,
- OUT PIO_STATUS_BLOCK IoStatus)
-{
-
- ULONG Index;
- PBCB Bcb;
- LARGE_INTEGER Offset;
- PLIST_ENTRY entry;
- PCACHE_VIEW current = NULL;
- ULONG CurrentLength;
- NTSTATUS Status;
-
- DPRINT("CcCopyRead(FileObject 0x%p, FileOffset %I64x, "
- "Length %d, Wait %d, Buffer 0x%p, IoStatus 0x%p)\n",
- FileObject, FileOffset->QuadPart, Length, Wait,
- Buffer, IoStatus);
-
-
- if (!Wait)
- {
- IoStatus->Information = 0;
- IoStatus->Status = STATUS_UNSUCCESSFUL;
- CHECKPOINT;
- return FALSE;
- }
-
- IoStatus->Information = Length;
- IoStatus->Status = STATUS_SUCCESS;
-
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-
- if (FileOffset->QuadPart + Length > Bcb->FileSizes.FileSize.QuadPart)
- {
- KEBUGCHECK(0);
- }
-
- if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof(Bcb->CacheView) /
sizeof(Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
- Offset = *FileOffset;
-
- ExAcquireFastMutex(&CcCacheViewLock);
- while (Length)
- {
- Index = Offset.QuadPart / CACHE_VIEW_SIZE;
- if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
- {
- CHECKPOINT;
- if (Bcb->CacheView[Index]->RefCount == 0)
- {
- RemoveEntryList(&Bcb->CacheView[Index]->ListEntry);
- InsertHeadList(&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
- }
- Bcb->CacheView[Index]->RefCount++;
- }
- else
- {
- CHECKPOINT;
- if (IsListEmpty(&CcFreeCacheViewListHead))
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
- entry = CcFreeCacheViewListHead.Flink;
- while (entry != &CcFreeCacheViewListHead)
- {
- current = CONTAINING_RECORD(entry, CACHE_VIEW, ListEntry);
- entry = entry->Flink;
- if (current->Bcb == NULL)
- {
- break;
- }
- }
- if (entry == &CcFreeCacheViewListHead)
- {
- KEBUGCHECK(0);
- }
-
- if (current->Bcb)
- {
- current->Bcb->CacheView[current->SectionData.ViewOffset / CACHE_VIEW_SIZE]
= NULL;
- }
- Bcb->CacheView[Index] = current;
-
-
- if(Bcb->CacheView[Index]->Bcb != NULL)
- {
- DPRINT1("%x\n", Bcb->CacheView[Index]->Bcb);
- /* not implemented */
- KEBUGCHECK(0);
- }
- Bcb->CacheView[Index]->RefCount = 1;
- Bcb->CacheView[Index]->Bcb = Bcb;
- Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
- Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
- Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
-
- Status = MmMapViewInSystemCache(Bcb->CacheView[Index]);
-
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- }
- ExReleaseFastMutex(&CcCacheViewLock);
-
- if (Offset.QuadPart % CACHE_VIEW_SIZE)
- {
- if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
- {
- CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
- }
- else
- {
- CurrentLength = Length;
- }
- memcpy(Buffer,
- (PVOID)((ULONG_PTR)Bcb->CacheView[Index]->BaseAddress +
Offset.u.LowPart % CACHE_VIEW_SIZE),
- CurrentLength);
- Buffer = (PVOID)((ULONG_PTR)Buffer + CurrentLength);
- Length -= CurrentLength;
- Offset.QuadPart += CurrentLength;
- }
- else
- {
- CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
- memcpy(Buffer, Bcb->CacheView[Index]->BaseAddress, CurrentLength);
- Buffer = (PVOID)((ULONG_PTR)Buffer + CurrentLength);
- Length -= CurrentLength;
- Offset.QuadPart += CurrentLength;
- }
- ExAcquireFastMutex(&CcCacheViewLock);
-
- Bcb->CacheView[Index]->RefCount--;
- if (Bcb->CacheView[Index]->RefCount == 0)
- {
- RemoveEntryList(&Bcb->CacheView[Index]->ListEntry);
- InsertHeadList(&CcFreeCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
- }
- }
- ExReleaseFastMutex(&CcCacheViewLock);
-
- CHECKPOINT;
-
- return TRUE;
-}
-
-/*
- * @implemented
- */
-BOOLEAN STDCALL
-CcCopyWrite(IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN BOOLEAN Wait,
- IN PVOID Buffer)
-{
-
- ULONG Index;
- PBCB Bcb;
- LARGE_INTEGER Offset;
- PLIST_ENTRY entry;
- PCACHE_VIEW current = NULL;
- ULONG CurrentLength;
- NTSTATUS Status;
-
- DPRINT("CcCopyWrite(FileObject 0x%p, FileOffset %I64x, "
- "Length %d, Wait %d, Buffer 0x%p)\n",
- FileObject, FileOffset->QuadPart, Length, Wait, Buffer);
-
- if (!Wait)
- {
- CHECKPOINT;
- return FALSE;
- }
-
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-
- if (FileOffset->QuadPart + Length > Bcb->FileSizes.FileSize.QuadPart)
- {
- KEBUGCHECK(0);
- }
-
- if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof(Bcb->CacheView) /
sizeof(Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
- Offset = *FileOffset;
-
- ExAcquireFastMutex(&CcCacheViewLock);
- while (Length)
- {
- Index = Offset.QuadPart / CACHE_VIEW_SIZE;
- if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
- {
- CHECKPOINT;
- if (Bcb->CacheView[Index]->RefCount == 0)
- {
- RemoveEntryList(&Bcb->CacheView[Index]->ListEntry);
- InsertHeadList(&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
- }
- Bcb->CacheView[Index]->RefCount++;
- }
- else
- {
- CHECKPOINT;
- if (IsListEmpty(&CcFreeCacheViewListHead))
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
- entry = CcFreeCacheViewListHead.Flink;
- while (entry != &CcFreeCacheViewListHead)
- {
- current = CONTAINING_RECORD(entry, CACHE_VIEW, ListEntry);
- entry = entry->Flink;
- if (current->Bcb == NULL)
- {
- break;
- }
- }
- if (entry == &CcFreeCacheViewListHead)
- {
- KEBUGCHECK(0);
- }
-
- if (current->Bcb)
- {
- current->Bcb->CacheView[current->SectionData.ViewOffset / CACHE_VIEW_SIZE]
= NULL;
- }
-
- Bcb->CacheView[Index] = current;
-
- if(Bcb->CacheView[Index]->Bcb != NULL)
- {
- DPRINT1("%x\n", Bcb->CacheView[Index]->Bcb);
- /* not implemented */
- KEBUGCHECK(0);
- }
- Bcb->CacheView[Index]->RefCount = 1;
- Bcb->CacheView[Index]->Bcb = Bcb;
- Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
- Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
- Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
-
- Status = MmMapViewInSystemCache(Bcb->CacheView[Index]);
-
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- }
- ExReleaseFastMutex(&CcCacheViewLock);
-
- if (Offset.QuadPart % CACHE_VIEW_SIZE)
- {
- if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
- {
- CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
- }
- else
- {
- CurrentLength = Length;
- }
- memcpy((PVOID)((ULONG_PTR)Bcb->CacheView[Index]->BaseAddress +
Offset.u.LowPart % CACHE_VIEW_SIZE),
- Buffer, CurrentLength);
- Buffer = (PVOID)((ULONG_PTR)Buffer + CurrentLength);
- Length -= CurrentLength;
- Offset.QuadPart += CurrentLength;
- }
- else
- {
- CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
- memcpy(Bcb->CacheView[Index]->BaseAddress, Buffer, CurrentLength);
- Buffer = (PVOID)((ULONG_PTR)Buffer + CurrentLength);
- Length -= CurrentLength;
- Offset.QuadPart += CurrentLength;
- }
- ExAcquireFastMutex(&CcCacheViewLock);
-
- Bcb->CacheView[Index]->RefCount--;
- if (Bcb->CacheView[Index]->RefCount == 0)
- {
- RemoveEntryList(&Bcb->CacheView[Index]->ListEntry);
- InsertHeadList(&CcFreeCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
- }
- }
- ExReleaseFastMutex(&CcCacheViewLock);
-
- CHECKPOINT;
-
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-VOID
-STDCALL
-CcDeferWrite (
- IN PFILE_OBJECT FileObject,
- IN PCC_POST_DEFERRED_WRITE PostRoutine,
- IN PVOID Context1,
- IN PVOID Context2,
- IN ULONG BytesToWrite,
- IN BOOLEAN Retrying
- )
-{
- UNIMPLEMENTED;
-}
-
-/*
- * @unimplemented
- */
-VOID
-STDCALL
-CcFastCopyRead (
- IN PFILE_OBJECT FileObject,
- IN ULONG FileOffset,
- IN ULONG Length,
- IN ULONG PageCount,
- OUT PVOID Buffer,
- OUT PIO_STATUS_BLOCK IoStatus
- )
-{
- UNIMPLEMENTED;
-}
-/*
- * @unimplemented
- */
-VOID
-STDCALL
-CcFastCopyWrite(
- IN PFILE_OBJECT FileObject,
- IN ULONG FileOffset,
- IN ULONG Length,
- IN PVOID Buffer)
-{
- UNIMPLEMENTED;
-}
-
-/*
- * @unimplemented
- */
-NTSTATUS
-STDCALL
-CcWaitForCurrentLazyWriterActivity (
- VOID
- )
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
-/*
- * @implemented
- */
-BOOLEAN STDCALL
-CcZeroData (IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER StartOffset,
- IN PLARGE_INTEGER EndOffset,
- IN BOOLEAN Wait)
-{
- NTSTATUS Status;
- LARGE_INTEGER WriteOffset;
- ULONG Length;
- ULONG CurrentLength;
- PMDL Mdl;
- ULONG i;
- IO_STATUS_BLOCK Iosb;
- KEVENT Event;
- LARGE_INTEGER Offset;
- ULONG Index;
-
- DPRINT("CcZeroData(FileObject 0x%p, StartOffset %I64x, EndOffset %I64x, "
- "Wait %d)\n", FileObject, StartOffset->QuadPart, EndOffset->QuadPart,
- Wait);
-
- Length = EndOffset->u.LowPart - StartOffset->u.LowPart;
- WriteOffset.QuadPart = StartOffset->QuadPart;
-
- if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
- {
- /* File is not cached */
-
- Mdl = alloca(MmSizeOfMdl(NULL, MAX_ZERO_LENGTH));
-
- while (Length > 0)
- {
- if (Length + WriteOffset.u.LowPart % PAGE_SIZE > MAX_ZERO_LENGTH)
- {
- CurrentLength = MAX_ZERO_LENGTH - WriteOffset.u.LowPart % PAGE_SIZE;
- }
- else
- {
- CurrentLength = Length;
- }
- MmInitializeMdl(Mdl, (PVOID)WriteOffset.u.LowPart, CurrentLength);
- Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
- for (i = 0; i < ((Mdl->Size - sizeof(MDL)) / sizeof(ULONG)); i++)
- {
- ((PPFN_TYPE)(Mdl + 1))[i] = CcZeroPage;
- }
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- Status = IoSynchronousPageWrite(FileObject, Mdl, &WriteOffset, &Event,
&Iosb);
- if (Status == STATUS_PENDING)
- {
- KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
- Status = Iosb.Status;
- }
- MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
- if (!NT_SUCCESS(Status))
- {
- return(FALSE);
- }
- WriteOffset.QuadPart += CurrentLength;
- Length -= CurrentLength;
- }
- }
- else
- {
- /* File is cached */
- PBCB Bcb;
- PCACHE_VIEW current = NULL;
- PLIST_ENTRY entry;
-
-
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-
- if (!Wait)
- {
- CHECKPOINT;
- return FALSE;
- }
-
- if (EndOffset->QuadPart > Bcb->FileSizes.FileSize.QuadPart)
- {
- KEBUGCHECK(0);
- }
-
- if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof(Bcb->CacheView) /
sizeof(Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
- Offset = *StartOffset;
- Length = EndOffset->QuadPart - StartOffset->QuadPart;
-
- ExAcquireFastMutex(&CcCacheViewLock);
- while (Length)
- {
- Index = Offset.QuadPart / CACHE_VIEW_SIZE;
- if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb ==
Bcb)
- {
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN BOOLEAN Wait,
+ OUT PVOID Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus)
+{
+
+ ULONG Index;
+ PBCB Bcb;
+ LARGE_INTEGER Offset;
+ PLIST_ENTRY entry;
+ PCACHE_VIEW current = NULL;
+ ULONG CurrentLength;
+ NTSTATUS Status;
+
+ DPRINT ("CcCopyRead(FileObject 0x%p, FileOffset %I64x, "
+ "Length %d, Wait %d, Buffer 0x%p, IoStatus 0x%p)\n",
+ FileObject, FileOffset->QuadPart, Length, Wait, Buffer, IoStatus);
+
+
+ if (!Wait)
+ {
+ IoStatus->Information = 0;
+ IoStatus->Status = STATUS_UNSUCCESSFUL;
+ CHECKPOINT;
+ return FALSE;
+ }
+
+ IoStatus->Information = Length;
+ IoStatus->Status = STATUS_SUCCESS;
+
+ Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+
+ if (FileOffset->QuadPart + Length > Bcb->FileSizes.FileSize.QuadPart)
+ {
+ KEBUGCHECK (0);
+ }
+
+ if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) /
sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+ Offset = *FileOffset;
+
+ ExAcquireFastMutex (&CcCacheViewLock);
+ while (Length)
+ {
+ Index = Offset.QuadPart / CACHE_VIEW_SIZE;
+ if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
+ {
CHECKPOINT;
if (Bcb->CacheView[Index]->RefCount == 0)
{
- RemoveEntryList(&Bcb->CacheView[Index]->ListEntry);
- InsertHeadList(&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
+ RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
+ InsertHeadList (&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
}
Bcb->CacheView[Index]->RefCount++;
- }
- else
- {
+ }
+ else
+ {
CHECKPOINT;
- if (IsListEmpty(&CcFreeCacheViewListHead))
- {
- /* not implemented */
- KEBUGCHECK(0);
+ if (IsListEmpty (&CcFreeCacheViewListHead))
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
}
entry = CcFreeCacheViewListHead.Flink;
while (entry != &CcFreeCacheViewListHead)
{
- current = CONTAINING_RECORD(entry, CACHE_VIEW, ListEntry);
- entry = entry->Flink;
- if (current->Bcb == NULL)
- {
- break;
- }
+ current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
+ entry = entry->Flink;
+ if (current->Bcb == NULL)
+ {
+ break;
+ }
}
if (entry == &CcFreeCacheViewListHead)
{
- KEBUGCHECK(0);
- }
-
+ KEBUGCHECK (0);
+ }
+
+ if (current->Bcb)
+ {
+ current->Bcb->CacheView[current->SectionData.ViewOffset /
CACHE_VIEW_SIZE] = NULL;
+ }
Bcb->CacheView[Index] = current;
- if(Bcb->CacheView[Index]->Bcb != NULL)
- {
- DPRINT1("%x\n", Bcb->CacheView[Index]->Bcb);
- /* not implemented */
- KEBUGCHECK(0);
+
+ if (Bcb->CacheView[Index]->Bcb != NULL)
+ {
+ DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
+ /* not implemented */
+ KEBUGCHECK (0);
}
Bcb->CacheView[Index]->RefCount = 1;
Bcb->CacheView[Index]->Bcb = Bcb;
Bcb->CacheView[Index]->SectionData.ViewOffset = Index *
CACHE_VIEW_SIZE;
- Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
- Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
-
- Status = MmMapViewInSystemCache(Bcb->CacheView[Index]);
-
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- }
- ExReleaseFastMutex(&CcCacheViewLock);
-
- if (Offset.QuadPart % CACHE_VIEW_SIZE)
- {
+ Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
+ Bcb->CacheView[Index]->SectionData.Segment =
Bcb->Section->Segment;
+
+ Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
+
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+
+ if (Offset.QuadPart % CACHE_VIEW_SIZE)
+ {
if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
- {
- CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
- }
- else
- {
- CurrentLength = Length;
- }
- memset((PVOID)((ULONG_PTR)Bcb->CacheView[Index]->BaseAddress +
Offset.u.LowPart % CACHE_VIEW_SIZE), 0, CurrentLength);
- Length -= CurrentLength;
- Offset.QuadPart += CurrentLength;
- }
- else
- {
- CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
- memset(Bcb->CacheView[Index]->BaseAddress, 0, CurrentLength);
- Length -= CurrentLength;
- Offset.QuadPart += CurrentLength;
- }
- ExAcquireFastMutex(&CcCacheViewLock);
-
- Bcb->CacheView[Index]->RefCount--;
- if (Bcb->CacheView[Index]->RefCount == 0)
- {
- RemoveEntryList(&Bcb->CacheView[Index]->ListEntry);
- InsertHeadList(&CcFreeCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
- }
- }
- ExReleaseFastMutex(&CcCacheViewLock);
-
- CHECKPOINT;
-
- }
- return(TRUE);
-}
+ {
+ CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
+ }
+ else
+ {
+ CurrentLength = Length;
+ }
+ memcpy (Buffer,
+ (PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress +
Offset.u.LowPart % CACHE_VIEW_SIZE), CurrentLength);
+ Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
+ Length -= CurrentLength;
+ Offset.QuadPart += CurrentLength;
+ }
+ else
+ {
+ CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
+ memcpy (Buffer, Bcb->CacheView[Index]->BaseAddress, CurrentLength);
+ Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
+ Length -= CurrentLength;
+ Offset.QuadPart += CurrentLength;
+ }
+ ExAcquireFastMutex (&CcCacheViewLock);
+
+ Bcb->CacheView[Index]->RefCount--;
+ if (Bcb->CacheView[Index]->RefCount == 0)
+ {
+ RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
+ InsertHeadList (&CcFreeCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
+ }
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+
+ CHECKPOINT;
+
+ return TRUE;
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN STDCALL
+CcCopyWrite (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN BOOLEAN Wait,
+ IN PVOID Buffer)
+{
+
+ ULONG Index;
+ PBCB Bcb;
+ LARGE_INTEGER Offset;
+ PLIST_ENTRY entry;
+ PCACHE_VIEW current = NULL;
+ ULONG CurrentLength;
+ NTSTATUS Status;
+
+ DPRINT ("CcCopyWrite(FileObject 0x%p, FileOffset %I64x, "
+ "Length %d, Wait %d, Buffer 0x%p)\n", FileObject,
FileOffset->QuadPart, Length, Wait, Buffer);
+
+ if (!Wait)
+ {
+ CHECKPOINT;
+ return FALSE;
+ }
+
+ Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+
+ if (FileOffset->QuadPart + Length > Bcb->FileSizes.FileSize.QuadPart)
+ {
+ KEBUGCHECK (0);
+ }
+
+ if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) /
sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+ Offset = *FileOffset;
+
+ ExAcquireFastMutex (&CcCacheViewLock);
+ while (Length)
+ {
+ Index = Offset.QuadPart / CACHE_VIEW_SIZE;
+ if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
+ {
+ CHECKPOINT;
+ if (Bcb->CacheView[Index]->RefCount == 0)
+ {
+ RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
+ InsertHeadList (&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
+ }
+ Bcb->CacheView[Index]->RefCount++;
+ }
+ else
+ {
+ CHECKPOINT;
+ if (IsListEmpty (&CcFreeCacheViewListHead))
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+ entry = CcFreeCacheViewListHead.Flink;
+ while (entry != &CcFreeCacheViewListHead)
+ {
+ current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
+ entry = entry->Flink;
+ if (current->Bcb == NULL)
+ {
+ break;
+ }
+ }
+ if (entry == &CcFreeCacheViewListHead)
+ {
+ KEBUGCHECK (0);
+ }
+
+ if (current->Bcb)
+ {
+ current->Bcb->CacheView[current->SectionData.ViewOffset /
CACHE_VIEW_SIZE] = NULL;
+ }
+
+ Bcb->CacheView[Index] = current;
+
+ if (Bcb->CacheView[Index]->Bcb != NULL)
+ {
+ DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+ Bcb->CacheView[Index]->RefCount = 1;
+ Bcb->CacheView[Index]->Bcb = Bcb;
+ Bcb->CacheView[Index]->SectionData.ViewOffset = Index *
CACHE_VIEW_SIZE;
+ Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
+ Bcb->CacheView[Index]->SectionData.Segment =
Bcb->Section->Segment;
+
+ Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
+
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+
+ if (Offset.QuadPart % CACHE_VIEW_SIZE)
+ {
+ if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
+ {
+ CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
+ }
+ else
+ {
+ CurrentLength = Length;
+ }
+ memcpy ((PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress +
Offset.u.LowPart % CACHE_VIEW_SIZE),
+ Buffer, CurrentLength);
+ Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
+ Length -= CurrentLength;
+ Offset.QuadPart += CurrentLength;
+ }
+ else
+ {
+ CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
+ memcpy (Bcb->CacheView[Index]->BaseAddress, Buffer, CurrentLength);
+ Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
+ Length -= CurrentLength;
+ Offset.QuadPart += CurrentLength;
+ }
+ ExAcquireFastMutex (&CcCacheViewLock);
+
+ Bcb->CacheView[Index]->RefCount--;
+ if (Bcb->CacheView[Index]->RefCount == 0)
+ {
+ RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
+ InsertHeadList (&CcFreeCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
+ }
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+
+ CHECKPOINT;
+
+ return TRUE;
+}
+
+/*
+ * @unimplemented
+ */
+VOID STDCALL
+CcDeferWrite (IN PFILE_OBJECT FileObject,
+ IN PCC_POST_DEFERRED_WRITE PostRoutine,
+ IN PVOID Context1,
+ IN PVOID Context2,
+ IN ULONG BytesToWrite,
+ IN BOOLEAN Retrying)
+{
+ UNIMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
+VOID STDCALL
+CcFastCopyRead (IN PFILE_OBJECT FileObject,
+ IN ULONG FileOffset,
+ IN ULONG Length,
+ IN ULONG PageCount,
+ OUT PVOID Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus)
+{
+ UNIMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
+VOID STDCALL
+CcFastCopyWrite (IN PFILE_OBJECT FileObject,
+ IN ULONG FileOffset,
+ IN ULONG Length,
+ IN PVOID Buffer)
+{
+ UNIMPLEMENTED;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS STDCALL
+CcWaitForCurrentLazyWriterActivity (VOID)
+{
+ UNIMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN STDCALL
+CcZeroData (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER StartOffset,
+ IN PLARGE_INTEGER EndOffset,
+ IN BOOLEAN Wait)
+{
+ NTSTATUS Status;
+ LARGE_INTEGER WriteOffset;
+ ULONG Length;
+ ULONG CurrentLength;
+ PMDL Mdl;
+ ULONG i;
+ IO_STATUS_BLOCK Iosb;
+ KEVENT Event;
+ LARGE_INTEGER Offset;
+ ULONG Index;
+
+ DPRINT ("CcZeroData(FileObject 0x%p, StartOffset %I64x, EndOffset %I64x, "
+ "Wait %d)\n", FileObject, StartOffset->QuadPart,
EndOffset->QuadPart, Wait);
+
+ Length = EndOffset->u.LowPart - StartOffset->u.LowPart;
+ WriteOffset.QuadPart = StartOffset->QuadPart;
+
+ if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
+ {
+ /* File is not cached */
+
+ Mdl = alloca (MmSizeOfMdl (NULL, MAX_ZERO_LENGTH));
+
+ while (Length > 0)
+ {
+ if (Length + WriteOffset.u.LowPart % PAGE_SIZE > MAX_ZERO_LENGTH)
+ {
+ CurrentLength = MAX_ZERO_LENGTH - WriteOffset.u.LowPart % PAGE_SIZE;
+ }
+ else
+ {
+ CurrentLength = Length;
+ }
+ MmInitializeMdl (Mdl, (PVOID) WriteOffset.u.LowPart, CurrentLength);
+ Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
+ for (i = 0; i < ((Mdl->Size - sizeof (MDL)) / sizeof (ULONG)); i++)
+ {
+ ((PPFN_TYPE) (Mdl + 1))[i] = CcZeroPage;
+ }
+ KeInitializeEvent (&Event, NotificationEvent, FALSE);
+ Status = IoSynchronousPageWrite (FileObject, Mdl, &WriteOffset,
&Event, &Iosb);
+ if (Status == STATUS_PENDING)
+ {
+ KeWaitForSingleObject (&Event, Executive, KernelMode, FALSE, NULL);
+ Status = Iosb.Status;
+ }
+ MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
+ if (!NT_SUCCESS (Status))
+ {
+ return (FALSE);
+ }
+ WriteOffset.QuadPart += CurrentLength;
+ Length -= CurrentLength;
+ }
+ }
+ else
+ {
+ /* File is cached */
+ PBCB Bcb;
+ PCACHE_VIEW current = NULL;
+ PLIST_ENTRY entry;
+
+ Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+
+ if (!Wait)
+ {
+ CHECKPOINT;
+ return FALSE;
+ }
+
+ if (EndOffset->QuadPart > Bcb->FileSizes.FileSize.QuadPart)
+ {
+ KEBUGCHECK (0);
+ }
+
+ if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) /
sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+ Offset = *StartOffset;
+ Length = EndOffset->QuadPart - StartOffset->QuadPart;
+
+ ExAcquireFastMutex (&CcCacheViewLock);
+ while (Length)
+ {
+ Index = Offset.QuadPart / CACHE_VIEW_SIZE;
+ if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb ==
Bcb)
+ {
+ CHECKPOINT;
+ if (Bcb->CacheView[Index]->RefCount == 0)
+ {
+ RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
+ InsertHeadList (&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
+ }
+ Bcb->CacheView[Index]->RefCount++;
+ }
+ else
+ {
+ CHECKPOINT;
+ if (IsListEmpty (&CcFreeCacheViewListHead))
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+ entry = CcFreeCacheViewListHead.Flink;
+ while (entry != &CcFreeCacheViewListHead)
+ {
+ current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
+ entry = entry->Flink;
+ if (current->Bcb == NULL)
+ {
+ break;
+ }
+ }
+ if (entry == &CcFreeCacheViewListHead)
+ {
+ KEBUGCHECK (0);
+ }
+
+ Bcb->CacheView[Index] = current;
+
+ if (Bcb->CacheView[Index]->Bcb != NULL)
+ {
+ DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+ Bcb->CacheView[Index]->RefCount = 1;
+ Bcb->CacheView[Index]->Bcb = Bcb;
+ Bcb->CacheView[Index]->SectionData.ViewOffset = Index *
CACHE_VIEW_SIZE;
+ Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
+ Bcb->CacheView[Index]->SectionData.Segment =
Bcb->Section->Segment;
+
+ Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
+
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+
+ if (Offset.QuadPart % CACHE_VIEW_SIZE)
+ {
+ if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
+ {
+ CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart %
CACHE_VIEW_SIZE;
+ }
+ else
+ {
+ CurrentLength = Length;
+ }
+ memset ((PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress +
Offset.u.LowPart % CACHE_VIEW_SIZE), 0,
+ CurrentLength);
+ Length -= CurrentLength;
+ Offset.QuadPart += CurrentLength;
+ }
+ else
+ {
+ CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
+ memset (Bcb->CacheView[Index]->BaseAddress, 0, CurrentLength);
+ Length -= CurrentLength;
+ Offset.QuadPart += CurrentLength;
+ }
+ ExAcquireFastMutex (&CcCacheViewLock);
+
+ Bcb->CacheView[Index]->RefCount--;
+ if (Bcb->CacheView[Index]->RefCount == 0)
+ {
+ RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
+ InsertHeadList (&CcFreeCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
+ }
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+
+ CHECKPOINT;
+ }
+ return (TRUE);
+}
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/cc/fs.c
URL:
http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nt…
==============================================================================
--- branches/cache_manager_rewrite/reactos/ntoskrnl/cc/fs.c (original)
+++ branches/cache_manager_rewrite/reactos/ntoskrnl/cc/fs.c Mon Mar 27 22:17:12 2006
@@ -16,7 +16,7 @@
#ifndef ROUND_DOWN
-#define ROUND_DOWN(X,Y) ((X) & ~((Y) - 1))
+#define ROUND_DOWN(X,Y) ((X) & ~((Y) - 1))
#endif
/* GLOBALS *****************************************************************/
@@ -25,89 +25,71 @@
extern ULONG CcCacheViewArrayCount;
extern FAST_MUTEX CcCacheViewLock;
-NTSTATUS STDCALL
-MmUnmapViewInSystemCache(PCACHE_VIEW);
+NTSTATUS STDCALL MmUnmapViewInSystemCache (PCACHE_VIEW);
-NTSTATUS STDCALL
-MmChangeSectionSize(PSECTION_OBJECT Section,
- PLARGE_INTEGER NewMaxSize);
+NTSTATUS STDCALL MmChangeSectionSize (PSECTION_OBJECT Section, PLARGE_INTEGER
NewMaxSize);
/* FUNCTIONS *****************************************************************/
/*
* @unimplemented
*/
-LARGE_INTEGER
-STDCALL
-CcGetDirtyPages (
- IN PVOID LogHandle,
- IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine,
- IN PVOID Context1,
- IN PVOID Context2
- )
+LARGE_INTEGER STDCALL
+CcGetDirtyPages (IN PVOID LogHandle,
+ IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine,
+ IN PVOID Context1,
+ IN PVOID Context2)
{
- LARGE_INTEGER i;
- UNIMPLEMENTED;
- i.QuadPart = 0;
- return i;
+ LARGE_INTEGER i;
+ UNIMPLEMENTED;
+ i.QuadPart = 0;
+ return i;
}
/*
* @implemented
*/
-PFILE_OBJECT
-STDCALL
-CcGetFileObjectFromBcb (
- IN PVOID Bcb
- )
+PFILE_OBJECT STDCALL
+CcGetFileObjectFromBcb (IN PVOID Bcb)
{
- PINTERNAL_BCB iBcb = (PINTERNAL_BCB)Bcb;
- return iBcb->Bcb->FileObject;
+ PINTERNAL_BCB iBcb = (PINTERNAL_BCB) Bcb;
+ return iBcb->Bcb->FileObject;
}
/*
* @unimplemented
*/
-LARGE_INTEGER
-STDCALL
-CcGetLsnForFileObject (
- IN PFILE_OBJECT FileObject,
- OUT PLARGE_INTEGER OldestLsn OPTIONAL
- )
+LARGE_INTEGER STDCALL
+CcGetLsnForFileObject (IN PFILE_OBJECT FileObject,
+ OUT PLARGE_INTEGER OldestLsn OPTIONAL)
{
- LARGE_INTEGER i;
- UNIMPLEMENTED;
- i.QuadPart = 0;
- return i;
+ LARGE_INTEGER i;
+ UNIMPLEMENTED;
+ i.QuadPart = 0;
+ return i;
}
/*
* @unimplemented
*/
-BOOLEAN
-STDCALL
-CcIsThereDirtyData (
- IN PVPB Vpb
- )
+BOOLEAN STDCALL
+CcIsThereDirtyData (IN PVPB Vpb)
{
- UNIMPLEMENTED;
- return FALSE;
+ UNIMPLEMENTED;
+ return FALSE;
}
/*
* @unimplemented
*/
-BOOLEAN
-STDCALL
-CcPurgeCacheSection (
- IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
- IN PLARGE_INTEGER FileOffset OPTIONAL,
- IN ULONG Length,
- IN BOOLEAN UninitializeCacheMaps
- )
+BOOLEAN STDCALL
+CcPurgeCacheSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
+ IN PLARGE_INTEGER FileOffset OPTIONAL,
+ IN ULONG Length,
+ IN BOOLEAN UninitializeCacheMaps)
{
- UNIMPLEMENTED;
- return FALSE;
+ UNIMPLEMENTED;
+ return FALSE;
}
@@ -115,101 +97,94 @@
* @implemented
*/
VOID STDCALL
-CcSetFileSizes (IN PFILE_OBJECT FileObject,
- IN PCC_FILE_SIZES FileSizes)
+CcSetFileSizes (IN PFILE_OBJECT FileObject,
+ IN PCC_FILE_SIZES FileSizes)
{
- PBCB Bcb;
- NTSTATUS Status;
- ULONG i;
+ PBCB Bcb;
+ NTSTATUS Status;
+ ULONG i;
- DPRINT("CcSetFileSizes(FileObject 0x%p, FileSizes 0x%p)\n",
- FileObject, FileSizes);
- DPRINT("AllocationSize %d, FileSize %d, ValidDataLength %d\n",
- (ULONG)FileSizes->AllocationSize.QuadPart,
- (ULONG)FileSizes->FileSize.QuadPart,
- (ULONG)FileSizes->ValidDataLength.QuadPart);
- DPRINT("%wZ\n", &FileObject->FileName);
-
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
- if (Bcb == NULL)
- {
- return;
- }
- DPRINT("AllocationSize %d, FileSize %d, ValidDataLength %d\n",
- (ULONG)Bcb->FileSizes.AllocationSize.QuadPart,
- (ULONG)Bcb->FileSizes.FileSize.QuadPart,
- (ULONG)Bcb->FileSizes.ValidDataLength.QuadPart);
- ExAcquireFastMutex(&CcCacheViewLock);
+ DPRINT ("CcSetFileSizes(FileObject 0x%p, FileSizes 0x%p)\n", FileObject,
FileSizes);
+ DPRINT ("AllocationSize %d, FileSize %d, ValidDataLength %d\n",
+ (ULONG) FileSizes->AllocationSize.QuadPart,
+ (ULONG) FileSizes->FileSize.QuadPart, (ULONG)
FileSizes->ValidDataLength.QuadPart);
+ DPRINT ("%wZ\n", &FileObject->FileName);
- DPRINT("%d\n", Bcb->FileSizes.FileSize.u.LowPart);
+ Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ if (Bcb == NULL)
+ {
+ return;
+ }
+ DPRINT ("AllocationSize %d, FileSize %d, ValidDataLength %d\n",
+ (ULONG) Bcb->FileSizes.AllocationSize.QuadPart,
+ (ULONG) Bcb->FileSizes.FileSize.QuadPart, (ULONG)
Bcb->FileSizes.ValidDataLength.QuadPart);
+ ExAcquireFastMutex (&CcCacheViewLock);
- for (i = ROUND_DOWN(FileSizes->AllocationSize.QuadPart, CACHE_VIEW_SIZE) /
CACHE_VIEW_SIZE;
- i < ROUND_UP(Bcb->FileSizes.AllocationSize.QuadPart, CACHE_VIEW_SIZE) /
CACHE_VIEW_SIZE;
- i++)
- {
- if (Bcb->CacheView[i] != NULL)
- {
- if (Bcb->CacheView[i]->Bcb != Bcb)
- {
- KEBUGCHECK(0);
- }
- if (Bcb->CacheView[i]->RefCount > 0)
- {
- KEBUGCHECK(0);
- }
- Status = MmUnmapViewInSystemCache(Bcb->CacheView[i]);
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- Bcb->CacheView[i]->RefCount = 0;
- Bcb->CacheView[i]->Bcb = NULL;
- Bcb->CacheView[i] = NULL;
- }
- }
-
+ DPRINT ("%d\n", Bcb->FileSizes.FileSize.u.LowPart);
+
+ for (i = ROUND_DOWN (FileSizes->AllocationSize.QuadPart, CACHE_VIEW_SIZE) /
CACHE_VIEW_SIZE;
+ i < ROUND_UP (Bcb->FileSizes.AllocationSize.QuadPart, CACHE_VIEW_SIZE) /
CACHE_VIEW_SIZE; i++)
+ {
+ if (Bcb->CacheView[i] != NULL)
+ {
+ if (Bcb->CacheView[i]->Bcb != Bcb)
+ {
+ KEBUGCHECK (0);
+ }
+ if (Bcb->CacheView[i]->RefCount > 0)
+ {
+ KEBUGCHECK (0);
+ }
+ Status = MmUnmapViewInSystemCache (Bcb->CacheView[i]);
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ Bcb->CacheView[i]->RefCount = 0;
+ Bcb->CacheView[i]->Bcb = NULL;
+ Bcb->CacheView[i] = NULL;
+ }
+ }
+
#if 0
- for (i = 0; i < CcCacheViewArrayCount; i++)
- {
- if (CcCacheViewArray[i].Bcb == Bcb)
- {
- if (PAGE_ROUND_UP(FileSizes->AllocationSize.QuadPart) <=
CcCacheViewArray[i].SectionData.ViewOffset ||
- (PAGE_ROUND_UP(FileSizes->AllocationSize.QuadPart) >
CcCacheViewArray[i].SectionData.ViewOffset &&
- PAGE_ROUND_UP(FileSizes->AllocationSize.QuadPart) <=
CcCacheViewArray[i].SectionData.ViewOffset + CACHE_VIEW_SIZE))
-
- {
- if (CcCacheViewArray[i].RefCount > 0)
- {
- KEBUGCHECK(0);
- }
- Status = MmUnmapViewInSystemCache(&CcCacheViewArray[i]);
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- CcCacheViewArray[i].RefCount = 0;
- CcCacheViewArray[i].Bcb = NULL;
- }
- }
- }
+ for (i = 0; i < CcCacheViewArrayCount; i++)
+ {
+ if (CcCacheViewArray[i].Bcb == Bcb)
+ {
+ if (PAGE_ROUND_UP (FileSizes->AllocationSize.QuadPart) <=
CcCacheViewArray[i].SectionData.ViewOffset ||
+ (PAGE_ROUND_UP (FileSizes->AllocationSize.QuadPart) >
CcCacheViewArray[i].SectionData.ViewOffset &&
+ PAGE_ROUND_UP (FileSizes->AllocationSize.QuadPart) <=
+ CcCacheViewArray[i].SectionData.ViewOffset + CACHE_VIEW_SIZE))
+
+ {
+ if (CcCacheViewArray[i].RefCount > 0)
+ {
+ KEBUGCHECK (0);
+ }
+ Status = MmUnmapViewInSystemCache (&CcCacheViewArray[i]);
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ CcCacheViewArray[i].RefCount = 0;
+ CcCacheViewArray[i].Bcb = NULL;
+ }
+ }
+ }
#endif
- Status = MmChangeSectionSize(Bcb->Section, &FileSizes->FileSize);
- Bcb->FileSizes = *FileSizes;
+ Status = MmChangeSectionSize (Bcb->Section, &FileSizes->FileSize);
+ Bcb->FileSizes = *FileSizes;
- ExReleaseFastMutex(&CcCacheViewLock);
+ ExReleaseFastMutex (&CcCacheViewLock);
}
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcSetLogHandleForFile (
- IN PFILE_OBJECT FileObject,
- IN PVOID LogHandle,
- IN PFLUSH_TO_LSN FlushToLsnRoutine
- )
+VOID STDCALL
+CcSetLogHandleForFile (IN PFILE_OBJECT FileObject,
+ IN PVOID LogHandle,
+ IN PFLUSH_TO_LSN FlushToLsnRoutine)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
-
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/cc/mdl.c
URL:
http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nt…
==============================================================================
--- branches/cache_manager_rewrite/reactos/ntoskrnl/cc/mdl.c (original)
+++ branches/cache_manager_rewrite/reactos/ntoskrnl/cc/mdl.c Mon Mar 27 22:17:12 2006
@@ -19,21 +19,18 @@
/*
* @implemented
*/
-VOID
-STDCALL
-CcMdlRead(
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- OUT PMDL * MdlChain,
- OUT PIO_STATUS_BLOCK IoStatus
- )
+VOID STDCALL
+CcMdlRead (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ OUT PMDL * MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
/*
- * NAME INTERNAL
+ * NAME INTERNAL
* CcMdlReadCompleteDev@8
*
* DESCRIPTION
@@ -46,13 +43,12 @@
* None.
*
* NOTE
- * Used by CcMdlReadComplete@8 and FsRtl
+ * Used by CcMdlReadComplete@8 and FsRtl
*
*/
-VOID
-STDCALL
-CcMdlReadCompleteDev(IN PMDL MdlChain,
- IN PFILE_OBJECT FileObject)
+VOID STDCALL
+CcMdlReadCompleteDev (IN PMDL MdlChain,
+ IN PFILE_OBJECT FileObject)
{
PMDL Mdl;
@@ -60,8 +56,8 @@
while ((Mdl = MdlChain))
{
MdlChain = Mdl->Next;
- MmUnlockPages(Mdl);
- IoFreeMdl(Mdl);
+ MmUnlockPages (Mdl);
+ IoFreeMdl (Mdl);
}
}
@@ -81,66 +77,58 @@
*
* @implemented
*/
-VOID
-STDCALL
-CcMdlReadComplete(IN PFILE_OBJECT FileObject,
- IN PMDL MdlChain)
-{
- PDEVICE_OBJECT DeviceObject = NULL;
- PFAST_IO_DISPATCH FastDispatch;
-
- /* Get Fast Dispatch Data */
- DeviceObject = IoGetRelatedDeviceObject(FileObject);
- FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
-
- /* Check if we support Fast Calls, and check this one */
- if (FastDispatch && FastDispatch->MdlReadComplete)
- {
- /* Use the fast path */
- FastDispatch->MdlReadComplete(FileObject,
- MdlChain,
- DeviceObject);
- }
-
- /* Use slow path */
- CcMdlReadCompleteDev(MdlChain, FileObject);
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-CcMdlWriteComplete(IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
+VOID STDCALL
+CcMdlReadComplete (IN PFILE_OBJECT FileObject,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject = NULL;
PFAST_IO_DISPATCH FastDispatch;
/* Get Fast Dispatch Data */
- DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ DeviceObject = IoGetRelatedDeviceObject (FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if we support Fast Calls, and check this one */
+ if (FastDispatch && FastDispatch->MdlReadComplete)
+ {
+ /* Use the fast path */
+ FastDispatch->MdlReadComplete (FileObject, MdlChain, DeviceObject);
+ }
+
+ /* Use slow path */
+ CcMdlReadCompleteDev (MdlChain, FileObject);
+}
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+CcMdlWriteComplete (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain)
+{
+ PDEVICE_OBJECT DeviceObject = NULL;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Fast Dispatch Data */
+ DeviceObject = IoGetRelatedDeviceObject (FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlWriteComplete)
{
- /* Use the fast path */
- FastDispatch->MdlWriteComplete(FileObject,
- FileOffset,
- MdlChain,
- DeviceObject);
+ /* Use the fast path */
+ FastDispatch->MdlWriteComplete (FileObject, FileOffset, MdlChain,
DeviceObject);
}
/* Use slow path */
- CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject);
+ CcMdlWriteCompleteDev (FileOffset, MdlChain, FileObject);
}
-VOID
-STDCALL
-CcMdlWriteCompleteDev(IN PLARGE_INTEGER FileOffset,
- IN PMDL MdlChain,
- IN PFILE_OBJECT FileObject)
+VOID STDCALL
+CcMdlWriteCompleteDev (IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain,
+ IN PFILE_OBJECT FileObject)
{
UNIMPLEMENTED;
}
@@ -148,28 +136,22 @@
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcMdlWriteAbort (
- IN PFILE_OBJECT FileObject,
- IN PMDL MdlChain
- )
+VOID STDCALL
+CcMdlWriteAbort (IN PFILE_OBJECT FileObject,
+ IN PMDL MdlChain)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcPrepareMdlWrite (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- OUT PMDL * MdlChain,
- OUT PIO_STATUS_BLOCK IoStatus
- )
+VOID STDCALL
+CcPrepareMdlWrite (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ OUT PMDL * MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus)
{
- UNIMPLEMENTED;
+ UNIMPLEMENTED;
}
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/cc/pin.c
URL:
http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nt…
==============================================================================
--- branches/cache_manager_rewrite/reactos/ntoskrnl/cc/pin.c (original)
+++ branches/cache_manager_rewrite/reactos/ntoskrnl/cc/pin.c Mon Mar 27 22:17:12 2006
@@ -24,217 +24,208 @@
/* FUNCTIONS *****************************************************************/
-NTSTATUS STDCALL
-MmMapViewInSystemCache(PCACHE_VIEW);
-
-
-/*
- * @implemented
- */
-BOOLEAN STDCALL
-CcMapData(IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN BOOLEAN Wait,
- OUT PVOID* piBcb,
- OUT PVOID* pBuffer)
-{
- PINTERNAL_BCB iBcb;
- PBCB Bcb;
- ULONG Index;
- NTSTATUS Status;
- PLIST_ENTRY entry;
- PCACHE_VIEW current = NULL;
-
- DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d, Wait %d,"
- " pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart,
- Length, Wait, piBcb, pBuffer);
-
- ASSERT (FileObject);
- ASSERT (FileObject->SectionObjectPointer);
- ASSERT (FileObject->SectionObjectPointer->SharedCacheMap);
- ASSERT (FileOffset);
- ASSERT (piBcb);
- ASSERT (pBuffer);
-
- if (!Wait)
- {
- *piBcb = NULL;
- *pBuffer = NULL;
- return FALSE;
- }
-
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
-
- if (FileOffset->QuadPart + Length > Bcb->FileSizes.AllocationSize.QuadPart)
- {
- DPRINT("%d %I64d %I64d\n", Length, FileOffset->QuadPart + Length,
Bcb->FileSizes.AllocationSize.QuadPart);
+NTSTATUS STDCALL MmMapViewInSystemCache (PCACHE_VIEW);
+
+
+/*
+ * @implemented
+ */
+BOOLEAN STDCALL
+CcMapData (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN BOOLEAN Wait,
+ OUT PVOID * piBcb,
+ OUT PVOID * pBuffer)
+{
+ PINTERNAL_BCB iBcb;
+ PBCB Bcb;
+ ULONG Index;
+ NTSTATUS Status;
+ PLIST_ENTRY entry;
+ PCACHE_VIEW current = NULL;
+
+ DPRINT ("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d, Wait %d,"
+ " pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart,
Length, Wait, piBcb, pBuffer);
+
+ ASSERT (FileObject);
+ ASSERT (FileObject->SectionObjectPointer);
+ ASSERT (FileObject->SectionObjectPointer->SharedCacheMap);
+ ASSERT (FileOffset);
+ ASSERT (piBcb);
+ ASSERT (pBuffer);
+
+ if (!Wait)
+ {
+ *piBcb = NULL;
+ *pBuffer = NULL;
+ return FALSE;
+ }
+
+ Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+
+ if (FileOffset->QuadPart + Length > Bcb->FileSizes.AllocationSize.QuadPart)
+ {
+ DPRINT ("%d %I64d %I64d\n", Length, FileOffset->QuadPart + Length,
Bcb->FileSizes.AllocationSize.QuadPart);
// KEBUGCHECK(0);
- }
-
- if (FileOffset->QuadPart + Length - ROUND_DOWN(FileOffset->QuadPart,
CACHE_VIEW_SIZE) > CACHE_VIEW_SIZE)
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
-
-
- if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof(Bcb->CacheView) /
sizeof(Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
- ExAcquireFastMutex(&CcCacheViewLock);
-
- Index = FileOffset->QuadPart / CACHE_VIEW_SIZE;
- if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
- {
- if (Bcb->CacheView[Index]->RefCount == 0)
- {
- RemoveEntryList(&Bcb->CacheView[Index]->ListEntry);
- InsertHeadList(&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
- }
- Bcb->CacheView[Index]->RefCount++;
- }
- else
- {
- if (IsListEmpty(&CcFreeCacheViewListHead))
- {
- /* not implemented */
- KEBUGCHECK(0);
- }
-
- entry = CcFreeCacheViewListHead.Flink;
- while (entry != &CcFreeCacheViewListHead)
- {
- current = CONTAINING_RECORD(entry, CACHE_VIEW, ListEntry);
- entry = entry->Flink;
- if (current->Bcb == NULL)
- {
- break;
- }
- }
- if (entry == &CcFreeCacheViewListHead)
- {
- KEBUGCHECK(0);
- }
-
- Bcb->CacheView[Index] = current;
-
- if(Bcb->CacheView[Index]->Bcb != NULL)
- {
- DPRINT1("%x\n", Bcb->CacheView[Index]->Bcb);
- /* not implemented */
- KEBUGCHECK(0);
- }
- Bcb->CacheView[Index]->RefCount = 1;
- Bcb->CacheView[Index]->Bcb = Bcb;
- Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
- Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
- Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
-
- Status = MmMapViewInSystemCache(Bcb->CacheView[Index]);
-
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- }
- ExReleaseFastMutex(&CcCacheViewLock);
-
- iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList);
- if (iBcb == NULL)
- {
- KEBUGCHECK(0);
- }
- memset(iBcb, 0, sizeof(INTERNAL_BCB));
-
- iBcb->Bcb = Bcb;
- iBcb->Index = Index;
-
- *piBcb = iBcb;
- *pBuffer = (PVOID)((ULONG_PTR)Bcb->CacheView[Index]->BaseAddress +
(ULONG_PTR)(FileOffset->QuadPart -
Bcb->CacheView[Index]->SectionData.ViewOffset));
-
- DPRINT("CcMapData() done\n");
-
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOLEAN
-STDCALL
-CcPinMappedData (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN ULONG Flags,
- OUT PVOID * Bcb
- )
-{
- /* no-op for current implementation. */
- return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOLEAN
-STDCALL
-CcPinRead (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN ULONG Flags,
- OUT PVOID * Bcb,
- OUT PVOID * Buffer
- )
-{
- if (CcMapData(FileObject, FileOffset, Length, Flags, Bcb, Buffer))
- {
- if (CcPinMappedData(FileObject, FileOffset, Length, Flags, Bcb))
- return TRUE;
+ }
+
+ if (FileOffset->QuadPart + Length - ROUND_DOWN (FileOffset->QuadPart,
CACHE_VIEW_SIZE) > CACHE_VIEW_SIZE)
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+
+
+ if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) /
sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+ ExAcquireFastMutex (&CcCacheViewLock);
+
+ Index = FileOffset->QuadPart / CACHE_VIEW_SIZE;
+ if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
+ {
+ if (Bcb->CacheView[Index]->RefCount == 0)
+ {
+ RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
+ InsertHeadList (&CcInUseCacheViewListHead,
&Bcb->CacheView[Index]->ListEntry);
+ }
+ Bcb->CacheView[Index]->RefCount++;
+ }
else
- CcUnpinData(Bcb);
- }
- return FALSE;
-}
-
-/*
- * @unimplemented
- */
-BOOLEAN
-STDCALL
-CcPreparePinWrite (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN BOOLEAN Zero,
- IN ULONG Flags,
- OUT PVOID * Bcb,
- OUT PVOID * Buffer
- )
-{
- /*
- * FIXME: This is function is similar to CcPinRead, but doesn't
- * read the data if they're not present. Instead it should just
- * prepare the cache segments and zero them out if Zero == TRUE.
- *
- * For now calling CcPinRead is better than returning error or
- * just having UNIMPLEMENTED here.
- */
- return CcPinRead(FileObject, FileOffset, Length, Flags, Bcb, Buffer);
-}
-
-/*
- * @implemented
- */
-VOID STDCALL
-CcSetDirtyPinnedData (IN PVOID Bcb,
- IN PLARGE_INTEGER Lsn)
+ {
+ if (IsListEmpty (&CcFreeCacheViewListHead))
+ {
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+
+ entry = CcFreeCacheViewListHead.Flink;
+ while (entry != &CcFreeCacheViewListHead)
+ {
+ current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
+ entry = entry->Flink;
+ if (current->Bcb == NULL)
+ {
+ break;
+ }
+ }
+ if (entry == &CcFreeCacheViewListHead)
+ {
+ KEBUGCHECK (0);
+ }
+
+ Bcb->CacheView[Index] = current;
+
+ if (Bcb->CacheView[Index]->Bcb != NULL)
+ {
+ DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
+ /* not implemented */
+ KEBUGCHECK (0);
+ }
+ Bcb->CacheView[Index]->RefCount = 1;
+ Bcb->CacheView[Index]->Bcb = Bcb;
+ Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
+ Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
+ Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
+
+ Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
+
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+
+ iBcb = ExAllocateFromNPagedLookasideList (&iBcbLookasideList);
+ if (iBcb == NULL)
+ {
+ KEBUGCHECK (0);
+ }
+ memset (iBcb, 0, sizeof (INTERNAL_BCB));
+
+ iBcb->Bcb = Bcb;
+ iBcb->Index = Index;
+
+ *piBcb = iBcb;
+ *pBuffer =
+ (PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress +
+ (ULONG_PTR) (FileOffset->QuadPart -
Bcb->CacheView[Index]->SectionData.ViewOffset));
+
+ DPRINT ("CcMapData() done\n");
+
+ return TRUE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN STDCALL
+CcPinMappedData (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG Flags,
+ OUT PVOID * Bcb)
+{
+ /* no-op for current implementation. */
+ return TRUE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN STDCALL
+CcPinRead (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG Flags,
+ OUT PVOID * Bcb,
+ OUT PVOID * Buffer)
+{
+ if (CcMapData (FileObject, FileOffset, Length, Flags, Bcb, Buffer))
+ {
+ if (CcPinMappedData (FileObject, FileOffset, Length, Flags, Bcb))
+ return TRUE;
+ else
+ CcUnpinData (Bcb);
+ }
+ return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN STDCALL
+CcPreparePinWrite (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN BOOLEAN Zero,
+ IN ULONG Flags,
+ OUT PVOID * Bcb,
+ OUT PVOID * Buffer)
+{
+ /*
+ * FIXME: This is function is similar to CcPinRead, but doesn't
+ * read the data if they're not present. Instead it should just
+ * prepare the cache segments and zero them out if Zero == TRUE.
+ *
+ * For now calling CcPinRead is better than returning error or
+ * just having UNIMPLEMENTED here.
+ */
+ return CcPinRead (FileObject, FileOffset, Length, Flags, Bcb, Buffer);
+}
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+CcSetDirtyPinnedData (IN PVOID Bcb,
+ IN PLARGE_INTEGER Lsn)
{
// PINTERNAL_BCB iBcb = Bcb;
// iBcb->Dirty = TRUE;
@@ -248,44 +239,38 @@
VOID STDCALL
CcUnpinData (IN PVOID _iBcb)
{
- PINTERNAL_BCB iBcb = _iBcb;
-
- DPRINT("CcUnpinData(%x)\n", _iBcb);
-
- ExAcquireFastMutex(&CcCacheViewLock);
- iBcb->Bcb->CacheView[iBcb->Index]->RefCount--;
- if (iBcb->Bcb->CacheView[iBcb->Index]->RefCount == 0)
- {
- RemoveEntryList(&iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
- InsertHeadList(&CcFreeCacheViewListHead,
&iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
- }
- ExReleaseFastMutex(&CcCacheViewLock);
- ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
-
- DPRINT("CcUnpinData done\n");
-}
-
-/*
- * @unimplemented
- */
-VOID
-STDCALL
-CcUnpinDataForThread (
- IN PVOID Bcb,
- IN ERESOURCE_THREAD ResourceThreadId
- )
-{
- UNIMPLEMENTED;
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-CcRepinBcb (
- IN PVOID Bcb
- )
+ PINTERNAL_BCB iBcb = _iBcb;
+
+ DPRINT ("CcUnpinData(%x)\n", _iBcb);
+
+ ExAcquireFastMutex (&CcCacheViewLock);
+ iBcb->Bcb->CacheView[iBcb->Index]->RefCount--;
+ if (iBcb->Bcb->CacheView[iBcb->Index]->RefCount == 0)
+ {
+ RemoveEntryList (&iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
+ InsertHeadList (&CcFreeCacheViewListHead,
&iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
+ }
+ ExReleaseFastMutex (&CcCacheViewLock);
+ ExFreeToNPagedLookasideList (&iBcbLookasideList, iBcb);
+
+ DPRINT ("CcUnpinData done\n");
+}
+
+/*
+ * @unimplemented
+ */
+VOID STDCALL
+CcUnpinDataForThread (IN PVOID Bcb,
+ IN ERESOURCE_THREAD ResourceThreadId)
+{
+ UNIMPLEMENTED;
+}
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+CcRepinBcb (IN PVOID Bcb)
{
// PINTERNAL_BCB iBcb = Bcb;
// iBcb->RefCount++;
@@ -295,13 +280,10 @@
/*
* @unimplemented
*/
-VOID
-STDCALL
-CcUnpinRepinnedBcb (
- IN PVOID Bcb,
- IN BOOLEAN WriteThrough,
- IN PIO_STATUS_BLOCK IoStatus)
-{
- KEBUGCHECK(0);
-}
-
+VOID STDCALL
+CcUnpinRepinnedBcb (IN PVOID Bcb,
+ IN BOOLEAN WriteThrough,
+ IN PIO_STATUS_BLOCK IoStatus)
+{
+ KEBUGCHECK (0);
+}
Modified: branches/cache_manager_rewrite/reactos/ntoskrnl/cc/view.c
URL:
http://svn.reactos.ru/svn/reactos/branches/cache_manager_rewrite/reactos/nt…
==============================================================================
--- branches/cache_manager_rewrite/reactos/ntoskrnl/cc/view.c (original)
+++ branches/cache_manager_rewrite/reactos/ntoskrnl/cc/view.c Mon Mar 27 22:17:12 2006
@@ -23,7 +23,7 @@
#undef ROUND_DOWN
#endif
-#define ROUND_UP(N, S) (((N) + (S) - 1) & ~((S) - 1))
+#define ROUND_UP(N, S) (((N) + (S) - 1) & ~((S) - 1))
#define ROUND_DOWN(N, S) ((N) & ~((S) - 1))
NPAGED_LOOKASIDE_LIST iBcbLookasideList;
@@ -37,21 +37,18 @@
LIST_ENTRY CcInUseCacheViewListHead;
PMEMORY_AREA CcCacheViewMemoryArea;
-NTSTATUS NTAPI
-MmCreateDataFileSection(PSECTION_OBJECT *SectionObject,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PLARGE_INTEGER UMaximumSize,
- ULONG SectionPageProtection,
- ULONG AllocationAttributes,
- PFILE_OBJECT FileObject,
- BOOLEAN CacheManager);
-
-NTSTATUS STDCALL
-MmUnmapViewInSystemCache(PCACHE_VIEW);
-
-NTSTATUS
-MmFlushDataFileSection(PSECTION_OBJECT Section, PLARGE_INTEGER StartOffset, ULONG
Length);
+NTSTATUS NTAPI MmCreateDataFileSection (PSECTION_OBJECT * SectionObject,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ PLARGE_INTEGER UMaximumSize,
+ ULONG SectionPageProtection,
+ ULONG AllocationAttributes,
+ PFILE_OBJECT FileObject,
+ BOOLEAN CacheManager);
+
+NTSTATUS STDCALL MmUnmapViewInSystemCache (PCACHE_VIEW);
+
+NTSTATUS MmFlushDataFileSection (PSECTION_OBJECT Section, PLARGE_INTEGER StartOffset,
ULONG Length);
/* FUNCTIONS *****************************************************************/
@@ -59,247 +56,220 @@
* @implemented
*/
VOID STDCALL
-CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
- IN PLARGE_INTEGER FileOffset OPTIONAL,
- IN ULONG Length,
- OUT PIO_STATUS_BLOCK IoStatus)
-{
- PBCB Bcb;
- NTSTATUS Status = STATUS_SUCCESS;
-
- DPRINT("CcFlushCache(SectionObjectPointers 0x%p, FileOffset 0x%p, Length %d,
IoStatus 0x%p)\n",
- SectionObjectPointers, FileOffset, Length, IoStatus);
-
- if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
- {
- Bcb = (PBCB)SectionObjectPointers->SharedCacheMap;
- ASSERT(Bcb);
-
- Status = MmFlushDataFileSection(Bcb->Section, FileOffset, Length);
- }
- if (IoStatus)
- {
- IoStatus->Status = Status;
- IoStatus->Status = STATUS_SUCCESS;
- }
+CcFlushCache (IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
+ IN PLARGE_INTEGER FileOffset OPTIONAL,
+ IN ULONG Length,
+ OUT PIO_STATUS_BLOCK IoStatus)
+{
+ PBCB Bcb;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ DPRINT ("CcFlushCache(SectionObjectPointers 0x%p, FileOffset 0x%p, Length %d,
IoStatus 0x%p)\n",
+ SectionObjectPointers, FileOffset, Length, IoStatus);
+
+ if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
+ {
+ Bcb = (PBCB) SectionObjectPointers->SharedCacheMap;
+ ASSERT (Bcb);
+
+ Status = MmFlushDataFileSection (Bcb->Section, FileOffset, Length);
+ }
+ if (IoStatus)
+ {
+ IoStatus->Status = Status;
+ IoStatus->Status = STATUS_SUCCESS;
+ }
}
/*
* @implemented
*/
PFILE_OBJECT STDCALL
-CcGetFileObjectFromSectionPtrs(IN PSECTION_OBJECT_POINTERS SectionObjectPointers)
-{
- PBCB Bcb;
- if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
- {
- Bcb = (PBCB)SectionObjectPointers->SharedCacheMap;
- ASSERT(Bcb);
- return Bcb->FileObject;
- }
- return NULL;
-}
-
-
-VOID
-INIT_FUNCTION
-NTAPI
-CcInitView(VOID)
-
-{
- NTSTATUS Status;
- PHYSICAL_ADDRESS BoundaryAddressMultiple;
- ULONG i;
- ULONG Size;
- PVOID Base;
-
- DPRINT("CcInitView()\n");
-
- ExInitializeFastMutex(&CcCacheViewLock);
-
- ExInitializeNPagedLookasideList (&iBcbLookasideList,
- NULL,
- NULL,
- 0,
- sizeof(INTERNAL_BCB),
- TAG_IBCB,
- 20);
- ExInitializeNPagedLookasideList (&BcbLookasideList,
- NULL,
- NULL,
- 0,
- sizeof(BCB),
- TAG_BCB,
- 20);
-
- InitializeListHead(&CcFreeCacheViewListHead);
- InitializeListHead(&CcInUseCacheViewListHead);
-
- BoundaryAddressMultiple.QuadPart = 0LL;
-
- Size = MmSystemRangeStart >= (PVOID)0xC0000000 ? 0x18000000 : 0x20000000;
- CcCacheViewBase = (PVOID)(0xF0000000 - Size);
- MmLockAddressSpace(MmGetKernelAddressSpace());
-
- Status = MmCreateMemoryArea(
- MmGetKernelAddressSpace(),
- MEMORY_AREA_CACHE_SEGMENT,
- &CcCacheViewBase,
- Size,
- 0,
- &CcCacheViewMemoryArea,
- FALSE,
- FALSE,
- BoundaryAddressMultiple);
- MmUnlockAddressSpace(MmGetKernelAddressSpace());
- DPRINT1("CcCacheViewBase: %x\n", CcCacheViewBase);
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- CcCacheViewArray = ExAllocatePool(NonPagedPool, sizeof(CACHE_VIEW) * (Size /
CACHE_VIEW_SIZE));
- if (CcCacheViewArray == NULL)
- {
- KEBUGCHECK(0);
- }
-
- Base = CcCacheViewBase;
- CcCacheViewArrayCount = Size / CACHE_VIEW_SIZE;
- for (i = 0; i < CcCacheViewArrayCount; i++)
- {
- CcCacheViewArray[i].BaseAddress = Base;
- CcCacheViewArray[i].RefCount = 0;
- CcCacheViewArray[i].Bcb = NULL;
- CcCacheViewArray[i].SectionData.ViewOffset = 0;
- InsertTailList(&CcFreeCacheViewListHead, &CcCacheViewArray[i].ListEntry);
- Base = (PVOID)((ULONG_PTR)Base + CACHE_VIEW_SIZE);
- }
- CcInitCacheZeroPage();
-
+CcGetFileObjectFromSectionPtrs (IN PSECTION_OBJECT_POINTERS SectionObjectPointers)
+{
+ PBCB Bcb;
+ if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
+ {
+ Bcb = (PBCB) SectionObjectPointers->SharedCacheMap;
+ ASSERT (Bcb);
+ return Bcb->FileObject;
+ }
+ return NULL;
+}
+
+
+VOID INIT_FUNCTION NTAPI
+CcInitView (VOID)
+{
+ NTSTATUS Status;
+ PHYSICAL_ADDRESS BoundaryAddressMultiple;
+ ULONG i;
+ ULONG Size;
+ PVOID Base;
+
+ DPRINT ("CcInitView()\n");
+
+ ExInitializeFastMutex (&CcCacheViewLock);
+
+ ExInitializeNPagedLookasideList (&iBcbLookasideList, NULL, NULL, 0, sizeof
(INTERNAL_BCB), TAG_IBCB, 20);
+ ExInitializeNPagedLookasideList (&BcbLookasideList, NULL, NULL, 0, sizeof (BCB),
TAG_BCB, 20);
+
+ InitializeListHead (&CcFreeCacheViewListHead);
+ InitializeListHead (&CcInUseCacheViewListHead);
+
+ BoundaryAddressMultiple.QuadPart = 0LL;
+
+ Size = MmSystemRangeStart >= (PVOID) 0xC0000000 ? 0x18000000 : 0x20000000;
+ CcCacheViewBase = (PVOID) (0xF0000000 - Size);
+ MmLockAddressSpace (MmGetKernelAddressSpace ());
+
+ Status = MmCreateMemoryArea (MmGetKernelAddressSpace (),
+ MEMORY_AREA_CACHE_SEGMENT,
+ &CcCacheViewBase, Size, 0,
&CcCacheViewMemoryArea, FALSE, FALSE, BoundaryAddressMultiple);
+ MmUnlockAddressSpace (MmGetKernelAddressSpace ());
+ DPRINT1 ("CcCacheViewBase: %x\n", CcCacheViewBase);
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ CcCacheViewArray = ExAllocatePool (NonPagedPool, sizeof (CACHE_VIEW) * (Size /
CACHE_VIEW_SIZE));
+ if (CcCacheViewArray == NULL)
+ {
+ KEBUGCHECK (0);
+ }
+
+ Base = CcCacheViewBase;
+ CcCacheViewArrayCount = Size / CACHE_VIEW_SIZE;
+ for (i = 0; i < CcCacheViewArrayCount; i++)
+ {
+ CcCacheViewArray[i].BaseAddress = Base;
+ CcCacheViewArray[i].RefCount = 0;
+ CcCacheViewArray[i].Bcb = NULL;
+ CcCacheViewArray[i].SectionData.ViewOffset = 0;
+ InsertTailList (&CcFreeCacheViewListHead,
&CcCacheViewArray[i].ListEntry);
+ Base = (PVOID) ((ULONG_PTR) Base + CACHE_VIEW_SIZE);
+ }
+ CcInitCacheZeroPage ();
+
}
VOID STDCALL
-CcInitializeCacheMap(IN PFILE_OBJECT FileObject,
- IN PCC_FILE_SIZES FileSizes,
- IN BOOLEAN PinAccess,
- IN PCACHE_MANAGER_CALLBACKS CallBacks,
- IN PVOID LazyWriterContext)
-{
- PBCB Bcb;
- NTSTATUS Status;
-
- DPRINT("CcInitializeCacheMap(), %wZ\n", &FileObject->FileName);
- DPRINT("%I64x (%I64d)\n", FileSizes->FileSize.QuadPart,
FileSizes->FileSize.QuadPart);
-
- ASSERT (FileObject);
- ASSERT (FileSizes);
-
- ExAcquireFastMutex(&CcCacheViewLock);
-
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
- if (Bcb == NULL)
- {
- Bcb = ExAllocateFromNPagedLookasideList(&BcbLookasideList);
- if (Bcb == NULL)
- {
- KEBUGCHECK(0);
- }
- memset(Bcb, 0, sizeof(BCB));
-
- Bcb->FileObject = FileObject;
- Bcb->FileSizes = *FileSizes;
- Bcb->PinAccess = PinAccess;
- Bcb->CallBacks = CallBacks;
- Bcb->LazyWriterContext = LazyWriterContext;
- Bcb->RefCount = 0;
-
- DPRINT("%x %x\n", FileObject, FileSizes->FileSize.QuadPart);
-
- Status = MmCreateDataFileSection(&Bcb->Section,
- STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
SECTION_MAP_READ | SECTION_MAP_WRITE,
- NULL,
- &Bcb->FileSizes.FileSize,
- PAGE_READWRITE,
- SEC_COMMIT,
- Bcb->FileObject,
- TRUE);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("%x\n", Status);
- KEBUGCHECK(0);
- }
-
- FileObject->SectionObjectPointer->SharedCacheMap = Bcb;
- }
-
- if (FileObject->PrivateCacheMap == NULL)
- {
- FileObject->PrivateCacheMap = Bcb;
- Bcb->RefCount++;
- }
-
- ExReleaseFastMutex(&CcCacheViewLock);
- DPRINT("CcInitializeCacheMap() done\n");
+CcInitializeCacheMap (IN PFILE_OBJECT FileObject,
+ IN PCC_FILE_SIZES FileSizes,
+ IN BOOLEAN PinAccess,
+ IN PCACHE_MANAGER_CALLBACKS CallBacks,
+ IN PVOID LazyWriterContext)
+{
+ PBCB Bcb;
+ NTSTATUS Status;
+
+ DPRINT ("CcInitializeCacheMap(), %wZ\n", &FileObject->FileName);
+ DPRINT ("%I64x (%I64d)\n", FileSizes->FileSize.QuadPart,
FileSizes->FileSize.QuadPart);
+
+ ASSERT (FileObject);
+ ASSERT (FileSizes);
+
+ ExAcquireFastMutex (&CcCacheViewLock);
+
+ Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ if (Bcb == NULL)
+ {
+ Bcb = ExAllocateFromNPagedLookasideList (&BcbLookasideList);
+ if (Bcb == NULL)
+ {
+ KEBUGCHECK (0);
+ }
+ memset (Bcb, 0, sizeof (BCB));
+
+ Bcb->FileObject = FileObject;
+ Bcb->FileSizes = *FileSizes;
+ Bcb->PinAccess = PinAccess;
+ Bcb->CallBacks = CallBacks;
+ Bcb->LazyWriterContext = LazyWriterContext;
+ Bcb->RefCount = 0;
+
+ DPRINT ("%x %x\n", FileObject, FileSizes->FileSize.QuadPart);
+
+ Status = MmCreateDataFileSection (&Bcb->Section,
+ STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
SECTION_MAP_READ | SECTION_MAP_WRITE,
+ NULL, &Bcb->FileSizes.FileSize,
PAGE_READWRITE, SEC_COMMIT, Bcb->FileObject, TRUE);
+ if (!NT_SUCCESS (Status))
+ {
+ DPRINT1 ("%x\n", Status);
+ KEBUGCHECK (0);
+ }
+
+ FileObject->SectionObjectPointer->SharedCacheMap = Bcb;
+ }
+
+ if (FileObject->PrivateCacheMap == NULL)
+ {
+ FileObject->PrivateCacheMap = Bcb;
+ Bcb->RefCount++;
+ }
+
+ ExReleaseFastMutex (&CcCacheViewLock);
+ DPRINT ("CcInitializeCacheMap() done\n");
}
BOOLEAN STDCALL
-CcUninitializeCacheMap (IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER TruncateSize OPTIONAL,
- IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL)
-{
- PBCB Bcb;
- ULONG i;
- NTSTATUS Status;
-
- DPRINT("CcUninitializeCacheMap(), %wZ\n", &FileObject->FileName);
- ExAcquireFastMutex(&CcCacheViewLock);
- Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
- if (Bcb)
- {
- if (FileObject->PrivateCacheMap == Bcb)
- {
- Bcb->RefCount--;
- FileObject->PrivateCacheMap = NULL;
- }
- if (Bcb->RefCount == 0)
- {
- Bcb->RefCount++;
- ExReleaseFastMutex(&CcCacheViewLock);
- MmFlushDataFileSection(Bcb->Section, NULL, 0);
- ExAcquireFastMutex(&CcCacheViewLock);
- Bcb->RefCount--;
- if (Bcb->RefCount == 0)
- {
- for (i = 0; i < ROUND_UP(Bcb->FileSizes.AllocationSize.QuadPart,
CACHE_VIEW_SIZE) / CACHE_VIEW_SIZE; i++)
- {
- if (Bcb->CacheView[i] && Bcb->CacheView[i]->Bcb == Bcb)
- {
- CHECKPOINT;
- if (Bcb->CacheView[i]->RefCount > 0)
- {
- KEBUGCHECK(0);
- }
- Status = MmUnmapViewInSystemCache(Bcb->CacheView[i]);
- if (!NT_SUCCESS(Status))
- {
- KEBUGCHECK(0);
- }
- Bcb->CacheView[i]->RefCount = 0;
- Bcb->CacheView[i]->Bcb = NULL;
- Bcb->CacheView[i] = NULL;
- }
- }
-
- DPRINT("%x\n", Bcb->Section);
- ObDereferenceObject(Bcb->Section);
- FileObject->SectionObjectPointer->SharedCacheMap = NULL;
- ExFreeToNPagedLookasideList(&BcbLookasideList, Bcb);
- }
- }
- }
- DPRINT("CcUninitializeCacheMap() done, %wZ\n",
&FileObject->FileName);
- ExReleaseFastMutex(&CcCacheViewLock);
- return TRUE;
+CcUninitializeCacheMap (IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER TruncateSize OPTIONAL,
+ IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL)
+{
+ PBCB Bcb;
+ ULONG i;
+ NTSTATUS Status;
+
+ DPRINT ("CcUninitializeCacheMap(), %wZ\n", &FileObject->FileName);
+ ExAcquireFastMutex (&CcCacheViewLock);
+ Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
+ if (Bcb)
+ {
+ if (FileObject->PrivateCacheMap == Bcb)
+ {
+ Bcb->RefCount--;
+ FileObject->PrivateCacheMap = NULL;
+ }
+ if (Bcb->RefCount == 0)
+ {
+ Bcb->RefCount++;
+ ExReleaseFastMutex (&CcCacheViewLock);
+ MmFlushDataFileSection (Bcb->Section, NULL, 0);
+ ExAcquireFastMutex (&CcCacheViewLock);
+ Bcb->RefCount--;
+ if (Bcb->RefCount == 0)
+ {
+ for (i = 0; i < ROUND_UP (Bcb->FileSizes.AllocationSize.QuadPart,
CACHE_VIEW_SIZE) / CACHE_VIEW_SIZE; i++)
+ {
+ if (Bcb->CacheView[i] && Bcb->CacheView[i]->Bcb ==
Bcb)
+ {
+ CHECKPOINT;
+ if (Bcb->CacheView[i]->RefCount > 0)
+ {
+ KEBUGCHECK (0);
+ }
+ Status = MmUnmapViewInSystemCache (Bcb->CacheView[i]);
+ if (!NT_SUCCESS (Status))
+ {
+ KEBUGCHECK (0);
+ }
+ Bcb->CacheView[i]->RefCount = 0;
+ Bcb->CacheView[i]->Bcb = NULL;
+ Bcb->CacheView[i] = NULL;
+ }
+ }
+
+ DPRINT ("%x\n", Bcb->Section);
+ ObDereferenceObject (Bcb->Section);
+ FileObject->SectionObjectPointer->SharedCacheMap = NULL;
+ ExFreeToNPagedLookasideList (&BcbLookasideList, Bcb);
+ }
+ }
+ }
+ DPRINT ("CcUninitializeCacheMap() done, %wZ\n",
&FileObject->FileName);
+ ExReleaseFastMutex (&CcCacheViewLock);
+ return TRUE;
}