Author: dcote
Date: Sun Jan 21 07:46:38 2007
New Revision: 25550
URL:
http://svn.reactos.org/svn/reactos?rev=25550&view=rev
Log:
===================================================================
cctypes.h
ntoskrnl/cc/copy.c
===================================================================
Added CcFastMdlReadNotPossible
===================================================================
fastio.c
===================================================================
Added #ifdef to allow the file to compile "as is" in my windows
framework. This doesnt affect RosBE
Brought back Alex's code for
FsRtlMdlReadCompleteDev
FsRtlMdlReadDev
FsRtlMdlReadComplete
after having code reviewed it.
===================================================================
ntoskrnl/include/internal/cc.h
ntoskrnl/cc/mdl.c
===================================================================
Change the name of CcMdlReadCompleteDev to CcMdlReadComplete2
Modified:
trunk/reactos/include/ndk/cctypes.h
trunk/reactos/ntoskrnl/cc/copy.c
trunk/reactos/ntoskrnl/cc/mdl.c
trunk/reactos/ntoskrnl/fsrtl/fastio.c
trunk/reactos/ntoskrnl/include/internal/cc.h
Modified: trunk/reactos/include/ndk/cctypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/cctypes.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/cctypes.h (original)
+++ trunk/reactos/include/ndk/cctypes.h Sun Jan 21 07:46:38 2007
@@ -33,6 +33,7 @@
extern ULONG NTSYSAPI CcFastReadWait;
extern ULONG NTSYSAPI CcFastReadResourceMiss;
extern ULONG NTSYSAPI CcFastReadNoWait;
+extern ULONG NTSYSAPI CcFastMdlReadNotPossible;
#ifdef _NTIFS_INCLUDED_
Modified: trunk/reactos/ntoskrnl/cc/copy.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/copy.c?rev=255…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/copy.c (original)
+++ trunk/reactos/ntoskrnl/cc/copy.c Sun Jan 21 07:46:38 2007
@@ -30,11 +30,11 @@
#endif
ULONG CcFastMdlReadWait;
+ULONG CcFastMdlReadNotPossible;
ULONG CcFastReadNotPossible;
ULONG CcFastReadWait;
ULONG CcFastReadNoWait;
ULONG CcFastReadResourceMiss;
-
/* FUNCTIONS *****************************************************************/
Modified: trunk/reactos/ntoskrnl/cc/mdl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/mdl.c?rev=2555…
==============================================================================
--- trunk/reactos/ntoskrnl/cc/mdl.c (original)
+++ trunk/reactos/ntoskrnl/cc/mdl.c Sun Jan 21 07:46:38 2007
@@ -51,15 +51,15 @@
*/
VOID
STDCALL
-CcMdlReadCompleteDev(IN PMDL MdlChain,
+CcMdlReadComplete2(IN PMDL MemoryDescriptorList,
IN PFILE_OBJECT FileObject)
{
PMDL Mdl;
/* Free MDLs */
- while ((Mdl = MdlChain))
+ while ((Mdl = MemoryDescriptorList))
{
- MdlChain = Mdl->Next;
+ MemoryDescriptorList = Mdl->Next;
MmUnlockPages(Mdl);
IoFreeMdl(Mdl);
}
@@ -103,7 +103,7 @@
}
/* Use slow path */
- CcMdlReadCompleteDev(MdlChain, FileObject);
+ CcMdlReadComplete2(MdlChain, FileObject);
}
/*
Modified: trunk/reactos/ntoskrnl/fsrtl/fastio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/fastio.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/fsrtl/fastio.c (original)
+++ trunk/reactos/ntoskrnl/fsrtl/fastio.c Sun Jan 21 07:46:38 2007
@@ -8,11 +8,18 @@
/* INCLUDES ******************************************************************/
+#ifdef _WINDOWS_TESTING
+#include <ntifs.h>
+#include "ntndk.h"
+#include "fsrtl_glue.h"
+#else
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
#include <ntifs.h>
#include <cctypes.h>
+#endif /* _WINDOWS_TESTING */
+
/* PUBLIC FUNCTIONS **********************************************************/
@@ -708,30 +715,56 @@
return FALSE;
}
-/*
- * @implemented
- */
BOOLEAN
NTAPI
FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject,
IN OUT PMDL MdlChain)
{
- KEBUGCHECK(0);
- return FALSE;
-}
-
-/*
- * @implemented
- */
-BOOLEAN
-NTAPI
+ PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ 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 */
+ return FastDispatch->MdlReadComplete(FileObject,
+ MdlChain,
+ DeviceObject);
+ }
+
+ /* Get the Base File System (Volume) and Fast Calls */
+ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
+ FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
+
+ /* If the Base Device Object has its own FastDispatch Routine, fail */
+ if ((BaseDeviceObject != DeviceObject) && FastDispatch
+ && FastDispatch->MdlReadComplete)
+ {
+ return FALSE;
+ }
+
+ /* No fast path, use slow path */
+ return FsRtlMdlReadCompleteDev(FileObject, MdlChain, DeviceObject);
+}
+
+/*
+ * @implemented
+ */
+ BOOLEAN
+ NTAPI
FsRtlMdlReadCompleteDev(IN PFILE_OBJECT FileObject,
- IN PMDL MdlChain,
+ IN PMDL MemoryDescriptorList,
IN PDEVICE_OBJECT DeviceObject)
{
- KEBUGCHECK(0);
- return FALSE;
-}
+ /* Call the Cache Manager */
+ CcMdlReadComplete2(MemoryDescriptorList, FileObject);
+ return TRUE;
+}
+
/*
* @implemented
@@ -746,8 +779,114 @@
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject)
{
- KEBUGCHECK(0);
- return FALSE;
+ PFSRTL_COMMON_FCB_HEADER FcbHeader;
+ BOOLEAN Result = TRUE;
+ LARGE_INTEGER Offset;
+ PFAST_IO_DISPATCH FastIoDispatch;
+ PDEVICE_OBJECT Device;
+ PAGED_CODE();
+
+ /* No actual read */
+ if (!Length)
+ {
+ /* Return success */
+ IoStatus->Status = STATUS_SUCCESS;
+ IoStatus->Information = 0;
+ return TRUE;
+ }
+
+ /* Sanity check */
+ ASSERT(MAXLONGLONG - FileOffset->QuadPart >= (LONGLONG)Length);
+
+ /* Get the offset and FCB header */
+ Offset.QuadPart = FileOffset->QuadPart + Length;
+ FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext;
+
+ /* Enter the FS */
+ FsRtlEnterFileSystem();
+ CcFastMdlReadWait++;
+
+ /* Lock the FCB */
+ ExAcquireResourceShared(FcbHeader->Resource, TRUE);
+
+ /* Check if this is a fast I/O cached file */
+ if (!(FileObject->PrivateCacheMap) ||
+ (FcbHeader->IsFastIoPossible == FastIoIsNotPossible))
+ {
+ /* It's not, so fail */
+ CcFastMdlReadNotPossible += 1;
+ Result = FALSE;
+ goto Cleanup;
+ }
+
+ /* Check if we need to find out if fast I/O is available */
+ if (FcbHeader->IsFastIoPossible == FastIoIsQuestionable)
+ {
+ /* Get the Fast I/O table */
+ Device = IoGetRelatedDeviceObject(FileObject);
+ FastIoDispatch = Device->DriverObject->FastIoDispatch;
+
+ /* Sanity check */
+ ASSERT(!KeIsExecutingDpc());
+ ASSERT(FastIoDispatch != NULL);
+ ASSERT(FastIoDispatch->FastIoCheckIfPossible != NULL);
+
+ /* Ask the driver if we can do it */
+ if (!FastIoDispatch->FastIoCheckIfPossible(FileObject,
+ FileOffset,
+ Length,
+ TRUE,
+ LockKey,
+ TRUE,
+ IoStatus,
+ Device))
+ {
+ /* It's not, fail */
+ CcFastMdlReadNotPossible += 1;
+ Result = FALSE;
+ goto Cleanup;
+ }
+ }
+
+ /* Check if we read too much */
+ if (Offset.QuadPart > FcbHeader->FileSize.QuadPart)
+ {
+ /* We did, check if the file offset is past the end */
+ if (FileOffset->QuadPart >= FcbHeader->FileSize.QuadPart)
+ {
+ /* Set end of file */
+ IoStatus->Status = STATUS_END_OF_FILE;
+ IoStatus->Information = 0;
+ goto Cleanup;
+ }
+
+ /* Otherwise, just normalize the length */
+ Length = (ULONG)(FcbHeader->FileSize.QuadPart - FileOffset->QuadPart);
+ }
+
+ /* Set this as top-level IRP */
+ PsGetCurrentThread()->TopLevelIrp = FSRTL_FAST_IO_TOP_LEVEL_IRP;
+
+ _SEH_TRY
+ {
+ /* Attempt a read */
+ CcMdlRead(FileObject, FileOffset, Length, MdlChain, IoStatus);
+ FileObject->Flags |= FO_FILE_FAST_IO_READ;
+ }
+ _SEH_EXCEPT(FsRtlCcCopyFilter)
+ {
+ Result = FALSE;
+ } _SEH_END;
+
+
+ /* Remove the top-level IRP flag */
+ PsGetCurrentThread()->TopLevelIrp = 0;
+
+ /* Return to caller */
+Cleanup:
+ ExReleaseResourceLite(FcbHeader->Resource);
+ FsRtlExitFileSystem();
+ return Result;
}
/*
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/cc.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/cc.h Sun Jan 21 07:46:38 2007
@@ -63,8 +63,8 @@
VOID
NTAPI
-CcMdlReadCompleteDev(
- IN PMDL MdlChain,
+CcMdlReadComplete2(
+ IN PMDL MemoryDescriptorList,
IN PFILE_OBJECT FileObject
);