Author: fireball
Date: Thu Aug 29 22:07:24 2013
New Revision: 59889
URL:
http://svn.reactos.org/svn/reactos?rev=59889&view=rev
Log:
[NTOS]
- Implement two types of FsRtl locking functions: exclusive lock and Cc flushing lock,
along with their releasing counterparts, without the filter callbacks support. These
functions are unused in trunk now but would be needed by proper Cc/Mm/IFS in future.
Modified:
trunk/reactos/ntoskrnl/fsrtl/fastio.c
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 [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/fsrtl/fastio.c [iso-8859-1] Thu Aug 29 22:07:24 2013
@@ -4,6 +4,7 @@
* FILE: ntoskrnl/fsrtl/fastio.c
* PURPOSE: Provides Fast I/O entrypoints to the Cache Manager
* PROGRAMMERS: buzdelabuz2@gmail.com,alex.ionescu@reactos.org
+ * Aleksey Bragin <aleksey(a)reactos.org>
*/
/* INCLUDES ******************************************************************/
@@ -1558,6 +1559,40 @@
return Result;
}
+NTSTATUS
+NTAPI
+FsRtlAcquireFileExclusiveCommon(IN PFILE_OBJECT FileObject,
+ IN FS_FILTER_SECTION_SYNC_TYPE SyncType,
+ IN ULONG Reserved)
+{
+ PFSRTL_COMMON_FCB_HEADER FcbHeader;
+ PDEVICE_OBJECT DeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext;
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Get master FsRtl lock */
+ FsRtlEnterFileSystem();
+
+ /* Check if Fast Calls are supported, and check AcquireFileForNtCreateSection */
+ if (FastDispatch &&
+ FastDispatch->AcquireFileForNtCreateSection)
+ {
+ /* Call the AcquireFileForNtCreateSection FastIo handler */
+ FastDispatch->AcquireFileForNtCreateSection(FileObject);
+ }
+ else
+ {
+ /* No FastIo handler, acquire file's resource exclusively */
+ if (FcbHeader && FcbHeader->Resource)
ExAcquireResourceExclusiveLite(FcbHeader->Resource, TRUE);
+ }
+
+ return STATUS_SUCCESS;
+}
+
/*
* @implemented
*/
@@ -1565,9 +1600,10 @@
NTAPI
FsRtlAcquireFileExclusive(IN PFILE_OBJECT FileObject)
{
- /* PAGED_CODE(); */
- /* FsRtlAcquireFileExclusiveCommon(FileObject, 0, 0); */
- KeBugCheck(FILE_SYSTEM);
+ PAGED_CODE();
+
+ /* Call the common routine. Don't care about the result */
+ (VOID)FsRtlAcquireFileExclusiveCommon(FileObject, SyncTypeOther, 0);
}
/*
@@ -1577,7 +1613,127 @@
NTAPI
FsRtlReleaseFile(IN PFILE_OBJECT FileObject)
{
- KeBugCheck(FILE_SYSTEM);
+ PFSRTL_COMMON_FCB_HEADER FcbHeader;
+ PDEVICE_OBJECT DeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext;
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if Fast Calls are supported and check ReleaseFileForNtCreateSection */
+ if (FastDispatch &&
+ FastDispatch->ReleaseFileForNtCreateSection)
+ {
+ /* Call the ReleaseFileForNtCreateSection FastIo handler */
+ FastDispatch->ReleaseFileForNtCreateSection(FileObject);
+ }
+ else
+ {
+ /* No FastIo handler, release file's resource */
+ if (FcbHeader && FcbHeader->Resource)
ExReleaseResourceLite(FcbHeader->Resource);
+ }
+
+ /* Release master FsRtl lock */
+ FsRtlExitFileSystem();
+}
+
+/*
+* @implemented
+*/
+NTSTATUS
+NTAPI
+FsRtlAcquireFileForCcFlushEx(IN PFILE_OBJECT FileObject)
+{
+ PFSRTL_COMMON_FCB_HEADER FcbHeader;
+ PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get the Base File System (Volume) and Fast Calls */
+ FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext;
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Get master FsRtl lock */
+ FsRtlEnterFileSystem();
+
+ /* Check if Fast Calls are supported, and check AcquireForCcFlush */
+ if (FastDispatch &&
+ FastDispatch->AcquireForCcFlush)
+ {
+ /* Call the AcquireForCcFlush FastIo handler */
+ FastDispatch->AcquireForCcFlush(FileObject, BaseDeviceObject);
+ }
+ else
+ {
+ /* No FastIo handler, acquire file's resource */
+ if (FcbHeader->Resource)
+ {
+ /* Acquire it - either shared if it's already acquired
+ or exclusively if we are the first */
+ if (ExIsResourceAcquiredSharedLite(FcbHeader->Resource))
+ ExAcquireResourceSharedLite(FcbHeader->Resource, TRUE);
+ else
+ ExAcquireResourceExclusiveLite(FcbHeader->Resource, TRUE);
+ }
+
+ /* Also acquire its Paging I/O resource */
+ if (FcbHeader->PagingIoResource)
+ ExAcquireResourceSharedLite(FcbHeader->PagingIoResource, TRUE);
+ }
+
+ return STATUS_SUCCESS;
+}
+
+/*
+* @implemented
+*/
+VOID
+NTAPI
+FsRtlAcquireFileForCcFlush(IN PFILE_OBJECT FileObject)
+{
+ PAGED_CODE();
+
+ /* Call the common routine. Don't care about the result */
+ (VOID)FsRtlAcquireFileForCcFlushEx(FileObject);
+}
+
+
+/*
+* @implemented
+*/
+VOID
+NTAPI
+FsRtlReleaseFileForCcFlush(IN PFILE_OBJECT FileObject)
+{
+ PFSRTL_COMMON_FCB_HEADER FcbHeader;
+ PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext;
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if Fast Calls are supported, and check ReleaseForCcFlush */
+ if (FastDispatch &&
+ FastDispatch->ReleaseForCcFlush)
+ {
+ /* Call the ReleaseForCcFlush FastIo handler */
+ FastDispatch->ReleaseForCcFlush(FileObject, BaseDeviceObject);
+ }
+ else
+ {
+ /* No FastIo handler, release PagingIO and then file's resource */
+ if (FcbHeader->PagingIoResource)
ExReleaseResourceLite(FcbHeader->PagingIoResource);
+ if (FcbHeader->Resource) ExReleaseResourceLite(FcbHeader->Resource);
+ }
+
+ /* Release master FsRtl lock */
+ FsRtlExitFileSystem();
}
/*++