#include <debug.h>
#include "internal/io_i.h"
+volatile LONG IoPageReadIrpAllocationFailure = 0;
+volatile LONG IoPageReadNonPagefileIrpAllocationFailure = 0;
+
/* PRIVATE FUNCTIONS *********************************************************/
VOID
}
/* Check if we got an output buffer */
- if (OutputBuffer)
+ if (OutputBufferLength)
{
/* Allocate the System Buffer */
Irp->MdlAddress = IoAllocateMdl(OutputBuffer,
IOTRACE(IO_API_DEBUG, "FileObject: %p. Mdl: %p. Offset: %p \n",
FileObject, Mdl, Offset);
+ /* Is the write originating from Cc? */
+ if (FileObject->SectionObjectPointer != NULL &&
+ FileObject->SectionObjectPointer->SharedCacheMap != NULL)
+ {
+ ++CcDataFlushes;
+ CcDataPages += BYTES_TO_PAGES(MmGetMdlByteCount(Mdl));
+ }
+
/* Get the Device Object */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
/* Allocate IRP */
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
- if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;
+ /* If allocation failed, try to see whether we can use
+ * the reserve IRP
+ */
+ if (Irp == NULL)
+ {
+ /* We will use it only for paging file */
+ if (MmIsFileObjectAPagingFile(FileObject))
+ {
+ InterlockedExchangeAdd(&IoPageReadIrpAllocationFailure, 1);
+ Irp = IopAllocateReserveIrp(DeviceObject->StackSize);
+ }
+ else
+ {
+ InterlockedExchangeAdd(&IoPageReadNonPagefileIrpAllocationFailure, 1);
+ }
+
+ /* If allocation failed (not a paging file or too big stack size)
+ * Fail for real
+ */
+ if (Irp == NULL)
+ {
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+ }
/* Get the Stack */
StackPtr = IoGetNextIrpStackLocation(Irp);