Author: arty Date: Tue Nov 24 01:48:06 2009 New Revision: 44278
URL: http://svn.reactos.org/svn/reactos?rev=44278&view=rev Log: Fix bugs: io - weren't at DISPATCH_LEVEL when using hyperspace. data - simplify page free and writeback in data sections.
Modified: branches/arty-newcc/ntoskrnl/mm/section/data.c branches/arty-newcc/ntoskrnl/mm/section/io.c
Modified: branches/arty-newcc/ntoskrnl/mm/section/data.c URL: http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/mm/section/d... ============================================================================== --- branches/arty-newcc/ntoskrnl/mm/section/data.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/mm/section/data.c [iso-8859-1] Tue Nov 24 01:48:06 2009 @@ -2216,8 +2216,6 @@ PFILE_OBJECT FileObject; LARGE_INTEGER Offset; SWAPENTRY SavedSwapEntry; - PMM_PAGEOP PageOp; - NTSTATUS Status; PROS_SECTION_OBJECT Section; PMM_SECTION_SEGMENT Segment; PMMSUPPORT AddressSpace; @@ -2234,26 +2232,6 @@ Section = MemoryArea->Data.SectionData.Section; Segment = MemoryArea->Data.SectionData.Segment; FileObject = Section->FileObject; - - PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset.QuadPart); - - while (PageOp) - { - MmUnlockSectionSegment(Segment); - MmUnlockAddressSpace(AddressSpace); - - Status = MmspWaitForPageOpCompletionEvent(PageOp); - if (Status != STATUS_SUCCESS) - { - DPRINT1("Failed to wait for page op, status = %x\n", Status); - ASSERT(FALSE); - } - - MmLockAddressSpace(AddressSpace); - MmLockSectionSegment(Segment); - MmspCompleteAndReleasePageOp(PageOp); - PageOp = MmCheckForPageOp(MemoryArea, NULL, NULL, Segment, Offset.QuadPart); - }
Entry = MiGetPageEntrySectionSegment(Segment, &Offset);
@@ -2263,8 +2241,17 @@ */ if (Page == PFN_FROM_SSE(Entry) && Dirty) { - DPRINT("Writing back dirty section page %08x%08x\n", Offset.u.HighPart, Offset.u.LowPart); - Status = MiWriteBackPage(FileObject, &Offset, PAGE_SIZE, Page); + MmReferencePage(Page); + MmUnlockSectionSegment(Segment); + MiWriteBackPage(FileObject, &Offset, PAGE_SIZE, Page); + MmLockSectionSegment(Segment); + MmDereferencePage(Page); + Entry = MiGetPageEntrySectionSegment(Segment, &Offset); + if (Page != PFN_FROM_SSE(Entry)) + { + // Somebody else freed the page while we were unlocked + return; + } }
if (SwapEntry != 0)
Modified: branches/arty-newcc/ntoskrnl/mm/section/io.c URL: http://svn.reactos.org/svn/reactos/branches/arty-newcc/ntoskrnl/mm/section/i... ============================================================================== --- branches/arty-newcc/ntoskrnl/mm/section/io.c [iso-8859-1] (original) +++ branches/arty-newcc/ntoskrnl/mm/section/io.c [iso-8859-1] Tue Nov 24 01:48:06 2009 @@ -431,13 +431,16 @@ NTSTATUS Status; PVOID Hyperspace; IO_STATUS_BLOCK Iosb; + KIRQL OldIrql; PVOID PageBuffer = ExAllocatePool(NonPagedPool, PAGE_SIZE);
if (!PageBuffer) return STATUS_NO_MEMORY;
+ OldIrql = KfRaiseIrql(DISPATCH_LEVEL); Hyperspace = MmCreateHyperspaceMapping(Page); RtlCopyMemory(PageBuffer, Hyperspace, PAGE_SIZE); MmDeleteHyperspaceMapping(Hyperspace); + KfLowerIrql(OldIrql);
DPRINT("MiWriteBackPage(%wZ,%08x%08x)\n", &FileObject->FileName, FileOffset->u.HighPart, FileOffset->u.LowPart); Status = MiSimpleWrite