Author: pschweitzer
Date: Fri May 15 16:03:29 2015
New Revision: 67743
URL:
http://svn.reactos.org/svn/reactos?rev=67743&view=rev
Log:
[FASTFAT]
Bring in initiated work on IRPs in NTFS (and complete it).
This simplifies the way IRPs and their context are handled in the driver.
Only VfatDispatchRequest() is responsible of completing IRPs (if required), freeing the
IRP context (if required), and queueing the IRP for later completion (if required).
This allows removing duplicated code, hacks, and so on. It might help reducing IRP leaks,
or memory leaks.
By default, VfatDispatchRequest() will complete the IRP and delete the IRP context.
In case you don't want it to complete the IRP (because you passed it down, for
instance), remove the IRPCONTEXT_COMPLETE flag. See for instance: VfatDeviceControl().
In case you want to queue the IRP (you previously called: VfatQueueRequest()), call the
newly introduced VfatMarkIrpContextForQueue() function that will prepare it.
Modified:
trunk/reactos/drivers/filesystems/fastfat/cleanup.c
trunk/reactos/drivers/filesystems/fastfat/close.c
trunk/reactos/drivers/filesystems/fastfat/create.c
trunk/reactos/drivers/filesystems/fastfat/dir.c
trunk/reactos/drivers/filesystems/fastfat/finfo.c
trunk/reactos/drivers/filesystems/fastfat/flush.c
trunk/reactos/drivers/filesystems/fastfat/fsctl.c
trunk/reactos/drivers/filesystems/fastfat/misc.c
trunk/reactos/drivers/filesystems/fastfat/pnp.c
trunk/reactos/drivers/filesystems/fastfat/rw.c
trunk/reactos/drivers/filesystems/fastfat/vfat.h
trunk/reactos/drivers/filesystems/fastfat/volume.c
Modified: trunk/reactos/drivers/filesystems/fastfat/cleanup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/cleanup.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/cleanup.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -152,14 +152,14 @@
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{
- Status = STATUS_SUCCESS;
- goto ByeBye;
+ IrpContext->Irp->IoStatus.Information = 0;
+ return STATUS_SUCCESS;
}
if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource,
(BOOLEAN)(IrpContext->Flags &
IRPCONTEXT_CANWAIT)))
{
- return VfatQueueRequest(IrpContext);
+ return VfatMarkIrpContextForQueue(IrpContext);
}
Status = VfatCleanupFile(IrpContext);
@@ -168,15 +168,10 @@
if (Status == STATUS_PENDING)
{
- return VfatQueueRequest(IrpContext);
+ return VfatMarkIrpContextForQueue(IrpContext);
}
-ByeBye:
- IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;
-
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
return Status;
}
Modified: trunk/reactos/drivers/filesystems/fastfat/close.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/close.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/close.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -83,8 +83,8 @@
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{
DPRINT("Closing file system\n");
- Status = STATUS_SUCCESS;
- goto ByeBye;
+ IrpContext->Irp->IoStatus.Information = 0;
+ return STATUS_SUCCESS;
}
#if 0
/* There occurs a dead look at the call to
CcRosDeleteFileCache/ObDereferenceObject/VfatClose
@@ -94,17 +94,13 @@
if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource,
TRUE))
#endif
{
- return VfatQueueRequest(IrpContext);
+ return VfatMarkIrpContextForQueue(IrpContext);
}
Status = VfatCloseFile(IrpContext->DeviceExt, IrpContext->FileObject);
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
-ByeBye:
- IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
return Status;
}
Modified: trunk/reactos/drivers/filesystems/fastfat/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -941,15 +941,14 @@
/* DeviceObject represents FileSystem instead of logical volume */
DPRINT ("FsdCreate called with file system\n");
IrpContext->Irp->IoStatus.Information = FILE_OPENED;
- IrpContext->Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(IrpContext->Irp, IO_DISK_INCREMENT);
- VfatFreeIrpContext(IrpContext);
+ IrpContext->PriorityBoost = IO_DISK_INCREMENT;
+
return STATUS_SUCCESS;
}
if (!(IrpContext->Flags & IRPCONTEXT_CANWAIT))
{
- return(VfatQueueRequest(IrpContext));
+ return VfatMarkIrpContextForQueue(IrpContext);
}
IrpContext->Irp->IoStatus.Information = 0;
@@ -957,10 +956,9 @@
Status = VfatCreateFile(IrpContext->DeviceObject, IrpContext->Irp);
ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource);
- IrpContext->Irp->IoStatus.Status = Status;
- IoCompleteRequest(IrpContext->Irp,
- (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT :
IO_NO_INCREMENT));
- VfatFreeIrpContext(IrpContext);
+ if (NT_SUCCESS(Status))
+ IrpContext->PriorityBoost = IO_DISK_INCREMENT;
+
return Status;
}
Modified: trunk/reactos/drivers/filesystems/fastfat/dir.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/dir.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/dir.c [iso-8859-1] Fri May 15 16:03:29 2015
@@ -508,7 +508,7 @@
(BOOLEAN)(IrpContext->Flags &
IRPCONTEXT_CANWAIT)))
{
ExReleaseResourceLite(&pFcb->MainResource);
- return VfatQueueRequest(IrpContext);
+ return VfatMarkIrpContextForQueue(IrpContext);
}
while ((Status == STATUS_SUCCESS) && (BufferLength > 0))
@@ -592,29 +592,28 @@
return Status;
}
-NTSTATUS VfatNotifyChangeDirectory(PVFAT_IRP_CONTEXT * IrpContext)
+NTSTATUS VfatNotifyChangeDirectory(PVFAT_IRP_CONTEXT IrpContext)
{
PVCB pVcb;
PVFATFCB pFcb;
PIO_STACK_LOCATION Stack;
- Stack = (*IrpContext)->Stack;
- pVcb = (*IrpContext)->DeviceExt;
- pFcb = (PVFATFCB) (*IrpContext)->FileObject->FsContext;
+ Stack = IrpContext->Stack;
+ pVcb = IrpContext->DeviceExt;
+ pFcb = (PVFATFCB) IrpContext->FileObject->FsContext;
FsRtlNotifyFullChangeDirectory(pVcb->NotifySync,
&(pVcb->NotifyList),
- (*IrpContext)->FileObject->FsContext2,
+ IrpContext->FileObject->FsContext2,
(PSTRING)&(pFcb->PathNameU),
BooleanFlagOn(Stack->Flags, SL_WATCH_TREE),
FALSE,
Stack->Parameters.NotifyDirectory.CompletionFilter,
- (*IrpContext)->Irp,
+ IrpContext->Irp,
NULL,
NULL);
- /* We don't need the IRP context as we won't handle IRP completion */
- VfatFreeIrpContext(*IrpContext);
- *IrpContext = NULL;
+ /* We won't handle IRP completion */
+ IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
return STATUS_PENDING;
}
@@ -637,7 +636,7 @@
break;
case IRP_MN_NOTIFY_CHANGE_DIRECTORY:
- Status = VfatNotifyChangeDirectory(&IrpContext);
+ Status = VfatNotifyChangeDirectory(IrpContext);
break;
default:
@@ -648,19 +647,9 @@
break;
}
- if (Status == STATUS_PENDING)
- {
- /* Only queue if there's IRP context */
- if (IrpContext)
- {
- Status = VfatQueueRequest(IrpContext);
- }
- }
- else
- {
- IrpContext->Irp->IoStatus.Status = Status;
- IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
+ if (Status == STATUS_PENDING && IrpContext->Flags &
IRPCONTEXT_COMPLETE)
+ {
+ return VfatMarkIrpContextForQueue(IrpContext);
}
return Status;
Modified: trunk/reactos/drivers/filesystems/fastfat/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -1381,7 +1381,7 @@
if (!ExAcquireResourceSharedLite(&FCB->MainResource,
(BOOLEAN)(IrpContext->Flags &
IRPCONTEXT_CANWAIT)))
{
- return VfatQueueRequest(IrpContext);
+ return VfatMarkIrpContextForQueue(IrpContext);
}
}
@@ -1459,14 +1459,11 @@
ExReleaseResourceLite(&FCB->MainResource);
}
- IrpContext->Irp->IoStatus.Status = Status;
if (NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW)
IrpContext->Irp->IoStatus.Information =
IrpContext->Stack->Parameters.QueryFile.Length - BufferLength;
else
IrpContext->Irp->IoStatus.Information = 0;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
return Status;
}
@@ -1510,10 +1507,7 @@
(PLARGE_INTEGER)SystemBuffer))
{
DPRINT("Couldn't set file size!\n");
- IrpContext->Irp->IoStatus.Status = STATUS_USER_MAPPED_FILE;
IrpContext->Irp->IoStatus.Information = 0;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
return STATUS_USER_MAPPED_FILE;
}
DPRINT("Can set file size\n");
@@ -1524,7 +1518,7 @@
if
(!ExAcquireResourceExclusiveLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource,
(BOOLEAN)(IrpContext->Flags &
IRPCONTEXT_CANWAIT)))
{
- return VfatQueueRequest(IrpContext);
+ return VfatMarkIrpContextForQueue(IrpContext);
}
}
@@ -1537,7 +1531,8 @@
{
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
}
- return VfatQueueRequest(IrpContext);
+
+ return VfatMarkIrpContextForQueue(IrpContext);
}
}
@@ -1592,11 +1587,7 @@
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
}
- IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
-
return Status;
}
Modified: trunk/reactos/drivers/filesystems/fastfat/flush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/flush.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/flush.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -150,8 +150,8 @@
/* This request is not allowed on the main device object. */
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{
- Status = STATUS_INVALID_DEVICE_REQUEST;
- goto ByeBye;
+ IrpContext->Irp->IoStatus.Information = 0;
+ return STATUS_INVALID_DEVICE_REQUEST;
}
Fcb = (PVFATFCB)IrpContext->FileObject->FsContext;
@@ -170,12 +170,7 @@
ExReleaseResourceLite (&Fcb->MainResource);
}
-ByeBye:
- IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;
- IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
-
return Status;
}
Modified: trunk/reactos/drivers/filesystems/fastfat/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -1066,9 +1066,5 @@
break;
}
- IrpContext->Irp->IoStatus.Status = Status;
-
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
return Status;
}
Modified: trunk/reactos/drivers/filesystems/fastfat/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/misc.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -51,6 +51,10 @@
static LONG QueueCount = 0;
+static VOID VfatFreeIrpContext(PVFAT_IRP_CONTEXT);
+static PVFAT_IRP_CONTEXT VfatAllocateIrpContext(PDEVICE_OBJECT, PIRP);
+static NTSTATUS VfatQueueRequest(PVFAT_IRP_CONTEXT);
+
/* FUNCTIONS ****************************************************************/
static
@@ -69,28 +73,21 @@
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
{
- Status = STATUS_INVALID_DEVICE_REQUEST;
- goto Fail;
+ return STATUS_INVALID_DEVICE_REQUEST;
}
if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)
{
- Status = STATUS_INVALID_PARAMETER;
- goto Fail;
- }
-
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
Status = FsRtlProcessFileLock(&Fcb->FileLock,
IrpContext->Irp,
NULL);
VfatFreeIrpContext(IrpContext);
return Status;
-
-Fail:
- IrpContext->Irp->IoStatus.Status = Status;
- IoCompleteRequest(IrpContext->Irp, (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT
: IO_NO_INCREMENT));
- VfatFreeIrpContext(IrpContext);
- return Status;
}
static
@@ -100,6 +97,8 @@
{
IoSkipCurrentIrpStackLocation(IrpContext->Irp);
+ IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
+
return IoCallDriver(IrpContext->DeviceExt->StorageDevice, IrpContext->Irp);
}
@@ -108,6 +107,8 @@
VfatDispatchRequest(
IN PVFAT_IRP_CONTEXT IrpContext)
{
+ NTSTATUS Status;
+
DPRINT("VfatDispatchRequest (IrpContext %p), is called for %s\n",
IrpContext,
IrpContext->MajorFunction >= IRP_MJ_MAXIMUM_FUNCTION ? "????"
: MajorFunctionNames[IrpContext->MajorFunction]);
@@ -116,42 +117,94 @@
switch (IrpContext->MajorFunction)
{
case IRP_MJ_CLOSE:
- return VfatClose(IrpContext);
+ Status = VfatClose(IrpContext);
+ break;
+
case IRP_MJ_CREATE:
- return VfatCreate(IrpContext);
+ Status = VfatCreate(IrpContext);
+ break;
+
case IRP_MJ_READ:
- return VfatRead (IrpContext);
+ Status = VfatRead(IrpContext);
+ break;
+
case IRP_MJ_WRITE:
- return VfatWrite (IrpContext);
+ Status = VfatWrite (IrpContext);
+ break;
+
case IRP_MJ_FILE_SYSTEM_CONTROL:
- return VfatFileSystemControl(IrpContext);
+ Status = VfatFileSystemControl(IrpContext);
+ break;
+
case IRP_MJ_QUERY_INFORMATION:
- return VfatQueryInformation (IrpContext);
+ Status = VfatQueryInformation (IrpContext);
+ break;
+
case IRP_MJ_SET_INFORMATION:
- return VfatSetInformation (IrpContext);
+ Status = VfatSetInformation (IrpContext);
+ break;
+
case IRP_MJ_DIRECTORY_CONTROL:
- return VfatDirectoryControl(IrpContext);
+ Status = VfatDirectoryControl(IrpContext);
+ break;
+
case IRP_MJ_QUERY_VOLUME_INFORMATION:
- return VfatQueryVolumeInformation(IrpContext);
+ Status = VfatQueryVolumeInformation(IrpContext);
+ break;
+
case IRP_MJ_SET_VOLUME_INFORMATION:
- return VfatSetVolumeInformation(IrpContext);
+ Status = VfatSetVolumeInformation(IrpContext);
+ break;
+
case IRP_MJ_LOCK_CONTROL:
- return VfatLockControl(IrpContext);
+ Status = VfatLockControl(IrpContext);
+ break;
+
case IRP_MJ_DEVICE_CONTROL:
- return VfatDeviceControl(IrpContext);
+ Status = VfatDeviceControl(IrpContext);
+ break;
+
case IRP_MJ_CLEANUP:
- return VfatCleanup(IrpContext);
+ Status = VfatCleanup(IrpContext);
+ break;
+
case IRP_MJ_FLUSH_BUFFERS:
- return VfatFlush(IrpContext);
+ Status = VfatFlush(IrpContext);
+ break;
+
case IRP_MJ_PNP:
- return VfatPnp(IrpContext);
+ Status = VfatPnp(IrpContext);
+ break;
+
default:
DPRINT1("Unexpected major function %x\n",
IrpContext->MajorFunction);
- IrpContext->Irp->IoStatus.Status = STATUS_DRIVER_INTERNAL_ERROR;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
- return STATUS_DRIVER_INTERNAL_ERROR;
- }
+ Status = STATUS_DRIVER_INTERNAL_ERROR;
+ }
+
+ ASSERT((!(IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
!(IrpContext->Flags & IRPCONTEXT_QUEUE)) ||
+ ((IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
!(IrpContext->Flags & IRPCONTEXT_QUEUE)) ||
+ (!(IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
(IrpContext->Flags & IRPCONTEXT_QUEUE)));
+
+ if (IrpContext->Flags & IRPCONTEXT_COMPLETE)
+ {
+ IrpContext->Irp->IoStatus.Status = Status;
+ IoCompleteRequest(IrpContext->Irp, IrpContext->PriorityBoost);
+ }
+
+ if (IrpContext->Flags & IRPCONTEXT_QUEUE)
+ {
+ /* Reset our status flags before queueing the IRP */
+ IrpContext->Flags |= IRPCONTEXT_COMPLETE;
+ IrpContext->Flags &= ~IRPCONTEXT_QUEUE;
+ Status = VfatQueueRequest(IrpContext);
+ }
+ else
+ {
+ /* Unless the IRP was queued, always free the IRP context */
+ VfatFreeIrpContext(IrpContext);
+ }
+
+ return Status;
}
NTSTATUS
@@ -184,6 +237,7 @@
return Status;
}
+static
VOID
VfatFreeIrpContext(
PVFAT_IRP_CONTEXT IrpContext)
@@ -192,6 +246,7 @@
ExFreeToNPagedLookasideList(&VfatGlobalData->IrpContextLookasideList,
IrpContext);
}
+static
PVFAT_IRP_CONTEXT
VfatAllocateIrpContext(
PDEVICE_OBJECT DeviceObject,
@@ -218,7 +273,7 @@
MajorFunction = IrpContext->MajorFunction =
IrpContext->Stack->MajorFunction;
IrpContext->MinorFunction = IrpContext->Stack->MinorFunction;
IrpContext->FileObject = IrpContext->Stack->FileObject;
- IrpContext->Flags = 0;
+ IrpContext->Flags = IRPCONTEXT_COMPLETE;
if (MajorFunction == IRP_MJ_FILE_SYSTEM_CONTROL ||
MajorFunction == IRP_MJ_DEVICE_CONTROL ||
MajorFunction == IRP_MJ_SHUTDOWN)
@@ -233,6 +288,7 @@
}
KeInitializeEvent(&IrpContext->Event, NotificationEvent, FALSE);
IrpContext->RefCount = 0;
+ IrpContext->PriorityBoost = IO_NO_INCREMENT;
}
return IrpContext;
}
@@ -253,6 +309,7 @@
FsRtlExitFileSystem();
}
+static
NTSTATUS
VfatQueueRequest(
PVFAT_IRP_CONTEXT IrpContext)
Modified: trunk/reactos/drivers/filesystems/fastfat/pnp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/pnp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/pnp.c [iso-8859-1] Fri May 15 16:03:29 2015
@@ -33,17 +33,14 @@
case IRP_MN_REMOVE_DEVICE:
case IRP_MN_CANCEL_REMOVE_DEVICE:
Status = STATUS_NOT_IMPLEMENTED;
- IrpContext->Irp->IoStatus.Status = Status;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
break;
default:
IoSkipCurrentIrpStackLocation(IrpContext->Irp);
Vcb = (PVCB)IrpContext->Stack->DeviceObject->DeviceExtension;
+ IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
Status = IoCallDriver(Vcb->StorageDevice, IrpContext->Irp);
}
- VfatFreeIrpContext(IrpContext);
-
return Status;
}
Modified: trunk/reactos/drivers/filesystems/fastfat/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] Fri May 15 16:03:29 2015
@@ -572,9 +572,9 @@
PFATINFO FatInfo = &IrpContext->DeviceExt->FatInfo;
IrpContext->Stack->Parameters.Read.ByteOffset.QuadPart +=
FatInfo->dataStart * FatInfo->BytesPerSector;
IoSkipCurrentIrpStackLocation(IrpContext->Irp);
+ IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
DPRINT("Read from page file, disk offset %I64x\n",
IrpContext->Stack->Parameters.Read.ByteOffset.QuadPart);
Status = IoCallDriver(IrpContext->DeviceExt->StorageDevice,
IrpContext->Irp);
- VfatFreeIrpContext(IrpContext);
return Status;
}
@@ -740,13 +740,7 @@
Status = VfatLockUserBuffer(IrpContext->Irp, Length, IoWriteAccess);
if (NT_SUCCESS(Status))
{
- Status = VfatQueueRequest(IrpContext);
- }
- else
- {
- IrpContext->Irp->IoStatus.Status = Status;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
+ Status = VfatMarkIrpContextForQueue(IrpContext);
}
}
else
@@ -760,9 +754,8 @@
ByteOffset.QuadPart + IrpContext->Irp->IoStatus.Information;
}
- IoCompleteRequest(IrpContext->Irp,
- (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT :
IO_NO_INCREMENT));
- VfatFreeIrpContext(IrpContext);
+ if (NT_SUCCESS(Status))
+ IrpContext->PriorityBoost = IO_DISK_INCREMENT;
}
DPRINT("%x\n", Status);
return Status;
@@ -805,9 +798,9 @@
PFATINFO FatInfo = &IrpContext->DeviceExt->FatInfo;
IrpContext->Stack->Parameters.Write.ByteOffset.QuadPart +=
FatInfo->dataStart * FatInfo->BytesPerSector;
IoSkipCurrentIrpStackLocation(IrpContext->Irp);
+ IrpContext->Flags &= ~IRPCONTEXT_COMPLETE;
DPRINT("Write to page file, disk offset %I64x\n",
IrpContext->Stack->Parameters.Write.ByteOffset.QuadPart);
Status = IoCallDriver(IrpContext->DeviceExt->StorageDevice,
IrpContext->Irp);
- VfatFreeIrpContext(IrpContext);
return Status;
}
@@ -1074,13 +1067,7 @@
Status = VfatLockUserBuffer(IrpContext->Irp, Length, IoReadAccess);
if (NT_SUCCESS(Status))
{
- Status = VfatQueueRequest(IrpContext);
- }
- else
- {
- IrpContext->Irp->IoStatus.Status = Status;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
+ Status = VfatMarkIrpContextForQueue(IrpContext);
}
}
else
@@ -1093,9 +1080,8 @@
ByteOffset.QuadPart + IrpContext->Irp->IoStatus.Information;
}
- IoCompleteRequest(IrpContext->Irp,
- (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT :
IO_NO_INCREMENT));
- VfatFreeIrpContext(IrpContext);
+ if (NT_SUCCESS(Status))
+ IrpContext->PriorityBoost = IO_DISK_INCREMENT;
}
DPRINT("%x\n", Status);
return Status;
Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] Fri May 15 16:03:29
2015
@@ -446,8 +446,10 @@
}
DOSDATE, *PDOSDATE;
-#define IRPCONTEXT_CANWAIT 0x0001
-#define IRPCONTEXT_PENDINGRETURNED 0x0002
+#define IRPCONTEXT_CANWAIT 0x0001
+#define IRPCONTEXT_COMPLETE 0x0002
+#define IRPCONTEXT_QUEUE 0x0004
+#define IRPCONTEXT_PENDINGRETURNED 0x0008
typedef struct
{
@@ -462,6 +464,7 @@
PFILE_OBJECT FileObject;
ULONG RefCount;
KEVENT Event;
+ CCHAR PriorityBoost;
} VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
typedef struct _VFAT_DIRENTRY_CONTEXT
@@ -480,6 +483,18 @@
USHORT CreationDate;
USHORT CreationTime;
} VFAT_MOVE_CONTEXT, *PVFAT_MOVE_CONTEXT;
+
+FORCEINLINE
+NTSTATUS
+VfatMarkIrpContextForQueue(PVFAT_IRP_CONTEXT IrpContext)
+{
+ PULONG Flags = &IrpContext->Flags;
+
+ *Flags &= ~IRPCONTEXT_COMPLETE;
+ *Flags |= IRPCONTEXT_QUEUE;
+
+ return STATUS_PENDING;
+}
/* blockdev.c */
@@ -902,19 +917,6 @@
/* misc.c */
-NTSTATUS
-VfatQueueRequest(
- PVFAT_IRP_CONTEXT IrpContext);
-
-PVFAT_IRP_CONTEXT
-VfatAllocateIrpContext(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
-
-VOID
-VfatFreeIrpContext(
- PVFAT_IRP_CONTEXT IrpContext);
-
DRIVER_DISPATCH
VfatBuildRequest;
Modified: trunk/reactos/drivers/filesystems/fastfat/volume.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/volume.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/volume.c [iso-8859-1] Fri May 15 16:03:29
2015
@@ -363,7 +363,8 @@
if
(!ExAcquireResourceSharedLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource,
(BOOLEAN)(IrpContext->Flags &
IRPCONTEXT_CANWAIT)))
{
- return VfatQueueRequest(IrpContext);
+ DPRINT1("DirResource failed!\n");
+ return VfatMarkIrpContextForQueue(IrpContext);
}
/* INITIALIZATION */
@@ -405,14 +406,12 @@
}
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
- IrpContext->Irp->IoStatus.Status = RC;
+
if (NT_SUCCESS(RC))
IrpContext->Irp->IoStatus.Information =
IrpContext->Stack->Parameters.QueryVolume.Length - BufferLength;
else
IrpContext->Irp->IoStatus.Information = 0;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
return RC;
}
@@ -439,7 +438,7 @@
if
(!ExAcquireResourceExclusiveLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource,
(BOOLEAN)(IrpContext->Flags &
IRPCONTEXT_CANWAIT)))
{
- return VfatQueueRequest(IrpContext);
+ return VfatMarkIrpContextForQueue(IrpContext);
}
FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass;
@@ -462,10 +461,7 @@
}
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
- IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;
- IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
- VfatFreeIrpContext(IrpContext);
return Status;
}