Commit in reactos/ntoskrnl on MAIN
cc/copy.c+26-121.22 -> 1.23
include/internal/mm.h+2-21.80 -> 1.81
io/irp.c+9-51.60 -> 1.61
mm/anonmem.c+4-131.27 -> 1.28
  /section.c+6-211.150 -> 1.151
+47-53
5 modified files
- Allocate memory for mdl's for paging io  from stack instead of the non paged pool.

reactos/ntoskrnl/cc
copy.c 1.22 -> 1.23
diff -u -r1.22 -r1.23
--- copy.c	6 Jun 2004 07:52:22 -0000	1.22
+++ copy.c	6 Jun 2004 08:36:30 -0000	1.23
@@ -1,4 +1,4 @@
-/* $Id: copy.c,v 1.22 2004/06/06 07:52:22 hbirr Exp $
+/* $Id: copy.c,v 1.23 2004/06/06 08:36:30 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -33,6 +33,15 @@
 #endif
 
 #define MAX_ZERO_LENGTH	(256 * 1024)
+#define MAX_RW_LENGTH	(64 * 1024)
+
+#if defined(__GNUC__)
+void * alloca(size_t size);
+#elif defined(_MSC_VER)
+void* _alloca(size_t size);
+#else
+#error Unknown compiler for alloca intrinsic stack allocation "function"
+#endif
 
 /* FUNCTIONS *****************************************************************/
 
@@ -67,6 +76,9 @@
   NTSTATUS Status;
   ULONG TempLength;
   KEVENT Event;
+  PMDL Mdl;
+
+  Mdl = alloca(MmSizeOfMdl(NULL, MAX_RW_LENGTH));
 
   Status = CcRosGetCacheSegmentChain(Bcb, ReadOffset, Length, &head);
   if (!NT_SUCCESS(Status))
@@ -105,7 +117,6 @@
 	{
 	  PCACHE_SEGMENT current2;
 	  ULONG current_size;
-	  PMDL Mdl;
 	  ULONG i;
 	  ULONG offset;
 
@@ -124,7 +135,7 @@
 	  /*
 	   * Create an MDL which contains all their pages.
 	   */
-	  Mdl = MmCreateMdl(NULL, NULL, current_size);
+          MmInitializeMdl(Mdl, NULL, current_size);
 	  Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
 	  current2 = current;
 	  offset = 0;
@@ -157,6 +168,7 @@
 	     KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
 	     Status = Iosb.Status;
 	  }
+          MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);            
 	  if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
 	    {
 	      while (current != NULL)
@@ -206,8 +218,10 @@
     {
       Size = CacheSeg->Bcb->CacheSegmentSize;
     }
-  Mdl = MmCreateMdl(NULL, CacheSeg->BaseAddress, Size);
+  Mdl = alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size));
+  MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size);
   MmBuildMdlForNonPagedPool(Mdl);
+  Mdl->MdlFlags |= MDL_IO_PAGE_READ;
   KeInitializeEvent(&Event, NotificationEvent, FALSE);
   Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, & Event, &IoStatus); 
   if (Status == STATUS_PENDING)
@@ -246,8 +260,10 @@
     {
       Size = CacheSeg->Bcb->CacheSegmentSize;
     }
-  Mdl = MmCreateMdl(NULL, CacheSeg->BaseAddress, Size);
+  Mdl = alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size));
+  MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size);
   MmBuildMdlForNonPagedPool(Mdl);
+  Mdl->MdlFlags |= MDL_IO_PAGE_READ;
   KeInitializeEvent(&Event, NotificationEvent, FALSE);
   Status = IoPageWrite(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, &Event, &IoStatus);
   if (Status == STATUS_PENDING)
@@ -360,7 +376,7 @@
     }  
   while (Length > 0)
     {
-      TempLength = min(max(Bcb->CacheSegmentSize, 65536), Length);
+      TempLength = min(max(Bcb->CacheSegmentSize, MAX_RW_LENGTH), Length);
       ReadCacheSegmentChain(Bcb, ReadOffset, TempLength, Buffer);
       ReadLength += TempLength;
       Length -= TempLength;
@@ -533,6 +549,8 @@
   if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
     {
       /* File is not cached */
+
+      Mdl = alloca(MmSizeOfMdl(NULL, MAX_ZERO_LENGTH));
  
       while (Length > 0)
 	{
@@ -544,12 +562,7 @@
 	    {
 	      CurrentLength = Length;
 	    }
-          Mdl = MmCreateMdl(NULL, (PVOID)WriteOffset.u.LowPart, CurrentLength);
-
-	  if (Mdl == NULL)
-	    {
-	      return(FALSE);
-	    }
+          MmInitializeMdl(Mdl, (PVOID)WriteOffset.u.LowPart, CurrentLength);
 	  Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
 	  for (i = 0; i < ((Mdl->Size - sizeof(MDL)) / sizeof(ULONG)); i++)
 	    {
@@ -562,6 +575,7 @@
              KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
              Status = Iosb.Status;
 	  }
+          MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);            
 	  if (!NT_SUCCESS(Status))
 	    {
 	      return(FALSE);

reactos/ntoskrnl/include/internal
mm.h 1.80 -> 1.81
diff -u -r1.80 -r1.81
--- mm.h	20 May 2004 08:37:20 -0000	1.80
+++ mm.h	6 Jun 2004 08:36:31 -0000	1.81
@@ -368,9 +368,9 @@
 PVOID 
 MmGetDirtyPagesFromWorkingSet(struct _EPROCESS* Process);
 NTSTATUS 
-MmWriteToSwapPage(SWAPENTRY SwapEntry, PMDL Mdl);
+MmWriteToSwapPage(SWAPENTRY SwapEntry, PHYSICAL_ADDRESS* Page);
 NTSTATUS 
-MmReadFromSwapPage(SWAPENTRY SwapEntry, PMDL Mdl);
+MmReadFromSwapPage(SWAPENTRY SwapEntry, PHYSICAL_ADDRESS* Page);
 VOID 
 MmSetFlagsPage(PHYSICAL_ADDRESS PhysicalAddress, ULONG Flags);
 ULONG 

reactos/ntoskrnl/io
irp.c 1.60 -> 1.61
diff -u -r1.60 -r1.61
--- irp.c	20 Apr 2004 23:14:35 -0000	1.60
+++ irp.c	6 Jun 2004 08:36:31 -0000	1.61
@@ -1,4 +1,4 @@
-/* $Id: irp.c,v 1.60 2004/04/20 23:14:35 gdalsnes Exp $
+/* $Id: irp.c,v 1.61 2004/06/06 08:36:31 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -294,11 +294,15 @@
    /* Windows NT File System Internals, page 165 */
    if (Irp->Flags & (IRP_PAGING_IO|IRP_CLOSE_OPERATION))
    {
-      if (Irp->Flags & IRP_PAGING_IO)
+      /* 
+       * If MDL_IO_PAGE_READ is set, then the caller is responsible 
+       * for deallocating of the mdl. 
+       */
+      if (Irp->Flags & IRP_PAGING_IO &&
+          Irp->MdlAddress &&
+          !(Irp->MdlAddress->MdlFlags & MDL_IO_PAGE_READ))
       {
-         /* FIXME:
-          *   The mdl should be freed by the caller! 
-	       */
+
          if (Irp->MdlAddress->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
          {
             MmUnmapLockedPages(Irp->MdlAddress->MappedSystemVa, Irp->MdlAddress);            

reactos/ntoskrnl/mm
anonmem.c 1.27 -> 1.28
diff -u -r1.27 -r1.28
--- anonmem.c	10 Apr 2004 22:35:25 -0000	1.27
+++ anonmem.c	6 Jun 2004 08:36:31 -0000	1.28
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: anonmem.c,v 1.27 2004/04/10 22:35:25 gdalsnes Exp $
+/* $Id: anonmem.c,v 1.28 2004/06/06 08:36:31 hbirr Exp $
  *
  * PROJECT:     ReactOS kernel
  * FILE:        ntoskrnl/mm/anonmem.c
@@ -46,7 +46,6 @@
 {
    SWAPENTRY SwapEntry;
    LARGE_INTEGER PhysicalAddress;
-   PMDL Mdl;
    NTSTATUS Status;
 
    /*
@@ -99,9 +98,7 @@
    /*
     * Write the page to the pagefile
     */
-   Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-   MmBuildMdlFromPages(Mdl, (PULONG)&PhysicalAddress);
-   Status = MmWriteToSwapPage(SwapEntry, Mdl);
+   Status = MmWriteToSwapPage(SwapEntry, &PhysicalAddress);
    if (!NT_SUCCESS(Status))
    {
       DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
@@ -133,7 +130,6 @@
    BOOL WasDirty;
    SWAPENTRY SwapEntry;
    NTSTATUS Status;
-   PMDL Mdl;
 
    DPRINT("MmPageOutVirtualMemory(Address 0x%.8X) PID %d\n",
           Address, MemoryArea->Process->UniqueProcessId);
@@ -200,9 +196,7 @@
    /*
     * Write the page to the pagefile
     */
-   Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-   MmBuildMdlFromPages(Mdl, (ULONG *)&PhysicalAddress.u.LowPart);
-   Status = MmWriteToSwapPage(SwapEntry, Mdl);
+   Status = MmWriteToSwapPage(SwapEntry, &PhysicalAddress);
    if (!NT_SUCCESS(Status))
    {
       DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
@@ -372,12 +366,9 @@
    if (MmIsPageSwapEntry(NULL, Address))
    {
       SWAPENTRY SwapEntry;
-      PMDL Mdl;
 
       MmDeletePageFileMapping(MemoryArea->Process, Address, &SwapEntry);
-      Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-      MmBuildMdlFromPages(Mdl, (PULONG)&Page);
-      Status = MmReadFromSwapPage(SwapEntry, Mdl);
+      Status = MmReadFromSwapPage(SwapEntry, &Page);
       if (!NT_SUCCESS(Status))
       {
          KEBUGCHECK(0);

reactos/ntoskrnl/mm
section.c 1.150 -> 1.151
diff -u -r1.150 -r1.151
--- section.c	30 May 2004 12:55:11 -0000	1.150
+++ section.c	6 Jun 2004 08:36:31 -0000	1.151
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: section.c,v 1.150 2004/05/30 12:55:11 hbirr Exp $
+/* $Id: section.c,v 1.151 2004/06/06 08:36:31 hbirr Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/mm/section.c
@@ -396,10 +396,7 @@
                    *   process and the current segment (also not within an other process).
                    */
                   NTSTATUS Status;
-                  PMDL Mdl;
-                  Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-                  MmBuildMdlFromPages(Mdl, (PULONG)&Page);
-                  Status = MmWriteToSwapPage(SavedSwapEntry, Mdl);
+                  Status = MmWriteToSwapPage(SavedSwapEntry, &Page);
                   if (!NT_SUCCESS(Status))
                   {
                      DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n", Status);
@@ -792,7 +789,6 @@
        * Must be private page we have swapped out.
        */
       SWAPENTRY SwapEntry;
-      PMDL Mdl;
 
       /*
        * Sanity check
@@ -813,9 +809,7 @@
          KEBUGCHECK(0);
       }
 
-      Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-      MmBuildMdlFromPages(Mdl, (PULONG)&Page);
-      Status = MmReadFromSwapPage(SwapEntry, Mdl);
+      Status = MmReadFromSwapPage(SwapEntry, &Page);
       if (!NT_SUCCESS(Status))
       {
          DPRINT1("MmReadFromSwapPage failed, status = %x\n", Status);
@@ -1078,7 +1072,6 @@
    else if (IS_SWAP_FROM_SSE(Entry))
    {
       SWAPENTRY SwapEntry;
-      PMDL Mdl;
 
       SwapEntry = SWAPENTRY_FROM_SSE(Entry);
 
@@ -1095,9 +1088,7 @@
          KEBUGCHECK(0);
       }
 
-      Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-      MmBuildMdlFromPages(Mdl, (PULONG)&Page);
-      Status = MmReadFromSwapPage(SwapEntry, Mdl);
+      Status = MmReadFromSwapPage(SwapEntry, &Page);
       if (!NT_SUCCESS(Status))
       {
          KEBUGCHECK(0);
@@ -1434,7 +1425,6 @@
    PHYSICAL_ADDRESS PhysicalAddress;
    MM_SECTION_PAGEOUT_CONTEXT Context;
    SWAPENTRY SwapEntry;
-   PMDL Mdl;
    ULONG Entry;
    ULONG FileOffset;
    NTSTATUS Status;
@@ -1695,9 +1685,7 @@
    /*
     * Write the page to the pagefile
     */
-   Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-   MmBuildMdlFromPages(Mdl, (PULONG)&PhysicalAddress);
-   Status = MmWriteToSwapPage(SwapEntry, Mdl);
+   Status = MmWriteToSwapPage(SwapEntry, &PhysicalAddress);
    if (!NT_SUCCESS(Status))
    {
       DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
@@ -1784,7 +1772,6 @@
    PMM_SECTION_SEGMENT Segment;
    PHYSICAL_ADDRESS PhysicalAddress;
    SWAPENTRY SwapEntry;
-   PMDL Mdl;
    ULONG Entry;
    BOOLEAN Private;
    NTSTATUS Status;
@@ -1900,9 +1887,7 @@
    /*
     * Write the page to the pagefile
     */
-   Mdl = MmCreateMdl(NULL, NULL, PAGE_SIZE);
-   MmBuildMdlFromPages(Mdl, (PULONG)&PhysicalAddress);
-   Status = MmWriteToSwapPage(SwapEntry, Mdl);
+   Status = MmWriteToSwapPage(SwapEntry, &PhysicalAddress);
    if (!NT_SUCCESS(Status))
    {
       DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
CVSspam 0.2.8