mirror of
https://github.com/reactos/reactos.git
synced 2025-01-02 12:32:47 +00:00
- Allocate memory for mdl's for paging io from stack instead of the non paged pool.
svn path=/trunk/; revision=9631
This commit is contained in:
parent
3b09731efb
commit
353214e42e
5 changed files with 47 additions and 53 deletions
|
@ -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 @@ static PHYSICAL_ADDRESS CcZeroPage = { 0 };
|
|||
#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 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
|
|||
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 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
|
|||
{
|
||||
PCACHE_SEGMENT current2;
|
||||
ULONG current_size;
|
||||
PMDL Mdl;
|
||||
ULONG i;
|
||||
ULONG offset;
|
||||
|
||||
|
@ -124,7 +135,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
|
|||
/*
|
||||
* 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 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
|
|||
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 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
|
|||
{
|
||||
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 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg)
|
|||
{
|
||||
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 @@ CcCopyRead (IN PFILE_OBJECT FileObject,
|
|||
}
|
||||
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 @@ CcZeroData (IN PFILE_OBJECT FileObject,
|
|||
if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
|
||||
{
|
||||
/* File is not cached */
|
||||
|
||||
Mdl = alloca(MmSizeOfMdl(NULL, MAX_ZERO_LENGTH));
|
||||
|
||||
while (Length > 0)
|
||||
{
|
||||
|
@ -544,12 +562,7 @@ CcZeroData (IN PFILE_OBJECT FileObject,
|
|||
{
|
||||
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 @@ CcZeroData (IN PFILE_OBJECT FileObject,
|
|||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||
Status = Iosb.Status;
|
||||
}
|
||||
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(FALSE);
|
||||
|
|
|
@ -368,9 +368,9 @@ extern MM_STATS MmStats;
|
|||
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
|
||||
|
|
|
@ -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 @@ IofCompleteRequest(PIRP Irp,
|
|||
/* 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);
|
||||
|
|
|
@ -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 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
|||
{
|
||||
SWAPENTRY SwapEntry;
|
||||
LARGE_INTEGER PhysicalAddress;
|
||||
PMDL Mdl;
|
||||
NTSTATUS Status;
|
||||
|
||||
/*
|
||||
|
@ -99,9 +98,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
|||
/*
|
||||
* 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 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
|||
BOOL WasDirty;
|
||||
SWAPENTRY SwapEntry;
|
||||
NTSTATUS Status;
|
||||
PMDL Mdl;
|
||||
|
||||
DPRINT("MmPageOutVirtualMemory(Address 0x%.8X) PID %d\n",
|
||||
Address, MemoryArea->Process->UniqueProcessId);
|
||||
|
@ -200,9 +196,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
|||
/*
|
||||
* 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 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
|||
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);
|
||||
|
|
|
@ -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 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
|
|||
* 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 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
* Must be private page we have swapped out.
|
||||
*/
|
||||
SWAPENTRY SwapEntry;
|
||||
PMDL Mdl;
|
||||
|
||||
/*
|
||||
* Sanity check
|
||||
|
@ -813,9 +809,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
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 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
else if (IS_SWAP_FROM_SSE(Entry))
|
||||
{
|
||||
SWAPENTRY SwapEntry;
|
||||
PMDL Mdl;
|
||||
|
||||
SwapEntry = SWAPENTRY_FROM_SSE(Entry);
|
||||
|
||||
|
@ -1095,9 +1088,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
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 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
PHYSICAL_ADDRESS PhysicalAddress;
|
||||
MM_SECTION_PAGEOUT_CONTEXT Context;
|
||||
SWAPENTRY SwapEntry;
|
||||
PMDL Mdl;
|
||||
ULONG Entry;
|
||||
ULONG FileOffset;
|
||||
NTSTATUS Status;
|
||||
|
@ -1695,9 +1685,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
/*
|
||||
* 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 @@ MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
PMM_SECTION_SEGMENT Segment;
|
||||
PHYSICAL_ADDRESS PhysicalAddress;
|
||||
SWAPENTRY SwapEntry;
|
||||
PMDL Mdl;
|
||||
ULONG Entry;
|
||||
BOOLEAN Private;
|
||||
NTSTATUS Status;
|
||||
|
@ -1900,9 +1887,7 @@ MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
/*
|
||||
* 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",
|
||||
|
|
Loading…
Reference in a new issue