mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
2002-12-15 Casper S. Hornstrup <chorns@users.sourceforge.net>
* drivers/fs/vfat/cleanup.c (VfatCleanupFile): Only uninitialize caching when initialized. * drivers/fs/vfat/fcb.c (vfatReleaseFCB): Ditto. * lib/kernel32/mem/section.c (CreateFileMappingW): Pass NULL as MaximumSize to NtCreateSection if dwMaximumSizeHigh and dwMaximumSizeLow are both 0. * ntoskrnl/cc/pin.c (CcMapData): Assert if Bcb is NULL. * ntoskrnl/cc/view.c (CcRosReleaseCacheSegment, CcRosLookupCacheSegment, CcRosMarkDirtyCacheSegment, CcRosUnmapCacheSegment, CcRosCreateCacheSegment, CcRosGetCacheSegmentChain, CcRosGetCacheSegment, CcRosRequestCacheSegment, CcFlushCache, CcRosDeleteFileCache, CcRosReferenceCache, CcRosDereferenceCache, CcRosReleaseFileCache, CcGetFileObjectFromSectionPtrs): Ditto. * ntoskrnl/mm/section.c (MiReadPage): Assert if Fcb->Bcb is NULL. (MmCreateDataFileSection): Make sure caching is initialized for the file stream. svn path=/trunk/; revision=3879
This commit is contained in:
parent
d774049979
commit
3aa9d2d9ba
7 changed files with 101 additions and 14 deletions
|
@ -1,3 +1,22 @@
|
|||
2002-12-15 Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
|
||||
* drivers/fs/vfat/cleanup.c (VfatCleanupFile): Only uninitialize caching
|
||||
when initialized.
|
||||
* drivers/fs/vfat/fcb.c (vfatReleaseFCB): Ditto.
|
||||
* lib/kernel32/mem/section.c (CreateFileMappingW): Pass NULL as
|
||||
MaximumSize to NtCreateSection if dwMaximumSizeHigh and dwMaximumSizeLow
|
||||
are both 0.
|
||||
* ntoskrnl/cc/pin.c (CcMapData): Assert if Bcb is NULL.
|
||||
* ntoskrnl/cc/view.c (CcRosReleaseCacheSegment, CcRosLookupCacheSegment,
|
||||
CcRosMarkDirtyCacheSegment, CcRosUnmapCacheSegment,
|
||||
CcRosCreateCacheSegment, CcRosGetCacheSegmentChain,
|
||||
CcRosGetCacheSegment, CcRosRequestCacheSegment, CcFlushCache,
|
||||
CcRosDeleteFileCache, CcRosReferenceCache, CcRosDereferenceCache,
|
||||
CcRosReleaseFileCache, CcGetFileObjectFromSectionPtrs): Ditto.
|
||||
* ntoskrnl/mm/section.c (MiReadPage): Assert if Fcb->Bcb is NULL.
|
||||
(MmCreateDataFileSection): Make sure caching is initialized for the file
|
||||
stream.
|
||||
|
||||
2002-11-15 Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
|
||||
* include/ddk/ldrtypes.h: Move ...
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cleanup.c,v 1.7 2002/08/14 20:58:31 dwelch Exp $
|
||||
/* $Id: cleanup.c,v 1.8 2002/12/15 17:01:51 chorns Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -48,8 +48,11 @@ VfatCleanupFile(PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
}
|
||||
|
||||
/* Uninitialize the file cache. */
|
||||
CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
|
||||
/* Uninitialize file cache if initialized for this file object. */
|
||||
if (pFcb->RFCB.Bcb != NULL)
|
||||
{
|
||||
CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: fcb.c,v 1.22 2002/11/11 21:49:18 hbirr Exp $
|
||||
/* $Id: fcb.c,v 1.23 2002/12/15 17:01:51 chorns Exp $
|
||||
*
|
||||
*
|
||||
* FILE: fcb.c
|
||||
|
@ -149,7 +149,11 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
|
|||
KeReleaseSpinLock (&pVCB->FcbListLock, oldIrql);
|
||||
if (vfatFCBIsDirectory(pFCB))
|
||||
{
|
||||
CcRosReleaseFileCache(pFCB->FileObject, pFCB->RFCB.Bcb);
|
||||
/* Uninitialize file cache if initialized for this file object. */
|
||||
if (pFCB->RFCB.Bcb != NULL)
|
||||
{
|
||||
CcRosReleaseFileCache(pFCB->FileObject, pFCB->RFCB.Bcb);
|
||||
}
|
||||
vfatDestroyCCB(pFCB->FileObject->FsContext2);
|
||||
pFCB->FileObject->FsContext2 = NULL;
|
||||
ObDereferenceObject(pFCB->FileObject);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: section.c,v 1.16 2002/09/08 10:22:43 chorns Exp $
|
||||
/* $Id: section.c,v 1.17 2002/12/15 17:01:51 chorns Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -82,6 +82,7 @@ CreateFileMappingW(HANDLE hFile,
|
|||
NTSTATUS Status;
|
||||
HANDLE SectionHandle;
|
||||
LARGE_INTEGER MaximumSize;
|
||||
PLARGE_INTEGER MaximumSizePointer;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING UnicodeName;
|
||||
PSECURITY_DESCRIPTOR SecurityDescriptor;
|
||||
|
@ -95,8 +96,16 @@ CreateFileMappingW(HANDLE hFile,
|
|||
SecurityDescriptor = NULL;
|
||||
}
|
||||
|
||||
MaximumSize.u.LowPart = dwMaximumSizeLow;
|
||||
MaximumSize.u.HighPart = dwMaximumSizeHigh;
|
||||
if ((dwMaximumSizeLow == 0) && (dwMaximumSizeHigh == 0))
|
||||
{
|
||||
MaximumSizePointer = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaximumSize.u.LowPart = dwMaximumSizeLow;
|
||||
MaximumSize.u.HighPart = dwMaximumSizeHigh;
|
||||
MaximumSizePointer = &MaximumSize;
|
||||
}
|
||||
RtlInitUnicodeString(&UnicodeName,
|
||||
lpName);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
|
@ -107,7 +116,7 @@ CreateFileMappingW(HANDLE hFile,
|
|||
Status = NtCreateSection(&SectionHandle,
|
||||
SECTION_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
&MaximumSize,
|
||||
MaximumSizePointer,
|
||||
flProtect,
|
||||
0,
|
||||
hFile);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: pin.c,v 1.8 2002/10/02 19:23:42 hbirr Exp $
|
||||
/* $Id: pin.c,v 1.9 2002/12/15 17:01:52 chorns Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -57,7 +57,8 @@ CcMapData (IN PFILE_OBJECT FileObject,
|
|||
|
||||
ReadOffset = FileOffset->QuadPart;
|
||||
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("AllocationSize %d, FileSize %d\n",
|
||||
(ULONG)Bcb->AllocationSize.QuadPart,
|
||||
(ULONG)Bcb->FileSize.QuadPart);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: view.c,v 1.53 2002/10/02 19:20:51 hbirr Exp $
|
||||
/* $Id: view.c,v 1.54 2002/12/15 17:01:52 chorns Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/cc/view.c
|
||||
|
@ -227,6 +227,8 @@ CcRosReleaseCacheSegment(PBCB Bcb,
|
|||
BOOLEAN WasDirty = CacheSeg->Dirty;
|
||||
KIRQL oldIrql;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcReleaseCacheSegment(Bcb %x, CacheSeg %x, Valid %d)\n",
|
||||
Bcb, CacheSeg, Valid);
|
||||
|
||||
|
@ -268,6 +270,8 @@ PCACHE_SEGMENT CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset)
|
|||
PCACHE_SEGMENT current;
|
||||
KIRQL oldIrql;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosLookupCacheSegment(Bcb %x, FileOffset %d)\n", Bcb, FileOffset);
|
||||
|
||||
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
|
||||
|
@ -295,6 +299,8 @@ CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
|
|||
PCACHE_SEGMENT CacheSeg;
|
||||
KIRQL oldIrql;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosMarkDirtyCacheSegment(Bcb %x, FileOffset %d)\n", Bcb, FileOffset);
|
||||
|
||||
CacheSeg = CcRosLookupCacheSegment(Bcb, FileOffset);
|
||||
|
@ -330,6 +336,8 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
|
|||
BOOLEAN WasDirty;
|
||||
KIRQL oldIrql;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosUnmapCacheSegment(Bcb %x, FileOffset %d, NowDirty %d)\n",
|
||||
Bcb, FileOffset, NowDirty);
|
||||
|
||||
|
@ -380,6 +388,8 @@ CcRosCreateCacheSegment(PBCB Bcb,
|
|||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosCreateCacheSegment()\n");
|
||||
|
||||
current = ExAllocatePoolWithTag(NonPagedPool, sizeof(CACHE_SEGMENT),
|
||||
|
@ -487,6 +497,8 @@ CcRosGetCacheSegmentChain(PBCB Bcb,
|
|||
PCACHE_SEGMENT* CacheSegList;
|
||||
PCACHE_SEGMENT Previous = NULL;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosGetCacheSegmentChain()\n");
|
||||
|
||||
Length = ROUND_UP(Length, Bcb->CacheSegmentSize);
|
||||
|
@ -542,6 +554,8 @@ CcRosGetCacheSegment(PBCB Bcb,
|
|||
PCACHE_SEGMENT current;
|
||||
NTSTATUS Status;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosGetCacheSegment()\n");
|
||||
|
||||
/*
|
||||
|
@ -582,6 +596,8 @@ CcRosRequestCacheSegment(PBCB Bcb,
|
|||
{
|
||||
ULONG BaseOffset;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
if ((FileOffset % Bcb->CacheSegmentSize) != 0)
|
||||
{
|
||||
CPRINT("Bad fileoffset %x should be multiple of %x",
|
||||
|
@ -634,6 +650,8 @@ CcRosFreeCacheSegment(PBCB Bcb, PCACHE_SEGMENT CacheSeg)
|
|||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosFreeCacheSegment(Bcb %x, CacheSeg %x)\n",
|
||||
Bcb, CacheSeg);
|
||||
|
||||
|
@ -671,6 +689,7 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
|
|||
if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
|
||||
{
|
||||
Bcb = (PBCB)SectionObjectPointers->SharedCacheMap;
|
||||
assert(Bcb);
|
||||
if (FileOffset)
|
||||
{
|
||||
Offset = *FileOffset;
|
||||
|
@ -739,6 +758,8 @@ CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
|
|||
LIST_ENTRY FreeList;
|
||||
KIRQL oldIrql;
|
||||
|
||||
assert(Bcb);
|
||||
|
||||
DPRINT("CcRosDeleteFileCache(FileObject %x, Bcb %x)\n",
|
||||
Bcb->FileObject, Bcb);
|
||||
|
||||
|
@ -792,6 +813,7 @@ VOID CcRosReferenceCache(PFILE_OBJECT FileObject)
|
|||
PBCB Bcb;
|
||||
ExAcquireFastMutex(&ViewLock);
|
||||
Bcb = (PBCB)FileObject->SectionObjectPointers->SharedCacheMap;
|
||||
assert(Bcb);
|
||||
Bcb->RefCount++;
|
||||
ExReleaseFastMutex(&ViewLock);
|
||||
}
|
||||
|
@ -801,6 +823,7 @@ VOID CcRosDereferenceCache(PFILE_OBJECT FileObject)
|
|||
PBCB Bcb;
|
||||
ExAcquireFastMutex(&ViewLock);
|
||||
Bcb = (PBCB)FileObject->SectionObjectPointers->SharedCacheMap;
|
||||
assert(Bcb);
|
||||
Bcb->RefCount--;
|
||||
if (Bcb->RefCount == 0)
|
||||
{
|
||||
|
@ -816,6 +839,8 @@ CcRosReleaseFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
|
|||
* has been closed.
|
||||
*/
|
||||
{
|
||||
assert(Bcb);
|
||||
|
||||
ExAcquireFastMutex(&ViewLock);
|
||||
|
||||
if (FileObject->SectionObjectPointers->SharedCacheMap != NULL)
|
||||
|
@ -889,6 +914,7 @@ CcGetFileObjectFromSectionPtrs(IN PSECTION_OBJECT_POINTERS SectionObjectPointers
|
|||
if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
|
||||
{
|
||||
Bcb = (PBCB)SectionObjectPointers->SharedCacheMap;
|
||||
assert(Bcb);
|
||||
return Bcb->FileObject;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: section.c,v 1.101 2002/11/10 18:17:42 chorns Exp $
|
||||
/* $Id: section.c,v 1.102 2002/12/15 17:01:52 chorns Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/section.c
|
||||
|
@ -329,6 +329,8 @@ MiReadPage(PMEMORY_AREA MemoryArea,
|
|||
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
|
||||
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
|
||||
|
||||
assert(Fcb->Bcb);
|
||||
|
||||
/*
|
||||
* If the file system is letting us go directly to the cache and the
|
||||
* memory area was mapped at an offset in the file which is page aligned
|
||||
|
@ -2044,6 +2046,9 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
|
|||
PFILE_OBJECT FileObject;
|
||||
PMM_SECTION_SEGMENT Segment;
|
||||
ULONG FileAccess;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
LARGE_INTEGER Offset;
|
||||
CHAR Buffer;
|
||||
|
||||
/*
|
||||
* Check the protection
|
||||
|
@ -2053,7 +2058,27 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
|
|||
{
|
||||
return(STATUS_INVALID_PAGE_PROTECTION);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read a bit so caching is initiated for the file object.
|
||||
* This is only needed because MiReadPage currently cannot
|
||||
* handle non-cached streams.
|
||||
*/
|
||||
Offset.QuadPart = 0;
|
||||
Status = ZwReadFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&Iosb,
|
||||
&Buffer,
|
||||
sizeof (Buffer),
|
||||
&Offset,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the section
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue