Author: arty Date: Thu Dec 23 08:42:51 2010 New Revision: 50110
URL: http://svn.reactos.org/svn/reactos?rev=50110&view=rev Log: Do the required flush when the last reference to a cache stripe is released. The installer now completes given enough ram in NEWCC=1, and writes an understandable FS. There's at least one more problem preventing the resulting installation from booting however. Fix a bug in rmap where we were checking the next (unfortunately named current) rmap for a segment membership. Fix a mistake in cache trim. #ifdef detection of DirectMapping in section in NEWCC mode in page out.
Modified: trunk/reactos/ntoskrnl/cache/cachesub.c trunk/reactos/ntoskrnl/cache/fssup.c trunk/reactos/ntoskrnl/cache/newcc.h trunk/reactos/ntoskrnl/cache/pinsup.c trunk/reactos/ntoskrnl/mm/rmap.c trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/cache/cachesub.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/cachesub.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/cache/cachesub.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/cachesub.c [iso-8859-1] Thu Dec 23 08:42:51 2010 @@ -189,12 +189,12 @@ CcpDereferenceCache(Bcb - CcCacheSections, FALSE); } else - CcpUnpinData(Bcb); + CcpUnpinData(Bcb, TRUE); } else { ListEntry = ListEntry->Flink; - CcpUnpinData(Bcb); + CcpUnpinData(Bcb, TRUE); }
DPRINT("End loop\n");
Modified: trunk/reactos/ntoskrnl/cache/fssup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/fssup.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/cache/fssup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/fssup.c [iso-8859-1] Thu Dec 23 08:42:51 2010 @@ -53,7 +53,7 @@ // Reference a cache stripe so it won't go away CcpLock(); if (CcCacheSections[BcbHead].BaseAddress) { - CcpReferenceCache(i); + CcpReferenceCache(BcbHead); CcpUnlock(); } else { CcpUnlock(); @@ -68,7 +68,7 @@ *NrFreed += Freed;
CcpLock(); - CcpDereferenceCache(BcbHead, FALSE); + CcpUnpinData(&CcCacheSections[BcbHead], TRUE); CcpUnlock(); }
@@ -474,10 +474,10 @@ CcpLock(); ListEntry = ListEntry->Flink; // Return from pin state - CcpUnpinData(PinnedBcb); - } - - CcpUnpinData(Bcb); + CcpUnpinData(PinnedBcb, TRUE); + } + + CcpUnpinData(Bcb, TRUE); }
CcpUnlock();
Modified: trunk/reactos/ntoskrnl/cache/newcc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/newcc.h?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/cache/newcc.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/newcc.h [iso-8859-1] Thu Dec 23 08:42:51 2010 @@ -65,9 +65,9 @@ NTAPI CcInitView(VOID);
-VOID +BOOLEAN NTAPI -CcpUnpinData(PNOCC_BCB Bcb); +CcpUnpinData(PNOCC_BCB Bcb, BOOLEAN ActuallyRelease);
BOOLEAN NTAPI
Modified: trunk/reactos/ntoskrnl/cache/pinsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/pinsup.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/cache/pinsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/pinsup.c [iso-8859-1] Thu Dec 23 08:42:51 2010 @@ -707,9 +707,9 @@ return Result; }
-VOID -NTAPI -CcpUnpinData(IN PNOCC_BCB RealBcb) +BOOLEAN +NTAPI +CcpUnpinData(IN PNOCC_BCB RealBcb, BOOLEAN ReleaseBit) { if (RealBcb->RefCount <= 2) { @@ -718,9 +718,11 @@ { DPRINT("Triggering exclusive waiter\n"); KeSetEvent(&RealBcb->ExclusiveWait, IO_NO_INCREMENT, FALSE); - return; + return TRUE; } } + if (RealBcb->RefCount == 2 && !ReleaseBit) + return FALSE; if (RealBcb->RefCount > 1) { DPRINT("Removing one reference #%x\n", RealBcb - CcCacheSections); @@ -730,6 +732,7 @@ if (RealBcb->RefCount == 1) { DPRINT("Clearing allocation bit #%x\n", RealBcb - CcCacheSections); + RtlClearBit(CcCacheBitmap, RealBcb - CcCacheSections);
#ifdef PIN_WRITE_ONLY @@ -745,6 +748,8 @@ &OldProtect); #endif } + + return TRUE; } VOID @@ -753,13 +758,21 @@ { PNOCC_BCB RealBcb = (PNOCC_BCB)Bcb; ULONG Selected = RealBcb - CcCacheSections; + BOOLEAN Released;
ASSERT(RealBcb >= CcCacheSections && RealBcb - CcCacheSections < CACHE_NUM_SECTIONS); DPRINT("CcUnpinData Bcb #%x (RefCount %d)\n", Selected, RealBcb->RefCount);
CcpLock(); - CcpUnpinData(RealBcb); + Released = CcpUnpinData(RealBcb, FALSE); CcpUnlock(); + + if (!Released) { + MiFlushMappedSection(RealBcb->BaseAddress, &RealBcb->FileOffset, &RealBcb->Map->FileSizes.FileSize, RealBcb->Dirty); + CcpLock(); + CcpUnpinData(RealBcb, TRUE); + CcpUnlock(); + } }
VOID
Modified: trunk/reactos/ntoskrnl/mm/rmap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/rmap.c?rev=5011... ============================================================================== --- trunk/reactos/ntoskrnl/mm/rmap.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/rmap.c [iso-8859-1] Thu Dec 23 08:42:51 2010 @@ -365,7 +365,7 @@ previous_entry = current_entry; current_entry = current_entry->Next; #ifdef NEWCC - if (!RMAP_IS_SEGMENT(current_entry->Address)) + if (!RMAP_IS_SEGMENT(previous_entry->Address)) #endif { if (DeleteMapping)
Modified: trunk/reactos/ntoskrnl/mm/section.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=5... ============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Thu Dec 23 08:42:51 2010 @@ -2039,7 +2039,9 @@ ULONG FileOffset; NTSTATUS Status; PFILE_OBJECT FileObject; +#ifndef NEWCC PBCB Bcb = NULL; +#endif BOOLEAN DirectMapped; BOOLEAN IsImageSection; PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace); @@ -2061,6 +2063,7 @@
FileObject = Context.Section->FileObject; DirectMapped = FALSE; +#ifndef NEWCC if (FileObject != NULL && !(Context.Segment->Characteristics & IMAGE_SCN_MEM_SHARED)) { @@ -2077,6 +2080,7 @@ DirectMapped = TRUE; } } +#endif
/*