- Added profiling for possible Nt I/O function optimizations. Booting and running Firefox gave an amazing "0 missed optimizations", so defintely, this has been moved down on the priority list. Also merged all tracing TODOs in one entry and added device.c tracing TODO.

- Fix IRP Cancellation and enable all calls to IopQueueIrpToThread and IopUnqueueIrpFromThread. This seems to work properly now and the kernel fun entry for it has been removed. All remaining Io TODOs are now low priority.

svn path=/trunk/; revision=23354
This commit is contained in:
Alex Ionescu 2006-07-29 19:26:13 +00:00
parent 8775e940c1
commit 17509fb1e5
4 changed files with 59 additions and 15 deletions

View file

@ -9,14 +9,12 @@
// Failure to respect this will *ACHIEVE NOTHING*.
//
// Io:
// - See why queueing IRPs and cancelling them causes crashes.
// - Add tracing to iofunc.c, file.c and device.c
// - Add Access Checks in IopParseDevice.
// - Add validation checks in IoCreateFile.
// - Add probe/alignment checks for Query/Set routines.
// - Add tracing to iofunc.c
// - Add tracing to file.c
// - Add support for some fast-paths when querying/setting data.
// - Verify ShareAccess APIs, XP added some new semantics.
// - Add support for some fast-paths when querying/setting data.
// - Add support for Fast Dispatch I/O.
//
// Ob:

View file

@ -16,6 +16,8 @@
// These define the Debug Masks Supported
//
#define IO_IRP_DEBUG 0x01
#define IO_FO_DEBUG 0x02
#define IO_DEVICE_DEBUG 0x04
//
// Debug/Tracing support

View file

@ -373,7 +373,7 @@ IopParseDevice(IN PVOID ParseObject,
OpenPacket->FileObject = FileObject;
/* Queue the IRP and call the driver */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
@ -404,7 +404,7 @@ IopParseDevice(IN PVOID ParseObject,
FileObject->Event.Header.SignalState = 1;
/* Now that we've signaled the events, de-associate the IRP */
//IopUnQueueIrpFromThread(Irp);
IopUnQueueIrpFromThread(Irp);
/* Check if the IRP had an input buffer */
if ((Irp->Flags & IRP_BUFFERED_IO) &&
@ -611,6 +611,7 @@ IopDeleteFile(IN PVOID ObjectBody)
NTSTATUS Status;
KEVENT Event;
PDEVICE_OBJECT DeviceObject;
KIRQL OldIrql;
/* Check if the file has a device object */
if (FileObject->DeviceObject)
@ -656,7 +657,7 @@ IopDeleteFile(IN PVOID ObjectBody)
StackPtr->FileObject = FileObject;
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* Call the FS Driver */
Status = IoCallDriver(DeviceObject, Irp);
@ -666,6 +667,11 @@ IopDeleteFile(IN PVOID ObjectBody)
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
}
/* Raise to APC level and de-queue the IRP */
KeRaiseIrql(APC_LEVEL, &OldIrql);
IopUnQueueIrpFromThread(Irp);
KeLowerIrql(OldIrql);
/* Free the IRP */
IoFreeIrp(Irp);
@ -830,7 +836,7 @@ IopSecurityFile(IN PVOID ObjectBody,
}
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* Update operation counts */
IopUpdateOperationCount(IopOtherTransfer);
@ -1024,6 +1030,7 @@ IopCloseFile(IN PEPROCESS Process OPTIONAL,
PIO_STACK_LOCATION StackPtr;
NTSTATUS Status;
PDEVICE_OBJECT DeviceObject;
KIRQL OldIrql;
/* Check if the file is locked and has more then one handle opened */
if ((FileObject->LockOperation) && (SystemHandleCount != 1))
@ -1075,7 +1082,7 @@ IopCloseFile(IN PEPROCESS Process OPTIONAL,
StackPtr->FileObject = FileObject;
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* Update operation counts */
IopUpdateOperationCount(IopOtherTransfer);
@ -1088,6 +1095,11 @@ IopCloseFile(IN PEPROCESS Process OPTIONAL,
KeWaitForSingleObject(&Event, UserRequest, KernelMode, FALSE, NULL);
}
/* Raise to APC level and de-queue the IRP */
KeRaiseIrql(APC_LEVEL, &OldIrql);
IopUnQueueIrpFromThread(Irp);
KeLowerIrql(OldIrql);
/* Free the IRP */
IoFreeIrp(Irp);

View file

@ -14,6 +14,8 @@
#define NDEBUG
#include <internal/debug.h>
ULONG IopMissedOptimizations;
#if 0
IOTRACE(IO_IRP_DEBUG,
"%s - Queueing IRP %p\n",
@ -127,7 +129,7 @@ IopPerformSynchronousRequest(IN PDEVICE_OBJECT DeviceObject,
PAGED_CODE();
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* Update operation counts */
IopUpdateOperationCount(TransferType);
@ -449,7 +451,7 @@ IopQueryDeviceInformation(IN PFILE_OBJECT FileObject,
}
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* Call the Driver */
Status = IoCallDriver(FileObject->DeviceObject, Irp);
@ -696,7 +698,17 @@ IoSetInformation(IN PFILE_OBJECT FileObject,
StackPtr->Parameters.SetFile.Length = Length;
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* FIXME BUGBUG TEMPORARY CODE */
if ((FileInformationClass == FileModeInformation) ||
(FileInformationClass == FileRenameInformation ) ||
(FileInformationClass == FileLinkInformation ) ||
(FileInformationClass == FileMoveClusterInformation))
{
DPRINT1("Missed optimization: %lx\n", FileInformationClass);
IopMissedOptimizations++;
}
/* Call the Driver */
Status = IoCallDriver(FileObject->DeviceObject, Irp);
@ -1635,11 +1647,21 @@ NtQueryInformationFile(IN HANDLE FileHandle,
StackPtr->Parameters.QueryFile.Length = Length;
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* Update operation counts */
IopUpdateOperationCount(IopOtherTransfer);
/* FIXME BUGBUG TEMPORARY CODE */
if ((FileInformationClass == FileAccessInformation) ||
(FileInformationClass == FileModeInformation) ||
(FileInformationClass == FileAlignmentInformation) ||
(FileInformationClass == FileAllInformation))
{
DPRINT1("Missed optimization: %lx\n", FileInformationClass);
IopMissedOptimizations++;
}
/* Call the Driver */
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
@ -2181,12 +2203,22 @@ NtSetInformationFile(IN HANDLE FileHandle,
StackPtr->Parameters.SetFile.Length = Length;
/* Queue the IRP */
//IopQueueIrpToThread(Irp);
IopQueueIrpToThread(Irp);
/* Update operation counts */
IopUpdateOperationCount(IopOtherTransfer);
/* FIXME: Later, we can implement a lot of stuff here and avoid a driver call */
/* FIXME BUGBUG TEMPORARY CODE */
if ((FileInformationClass == FileModeInformation) ||
(FileInformationClass == FileRenameInformation ) ||
(FileInformationClass == FileLinkInformation ) ||
(FileInformationClass == FileMoveClusterInformation ) ||
(FileInformationClass == FileDispositionInformation ))
{
DPRINT1("Missed optimization: %lx\n", FileInformationClass);
IopMissedOptimizations++;
}
/* Handle IO Completion Port quickly */
if (FileInformationClass == FileCompletionInformation)
{