Author: fireball
Date: Sat Mar 8 17:47:41 2008
New Revision: 32612
URL:
http://svn.reactos.org/svn/reactos?rev=3D32612&view=3Drev
Log:
- Experimentally switch fastfat driver to non-Ros Cc functions, and thus no=
FSD in ReactOS are using CcRos-specific functions anymore.
- Assume VACB_MAPPING_GRANULARITY as a default cache segment size.
- Use FSD callbacks instead of direct accessing FCB's MainResource via File=
Object/FsContext. This allows removing of ObReferenceObject(FileObject) whi=
ch I had to add some time ago in order to keep FileObject alive for the laz=
y writer thread.
- IMPORTANT: Testers should thoroughly try this revision in order to see if=
any new problems appear. If they do appear, this revision will most probab=
ly be reverted by me.
Modified:
trunk/reactos/drivers/filesystems/fastfat/cleanup.c
trunk/reactos/drivers/filesystems/fastfat/fcb.c
trunk/reactos/drivers/filesystems/fastfat/fsctl.c
trunk/reactos/drivers/filesystems/fastfat/rw.c
trunk/reactos/ntoskrnl/cc/fs.c
trunk/reactos/ntoskrnl/cc/view.c
trunk/reactos/ntoskrnl/include/internal/cc.h
trunk/reactos/ntoskrnl/ntoskrnl_i386.def
Modified: trunk/reactos/drivers/filesystems/fastfat/cleanup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/f=
astfat/cleanup.c?rev=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/filesystems/fastfat/cleanup.c (original)
+++ trunk/reactos/drivers/filesystems/fastfat/cleanup.c Sat Mar 8 17:47:41=
2008
@@ -78,11 +78,7 @@
if (tmpFileObject !=3D NULL)
{
pFcb->FileObject =3D NULL;
-#ifdef USE_ROS_CC_AND_FS
- CcRosReleaseFileCache(tmpFileObject);
-#else
CcUninitializeCacheMap(tmpFileObject, NULL, NULL);
-#endif
ObDereferenceObject(tmpFileObject);
}
=
@@ -94,14 +90,10 @@
#endif
}
/* Uninitialize file cache if. */
-#ifdef USE_ROS_CC_AND_FS
- CcRosReleaseFileCache (FileObject);
-#else
if (FileObject->SectionObjectPointer->SharedCacheMap)
{
CcUninitializeCacheMap (FileObject, &pFcb->RFCB.FileSize, NULL=
);
}
-#endif
if (pFcb->OpenHandleCount !=3D 0)
{
IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
Modified: trunk/reactos/drivers/filesystems/fastfat/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/f=
astfat/fcb.c?rev=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/filesystems/fastfat/fcb.c (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fcb.c Sat Mar 8 17:47:41 2008
@@ -314,10 +314,6 @@
static NTSTATUS
vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
{
-#ifdef USE_ROS_CC_AND_FS
- NTSTATUS status;
- ULONG fileCacheQuantum;
-#endif
PFILE_OBJECT fileObject;
PVFATCCB newCCB;
=
@@ -336,25 +332,12 @@
fcb->FileObject =3D fileObject;
fcb->RefCount++;
=
-#ifdef USE_ROS_CC_AND_FS
- fileCacheQuantum =3D (vcb->FatInfo.BytesPerCluster >=3D PAGE_SIZE) ?
- vcb->FatInfo.BytesPerCluster : PAGE_SIZE;
-
- status =3D CcRosInitializeFileCache (fileObject,
- fileCacheQuantum);
- if (!NT_SUCCESS (status))
- {
- DbgPrint ("CcRosInitializeFileCache failed\n");
- KEBUGCHECK (0);
- }
-#else
/* FIXME: Guard by SEH. */
CcInitializeCacheMap(fileObject,
(PCC_FILE_SIZES)(&fcb->RFCB.AllocationSize),
FALSE,
&VfatGlobalData->CacheMgrCallbacks,
fcb);
-#endif
=
fcb->Flags |=3D FCB_CACHE_INITIALIZED;
return STATUS_SUCCESS;
Modified: trunk/reactos/drivers/filesystems/fastfat/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/f=
astfat/fsctl.c?rev=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/filesystems/fastfat/fsctl.c (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fsctl.c Sat Mar 8 17:47:41 2=
008
@@ -534,28 +534,13 @@
Fcb->RFCB.ValidDataLength =3D Fcb->RFCB.FileSize;
Fcb->RFCB.AllocationSize =3D Fcb->RFCB.FileSize;
=
-#ifdef USE_ROS_CC_AND_FS
- if (DeviceExt->FatInfo.FatType !=3D FAT12)
- {
- Status =3D CcRosInitializeFileCache(DeviceExt->FATFileObject, CACHEP=
AGESIZE(DeviceExt));
- }
- else
- {
- Status =3D CcRosInitializeFileCache(DeviceExt->FATFileObject, 2 * PA=
GE_SIZE);
- }
- if (!NT_SUCCESS (Status))
- {
- DPRINT1 ("CcRosInitializeFileCache failed\n");
- goto ByeBye;
- }
-#else
/* FIXME: Guard by SEH. */
CcInitializeCacheMap(DeviceExt->FATFileObject,
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
FALSE,
&VfatGlobalData->CacheMgrCallbacks,
Fcb);
-#endif
+
DeviceExt->LastAvailableCluster =3D 2;
ExInitializeResourceLite(&DeviceExt->DirResource);
ExInitializeResourceLite(&DeviceExt->FatResource);
Modified: trunk/reactos/drivers/filesystems/fastfat/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/f=
astfat/rw.c?rev=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/filesystems/fastfat/rw.c (original)
+++ trunk/reactos/drivers/filesystems/fastfat/rw.c Sat Mar 8 17:47:41 2008
@@ -671,19 +671,12 @@
CHECKPOINT;
if (IrpContext->FileObject->PrivateCacheMap =3D=3D NULL)
{
-#ifdef USE_ROS_CC_AND_FS
- ULONG CacheSize;
- CacheSize =3D max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
- 8 * PAGE_SIZE);
- CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
-#else
/* FIXME: Guard by SEH. */
CcInitializeCacheMap(IrpContext->FileObject,
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
FALSE,
&(VfatGlobalData->CacheMgrCallbacks),
Fcb);
-#endif
}
if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length,
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT), B=
uffer,
@@ -972,19 +965,12 @@
=
if (IrpContext->FileObject->PrivateCacheMap =3D=3D NULL)
{
-#ifdef USE_ROS_CC_AND_FS
- ULONG CacheSize;
- CacheSize =3D max(IrpContext->DeviceExt->FatInfo.BytesPerCluster,
- 8 * PAGE_SIZE);
- CcRosInitializeFileCache(IrpContext->FileObject, CacheSize);
-#else
/* FIXME: Guard by SEH. */
CcInitializeCacheMap(IrpContext->FileObject,
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
FALSE,
&VfatGlobalData->CacheMgrCallbacks,
Fcb);
-#endif
}
if (ByteOffset.QuadPart > OldFileSize.QuadPart)
{
Modified: trunk/reactos/ntoskrnl/cc/fs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/fs.c?rev=
=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/cc/fs.c (original)
+++ trunk/reactos/ntoskrnl/cc/fs.c Sat Mar 8 17:47:41 2008
@@ -92,7 +92,8 @@
=
/* Call old ROS cache init function */
CcRosInitializeFileCache(FileObject,
- PAGE_SIZE/*VACB_MAPPING_GRANULARITY*/);
+ /*PAGE_SIZE*/ VACB_MAPPING_GRANULARITY, CallBacks,
+ LazyWriterContext);
}
=
/*
Modified: trunk/reactos/ntoskrnl/cc/view.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?re=
v=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/cc/view.c (original)
+++ trunk/reactos/ntoskrnl/cc/view.c Sat Mar 8 17:47:41 2008
@@ -238,23 +238,19 @@
DirtySegmentListEntry);
current_entry =3D current_entry->Flink;
=
- /* This Ros-specific function needs FileObject to be referenced,
- ohterwise it may be deleted while this function still works
- with it */
- ObReferenceObject(current->Bcb->FileObject);
-
- Locked =3D ExTryToAcquireResourceExclusiveLite(((FSRTL_COMMON_FCB_=
HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
+ Locked =3D current->Bcb->Callbacks->AcquireForLazyWrite(
+ current->Bcb->LazyWriteContext, FALSE);
if (!Locked)
{
- ObDereferenceObject(current->Bcb->FileObject);
continue;
}
=
Locked =3D ExTryToAcquirePushLockExclusive(¤t->Lock);
if (!Locked)
{
- ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb=
->FileObject->FsContext))->Resource);
- ObDereferenceObject(current->Bcb->FileObject);
+ current->Bcb->Callbacks->ReleaseFromLazyWrite(
+ current->Bcb->LazyWriteContext);
+
continue;
}
=
@@ -262,20 +258,20 @@
if (current->ReferenceCount > 1)
{
ExReleasePushLock(¤t->Lock);
- ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb=
->FileObject->FsContext))->Resource);
- ObDereferenceObject(current->Bcb->FileObject);
+ current->Bcb->Callbacks->ReleaseFromLazyWrite(
+ current->Bcb->LazyWriteContext);
continue;
}
=
PagesPerSegment =3D current->Bcb->CacheSegmentSize / PAGE_SIZE;
=
KeReleaseGuardedMutex(&ViewLock);
- =
+
Status =3D CcRosFlushCacheSegment(current);
=
ExReleasePushLock(¤t->Lock);
- ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->Fi=
leObject->FsContext))->Resource);
- ObDereferenceObject(current->Bcb->FileObject);
+ current->Bcb->Callbacks->ReleaseFromLazyWrite(
+ current->Bcb->LazyWriteContext);
=
if (!NT_SUCCESS(Status) && (Status !=3D STATUS_END_OF_FILE))
{
@@ -711,7 +707,7 @@
KEBUGCHECKCC;
}
#endif
- Pfn =3D alloca(sizeof(PFN_TYPE) * (Bcb->CacheSegmentSize / PAGE_SIZE));
+ Pfn =3D alloca(sizeof(PFN_TYPE) * ((Bcb->CacheSegmentSize / PAGE_SIZE)));
for (i =3D 0; i < (Bcb->CacheSegmentSize / PAGE_SIZE); i++)
{
Status =3D MmRequestPageMemoryConsumer(MC_CACHE, TRUE, &Pfn[i]);
@@ -729,6 +725,7 @@
{
KEBUGCHECKCC;
}
+
return(STATUS_SUCCESS);
}
=
@@ -1259,9 +1256,11 @@
}
=
=
-NTSTATUS STDCALL
+NTSTATUS NTAPI
CcRosInitializeFileCache(PFILE_OBJECT FileObject,
- ULONG CacheSegmentSize)
+ ULONG CacheSegmentSize,
+ PCACHE_MANAGER_CALLBACKS CallBacks,
+ PVOID LazyWriterContext)
/*
* FUNCTION: Initializes a BCB for a file object
*/
@@ -1275,39 +1274,41 @@
KeAcquireGuardedMutex(&ViewLock);
if (Bcb =3D=3D NULL)
{
- Bcb =3D ExAllocateFromNPagedLookasideList(&BcbLookasideList);
- if (Bcb =3D=3D NULL)
- {
- KeReleaseGuardedMutex(&ViewLock);
- return(STATUS_UNSUCCESSFUL);
- }
- memset(Bcb, 0, sizeof(BCB));
- ObReferenceObjectByPointer(FileObject,
- FILE_ALL_ACCESS,
- NULL,
- KernelMode);
- Bcb->FileObject =3D FileObject;
- Bcb->CacheSegmentSize =3D CacheSegmentSize;
- if (FileObject->FsContext)
- {
- Bcb->AllocationSize =3D
- ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->AllocationSize;
- Bcb->FileSize =3D
- ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize;
- }
- KeInitializeSpinLock(&Bcb->BcbLock);
- InitializeListHead(&Bcb->BcbSegmentListHead);
- FileObject->SectionObjectPointer->SharedCacheMap =3D Bcb;
+ Bcb =3D ExAllocateFromNPagedLookasideList(&BcbLookasideList);
+ if (Bcb =3D=3D NULL)
+ {
+ KeReleaseGuardedMutex(&ViewLock);
+ return(STATUS_UNSUCCESSFUL);
+ }
+ memset(Bcb, 0, sizeof(BCB));
+ ObReferenceObjectByPointer(FileObject,
+ FILE_ALL_ACCESS,
+ NULL,
+ KernelMode);
+ Bcb->FileObject =3D FileObject;
+ Bcb->CacheSegmentSize =3D CacheSegmentSize;
+ Bcb->Callbacks =3D CallBacks;
+ Bcb->LazyWriteContext =3D LazyWriterContext;
+ if (FileObject->FsContext)
+ {
+ Bcb->AllocationSize =3D
+ ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->Allocati=
onSize;
+ Bcb->FileSize =3D
+ ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize;
+ }
+ KeInitializeSpinLock(&Bcb->BcbLock);
+ InitializeListHead(&Bcb->BcbSegmentListHead);
+ FileObject->SectionObjectPointer->SharedCacheMap =3D Bcb;
}
if (FileObject->PrivateCacheMap =3D=3D NULL)
{
- FileObject->PrivateCacheMap =3D Bcb;
- Bcb->RefCount++;
+ FileObject->PrivateCacheMap =3D Bcb;
+ Bcb->RefCount++;
}
if (Bcb->BcbRemoveListEntry.Flink !=3D NULL)
{
- RemoveEntryList(&Bcb->BcbRemoveListEntry);
- Bcb->BcbRemoveListEntry.Flink =3D NULL;
+ RemoveEntryList(&Bcb->BcbRemoveListEntry);
+ Bcb->BcbRemoveListEntry.Flink =3D NULL;
}
KeReleaseGuardedMutex(&ViewLock);
=
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/inte=
rnal/cc.h?rev=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/include/internal/cc.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/cc.h Sat Mar 8 17:47:41 2008
@@ -112,6 +112,8 @@
ULONG CacheSegmentSize;
LARGE_INTEGER AllocationSize;
LARGE_INTEGER FileSize;
+ PCACHE_MANAGER_CALLBACKS Callbacks;
+ PVOID LazyWriteContext;
KSPIN_LOCK BcbLock;
ULONG RefCount;
#if defined(DBG) || defined(KDBG)
Modified: trunk/reactos/ntoskrnl/ntoskrnl_i386.def
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl_i38=
6.def?rev=3D32612&r1=3D32611&r2=3D32612&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/ntoskrnl_i386.def (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl_i386.def Sat Mar 8 17:47:41 2008
@@ -5,7 +5,7 @@
; ReactOS Operating System
;
EXPORTS
-CcRosInitializeFileCache@8
+CcRosInitializeFileCache
CcRosReleaseFileCache@4
CcRosTraceCacheMap@8
CcCanIWrite@16