ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
30 participants
434 discussions
Start a n
N
ew thread
[reactos] 77/100: [NTOS:PO] Flush dirty pages after flushing volumes
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=48e1c8593f97b278ce02a…
commit 48e1c8593f97b278ce02a78cd3002368ee92d907 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Jan 21 16:39:27 2021 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:PO] Flush dirty pages after flushing volumes --- ntoskrnl/po/power.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ntoskrnl/po/power.c b/ntoskrnl/po/power.c index 6dee7054c02..125edbc11df 100644 --- a/ntoskrnl/po/power.c +++ b/ntoskrnl/po/power.c @@ -1072,18 +1072,19 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction, /* Check if we're still in an invalid status */ if (!NT_SUCCESS(Status)) break; + /* Flush all volumes and the registry */ + DPRINT("Flushing volumes\n"); + PopFlushVolumes(PopAction.Shutdown); + #ifndef NEWCC /* Flush dirty cache pages */ /* XXX: Is that still mandatory? As now we'll wait on lazy writer to complete? */ - CcRosFlushDirtyPages(MAXULONG, &Dummy, TRUE, FALSE); //HACK: We really should wait here! + CcRosFlushDirtyPages(MAXULONG, &Dummy, TRUE, FALSE); + DPRINT("Cache flushed %lu pages\n", Dummy); #else Dummy = 0; #endif - /* Flush all volumes and the registry */ - DPRINT("Flushing volumes, cache flushed %lu pages\n", Dummy); - PopFlushVolumes(PopAction.Shutdown); - /* Set IRP for drivers */ PopAction.IrpMinor = IRP_MN_SET_POWER; if (PopAction.Shutdown)
3 years, 10 months
1
0
0
0
[reactos] 76/100: [NTOS:CC][NTOS:MM] Try respecting ValidDataLength
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5949d5095d95d1ab5118f…
commit 5949d5095d95d1ab5118f24f00193ded2670b825 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jan 5 18:39:55 2021 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC][NTOS:MM] Try respecting ValidDataLength --- ntoskrnl/cc/copy.c | 38 ++++++++++++++++++++++++++++++++++++-- ntoskrnl/cc/fs.c | 1 + ntoskrnl/cc/pin.c | 5 +++++ ntoskrnl/cc/view.c | 1 + ntoskrnl/include/internal/cc.h | 1 + ntoskrnl/mm/section.c | 15 ++++++++++++--- 6 files changed, 56 insertions(+), 5 deletions(-) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index 677ab00dd2f..8ed24f2bd92 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -504,6 +504,24 @@ CcCopyRead ( CurrentOffset = FileOffset->QuadPart; while(CurrentOffset < ReadEnd) { + if (CurrentOffset >= SharedCacheMap->ValidDataLength.QuadPart) + { + DPRINT1("Zeroing buffer because we are beyond the VDL.\n"); + /* We are beyond what is valid. Just zero this out */ + _SEH2_TRY + { + RtlZeroMemory(Buffer, Length); + } + _SEH2_EXCEPT(CcpCheckInvalidUserBuffer(_SEH2_GetExceptionInformation(), Buffer, Length)) + { + ExRaiseStatus(STATUS_INVALID_USER_BUFFER); + } + _SEH2_END; + + ReadLength += Length; + break; + } + Status = CcRosGetVacb(SharedCacheMap, CurrentOffset, &Vacb); if (!NT_SUCCESS(Status)) { @@ -598,7 +616,7 @@ CcCopyWrite ( PROS_SHARED_CACHE_MAP SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; NTSTATUS Status; LONGLONG CurrentOffset; - LONGLONG WriteEnd = FileOffset->QuadPart + Length; + LONGLONG WriteEnd; CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%I64d Length=%lu Wait=%d Buffer=%p\n", FileObject, FileOffset->QuadPart, Length, Wait, Buffer); @@ -610,7 +628,11 @@ CcCopyWrite ( if (!SharedCacheMap) return FALSE; - ASSERT((FileOffset->QuadPart + Length) <= SharedCacheMap->SectionSize.QuadPart); + Status = RtlLongLongAdd(FileOffset->QuadPart, Length, &WriteEnd); + if (!NT_SUCCESS(Status)) + ExRaiseStatus(Status); + + ASSERT(WriteEnd <= SharedCacheMap->SectionSize.QuadPart); CurrentOffset = FileOffset->QuadPart; while(CurrentOffset < WriteEnd) @@ -662,6 +684,10 @@ CcCopyWrite ( if (FileObject->Flags & FO_WRITE_THROUGH) CcFlushCache(FileObject->SectionObjectPointer, FileOffset, Length, NULL); + /* Update VDL */ + if (WriteEnd > SharedCacheMap->ValidDataLength.QuadPart) + SharedCacheMap->ValidDataLength.QuadPart = WriteEnd; + return TRUE; } @@ -871,6 +897,14 @@ CcZeroData ( return TRUE; } + /* See if we should simply truncate the valid data length */ + if ((StartOffset->QuadPart < SharedCacheMap->ValidDataLength.QuadPart) && (EndOffset->QuadPart > SharedCacheMap->ValidDataLength.QuadPart)) + { + DPRINT1("Truncating VDL.\n"); + SharedCacheMap->ValidDataLength = *StartOffset; + return TRUE; + } + ASSERT(EndOffset->QuadPart <= SharedCacheMap->SectionSize.QuadPart); while(WriteOffset.QuadPart < EndOffset->QuadPart) diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c index 7a4c8cf4df2..161833d14e2 100644 --- a/ntoskrnl/cc/fs.c +++ b/ntoskrnl/cc/fs.c @@ -297,6 +297,7 @@ CcSetFileSizes ( OldSectionSize = SharedCacheMap->SectionSize; SharedCacheMap->SectionSize = FileSizes->AllocationSize; SharedCacheMap->FileSize = FileSizes->FileSize; + SharedCacheMap->ValidDataLength = FileSizes->ValidDataLength; KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql); if (FileSizes->AllocationSize.QuadPart < OldSectionSize.QuadPart) diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index ae62d2da0bc..07bfd63241c 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -543,6 +543,7 @@ CcSetDirtyPinnedData ( IN PLARGE_INTEGER Lsn) { PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); + PROS_SHARED_CACHE_MAP SharedCacheMap = iBcb->Vacb->SharedCacheMap; CCTRACE(CC_API_DEBUG, "Bcb=%p Lsn=%p\n", Bcb, Lsn); @@ -555,6 +556,10 @@ CcSetDirtyPinnedData ( { CcRosMarkDirtyVacb(iBcb->Vacb); } + + /* Update VDL */ + if (SharedCacheMap->ValidDataLength.QuadPart < (iBcb->PFCB.MappedFileOffset.QuadPart + iBcb->PFCB.MappedLength)) + SharedCacheMap->ValidDataLength.QuadPart = iBcb->PFCB.MappedFileOffset.QuadPart + iBcb->PFCB.MappedLength; } diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 21fd37ad681..06ec86788a9 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -1182,6 +1182,7 @@ CcRosInitializeFileCache ( SharedCacheMap->LazyWriteContext = LazyWriterContext; SharedCacheMap->SectionSize = FileSizes->AllocationSize; SharedCacheMap->FileSize = FileSizes->FileSize; + SharedCacheMap->ValidDataLength = FileSizes->ValidDataLength; SharedCacheMap->PinAccess = PinAccess; SharedCacheMap->DirtyPageThreshold = 0; SharedCacheMap->DirtyPages = 0; diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h index 6416b2e7d3d..7384d9be0d3 100644 --- a/ntoskrnl/include/internal/cc.h +++ b/ntoskrnl/include/internal/cc.h @@ -175,6 +175,7 @@ typedef struct _ROS_SHARED_CACHE_MAP LARGE_INTEGER FileSize; LIST_ENTRY BcbList; LARGE_INTEGER SectionSize; + LARGE_INTEGER ValidDataLength; PFILE_OBJECT FileObject; ULONG DirtyPages; LIST_ENTRY SharedCacheMapLinks; diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index b30462094c7..7ff5485ae81 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1167,11 +1167,13 @@ MiCopyFromUserPage(PFN_NUMBER DestPage, const VOID *SrcAddress) } #ifndef NEWCC +static NTSTATUS NTAPI MiReadPage(PMEMORY_AREA MemoryArea, LONGLONG SegOffset, - PPFN_NUMBER Page) + PPFN_NUMBER Page, + BOOLEAN IgnoreSize) /* * FUNCTION: Read a page for a section backed memory area. * PARAMETERS: @@ -1188,6 +1190,7 @@ MiReadPage(PMEMORY_AREA MemoryArea, PFILE_OBJECT FileObject = MemoryArea->SectionData.Segment->FileObject; LARGE_INTEGER FileOffset; KIRQL OldIrql; + PFSRTL_ADVANCED_FCB_HEADER FcbHeader = FileObject->FsContext; FileOffset.QuadPart = MemoryArea->SectionData.Segment->Image.FileOffset + SegOffset; @@ -1197,6 +1200,12 @@ MiReadPage(PMEMORY_AREA MemoryArea, if (!NT_SUCCESS(Status)) return Status; + if ((FileOffset.QuadPart > FcbHeader->ValidDataLength.QuadPart) && !IgnoreSize) + { + /* Quick path : data is not valid; return a zero-page */ + return STATUS_SUCCESS; + } + RtlZeroMemory(MdlBase, sizeof(MdlBase)); MmInitializeMdl(Mdl, NULL, PAGE_SIZE); MmBuildMdlFromPages(Mdl, Page); @@ -1616,7 +1625,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, else { DPRINT("Getting fresh page for file %wZ at offset %I64d.\n", &Segment->FileObject->FileName, Offset.QuadPart); - Status = MiReadPage(MemoryArea, Offset.QuadPart, &Page); + Status = MiReadPage(MemoryArea, Offset.QuadPart, &Page, FALSE); if (!NT_SUCCESS(Status)) { DPRINT1("MiReadPage failed (Status %x)\n", Status); @@ -4592,7 +4601,7 @@ MmMakePagesResident( /* FIXME: Read the whole range at once instead of one page at a time */ /* Ignore file size, as Cc already checked on its side. */ - Status = MiReadPage(MemoryArea, SegmentOffset.QuadPart, &Page); + Status = MiReadPage(MemoryArea, SegmentOffset.QuadPart, &Page, TRUE); if (!NT_SUCCESS(Status)) { /* Reset the Segment entry and fail */
3 years, 10 months
1
0
0
0
[reactos] 75/100: [NTOS:CC] Flush the whole VACB
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bdb73edab7d444cdb5e49…
commit bdb73edab7d444cdb5e49d1a166ccd7d0a721bf7 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jan 5 12:32:26 2021 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Flush the whole VACB Let Mm know what it has to do. --- ntoskrnl/cc/view.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index dab292bd273..21fd37ad681 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -169,8 +169,7 @@ CcRosFlushVacb ( PROS_VACB Vacb) { IO_STATUS_BLOCK Iosb; - SIZE_T FlushSize = min(VACB_MAPPING_GRANULARITY, - Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart); + SIZE_T FlushSize = VACB_MAPPING_GRANULARITY; NTSTATUS Status; BOOLEAN HaveLock = FALSE; @@ -1024,7 +1023,7 @@ CcRosDeleteFileCache ( /* Flush to disk, if needed */ if (Vacb->Dirty) { - SIZE_T FlushSize = min(VACB_MAPPING_GRANULARITY, Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart); + SIZE_T FlushSize = VACB_MAPPING_GRANULARITY; IO_STATUS_BLOCK Iosb; NTSTATUS Status;
3 years, 10 months
1
0
0
0
[reactos] 74/100: [NTOS:CC] Improve trace messages
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=804f5a41edd0af35e881e…
commit 804f5a41edd0af35e881ea69a1595220587777c3 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jan 5 12:32:09 2021 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Improve trace messages --- ntoskrnl/cc/view.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 2aeb9df5b3b..dab292bd273 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -138,8 +138,8 @@ CcRosTraceCacheMap ( current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry); current_entry = current_entry->Flink; - DPRINT1(" VACB 0x%p enabled, RefCount %lu, Dirty %u, PageOut %lu\n", - current, current->ReferenceCount, current->Dirty, current->PageOut ); + DPRINT1(" VACB 0x%p enabled, RefCount %lu, Dirty %u, PageOut %lu, BaseAddress %p, FileOffset %I64d\n", + current, current->ReferenceCount, current->Dirty, current->PageOut, current->BaseAddress, current->FileOffset.QuadPart); } KeReleaseSpinLockFromDpcLevel(&SharedCacheMap->CacheMapLock); @@ -595,12 +595,6 @@ CcRosCreateVacb ( current->PageOut = FALSE; current->FileOffset.QuadPart = ROUND_DOWN(FileOffset, VACB_MAPPING_GRANULARITY); current->SharedCacheMap = SharedCacheMap; -#if DBG - if (SharedCacheMap->Trace) - { - DPRINT1("CacheMap 0x%p: new VACB: 0x%p\n", SharedCacheMap, current); - } -#endif current->MappedCount = 0; current->ReferenceCount = 0; InitializeListHead(¤t->CacheMapVacbListEntry); @@ -633,6 +627,14 @@ Retry: return Status; } +#if DBG + if (SharedCacheMap->Trace) + { + DPRINT1("CacheMap 0x%p: new VACB: 0x%p, file offset %I64d, BaseAddress %p\n", + SharedCacheMap, current, current->FileOffset.QuadPart, current->BaseAddress); + } +#endif + oldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); *Vacb = current;
3 years, 10 months
1
0
0
0
[reactos] 73/100: [NTOS:CC] Simplify CcFlushCache implementation
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=20fe42c9e92093996cbfa…
commit 20fe42c9e92093996cbfafbc046ad037b0f07c0f Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jan 5 10:45:39 2021 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Simplify CcFlushCache implementation --- ntoskrnl/cc/view.c | 90 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 1bd86b2cab7..2aeb9df5b3b 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -899,63 +899,73 @@ CcFlushCache ( OUT PIO_STATUS_BLOCK IoStatus) { PROS_SHARED_CACHE_MAP SharedCacheMap; - LARGE_INTEGER Offset; - LONGLONG RemainingLength; - PROS_VACB current; + LONGLONG FlushStart, FlushEnd; NTSTATUS Status; CCTRACE(CC_API_DEBUG, "SectionObjectPointers=%p FileOffset=0x%I64X Length=%lu\n", SectionObjectPointers, FileOffset ? FileOffset->QuadPart : 0LL, Length); - if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap) + if (!SectionObjectPointers || !SectionObjectPointers->SharedCacheMap) { - SharedCacheMap = SectionObjectPointers->SharedCacheMap; - ASSERT(SharedCacheMap); - if (FileOffset) - { - Offset = *FileOffset; - RemainingLength = Length; - } - else - { - Offset.QuadPart = 0; - RemainingLength = SharedCacheMap->FileSize.QuadPart; - } + Status = STATUS_INVALID_PARAMETER; + goto quit; + } - if (IoStatus) - { - IoStatus->Status = STATUS_SUCCESS; - IoStatus->Information = 0; - } + SharedCacheMap = SectionObjectPointers->SharedCacheMap; + ASSERT(SharedCacheMap); + if (FileOffset) + { + FlushStart = FileOffset->QuadPart; + Status = RtlLongLongAdd(FlushStart, Length, &FlushEnd); + if (!NT_SUCCESS(Status)) + goto quit; + } + else + { + FlushStart = 0; + FlushEnd = SharedCacheMap->FileSize.QuadPart; + } + + Status = STATUS_SUCCESS; + + if (IoStatus) + { + IoStatus->Information = 0; + } - while (RemainingLength > 0) + while (FlushStart < FlushEnd) + { + PROS_VACB vacb = CcRosLookupVacb(SharedCacheMap, FlushStart); + + if (vacb != NULL) { - current = CcRosLookupVacb(SharedCacheMap, Offset.QuadPart); - if (current != NULL) + if (vacb->Dirty) { - if (current->Dirty) + Status = CcRosFlushVacb(vacb); + if (!NT_SUCCESS(Status)) { - Status = CcRosFlushVacb(current); - if (!NT_SUCCESS(Status) && IoStatus != NULL) - { - IoStatus->Status = Status; - } + goto quit; } - - CcRosReleaseVacb(SharedCacheMap, current, FALSE, FALSE); } - Offset.QuadPart += VACB_MAPPING_GRANULARITY; - RemainingLength -= min(RemainingLength, VACB_MAPPING_GRANULARITY); + CcRosReleaseVacb(SharedCacheMap, vacb, FALSE, FALSE); + + if (IoStatus) + IoStatus->Information += VACB_MAPPING_GRANULARITY; } - } - else - { - if (IoStatus) + + if (!NT_SUCCESS(RtlLongLongAdd(FlushStart, VACB_MAPPING_GRANULARITY, &FlushStart))) { - IoStatus->Status = STATUS_INVALID_PARAMETER; + /* We're at the end of file ! */ + break; } } + +quit: + if (IoStatus) + { + IoStatus->Status = Status; + } } NTSTATUS @@ -1188,7 +1198,7 @@ CcRosInitializeFileCache ( FileObject->SectionObjectPointer->SharedCacheMap = SharedCacheMap; - // CcRosTraceCacheMap(SharedCacheMap, TRUE); + //CcRosTraceCacheMap(SharedCacheMap, TRUE); } else if (SharedCacheMap->Flags & SHARED_CACHE_MAP_IN_CREATION) {
3 years, 10 months
1
0
0
0
[reactos] 72/100: [NTOS:CC] Get rid of ROS_VACB:Valid
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b6240ee03eef58f1113b…
commit 9b6240ee03eef58f1113bc6897269d379f68141d Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jan 5 10:41:41 2021 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Get rid of ROS_VACB:Valid --- ntoskrnl/cc/copy.c | 14 +++++++------- ntoskrnl/cc/pin.c | 10 ++++------ ntoskrnl/cc/view.c | 23 ++++++----------------- ntoskrnl/include/internal/cc.h | 3 --- 4 files changed, 17 insertions(+), 33 deletions(-) diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c index 502dfb03ee8..677ab00dd2f 100644 --- a/ntoskrnl/cc/copy.c +++ b/ntoskrnl/cc/copy.c @@ -227,12 +227,12 @@ CcPerformReadAhead( CurrentOffset % VACB_MAPPING_GRANULARITY, PartialLength); if (!NT_SUCCESS(Status)) { - CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); DPRINT1("Failed to read data: %lx!\n", Status); goto Clear; } - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); Length -= PartialLength; CurrentOffset += PartialLength; @@ -254,12 +254,12 @@ CcPerformReadAhead( Status = CcRosEnsureVacbResident(Vacb, TRUE, FALSE, 0, PartialLength); if (!NT_SUCCESS(Status)) { - CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); DPRINT1("Failed to read data: %lx!\n", Status); goto Clear; } - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); Length -= PartialLength; CurrentOffset += PartialLength; @@ -548,7 +548,7 @@ CcCopyRead ( } _SEH2_FINALLY { - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); } _SEH2_END; } @@ -653,7 +653,7 @@ CcCopyWrite ( _SEH2_FINALLY { /* Do not mark the VACB as dirty if an exception was raised */ - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, !_SEH2_AbnormalTermination(), FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, !_SEH2_AbnormalTermination(), FALSE); } _SEH2_END; } @@ -905,7 +905,7 @@ CcZeroData ( _SEH2_FINALLY { /* Do not mark the VACB as dirty if an exception was raised */ - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, !_SEH2_AbnormalTermination(), FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, !_SEH2_AbnormalTermination(), FALSE); } _SEH2_END; } diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index 12b5f87018b..ae62d2da0bc 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -91,7 +91,6 @@ CcpDereferenceBcb( */ CcRosReleaseVacb(SharedCacheMap, Bcb->Vacb, - TRUE, FALSE, FALSE); @@ -121,7 +120,7 @@ CcpGetAppropriateBcb( iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList); if (iBcb == NULL) { - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); return NULL; } @@ -172,7 +171,7 @@ CcpGetAppropriateBcb( if (DupBcb != NULL) { /* Delete the loser */ - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); ExDeleteResourceLite(&iBcb->Lock); ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb); } @@ -282,7 +281,7 @@ CcpPinData( NewBcb = CcpGetAppropriateBcb(SharedCacheMap, Vacb, FileOffset, Length, Flags, TRUE); if (NewBcb == NULL) { - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); return FALSE; } } @@ -383,7 +382,7 @@ CcMapData ( iBcb = CcpGetAppropriateBcb(SharedCacheMap, Vacb, FileOffset, Length, 0, FALSE); if (iBcb == NULL) { - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE); CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> FALSE\n", SharedCacheMap->FileObject, FileOffset, Length, Flags); return FALSE; @@ -660,7 +659,6 @@ CcUnpinRepinnedBcb ( */ CcRosReleaseVacb(iBcb->Vacb->SharedCacheMap, iBcb->Vacb, - TRUE, FALSE, FALSE); diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index b6b7ec57560..1bd86b2cab7 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -342,17 +342,13 @@ NTAPI CcRosReleaseVacb ( PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, - BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped) { ULONG Refs; ASSERT(SharedCacheMap); - DPRINT("CcRosReleaseVacb(SharedCacheMap 0x%p, Vacb 0x%p, Valid %u)\n", - SharedCacheMap, Vacb, Valid); - - Vacb->Valid = Valid; + DPRINT("CcRosReleaseVacb(SharedCacheMap 0x%p, Vacb 0x%p)\n", SharedCacheMap, Vacb); if (Dirty && !Vacb->Dirty) { @@ -595,7 +591,6 @@ CcRosCreateVacb ( current = ExAllocateFromNPagedLookasideList(&VacbLookasideList); current->BaseAddress = NULL; - current->Valid = FALSE; current->Dirty = FALSE; current->PageOut = FALSE; current->FileOffset.QuadPart = ROUND_DOWN(FileOffset, VACB_MAPPING_GRANULARITY); @@ -947,7 +942,7 @@ CcFlushCache ( } } - CcRosReleaseVacb(SharedCacheMap, current, current->Valid, FALSE, FALSE); + CcRosReleaseVacb(SharedCacheMap, current, FALSE, FALSE); } Offset.QuadPart += VACB_MAPPING_GRANULARITY; @@ -1371,14 +1366,14 @@ ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]) UNICODE_STRING NoName = RTL_CONSTANT_STRING(L"No name for File"); KdbpPrint(" Usage Summary (in kb)\n"); - KdbpPrint("Shared\t\tValid\tDirty\tName\n"); + KdbpPrint("Shared\t\tMapped\tDirty\tName\n"); /* No need to lock the spin lock here, we're in DBG */ for (ListEntry = CcCleanSharedCacheMapList.Flink; ListEntry != &CcCleanSharedCacheMapList; ListEntry = ListEntry->Flink) { PLIST_ENTRY Vacbs; - ULONG Valid = 0, Dirty = 0; + ULONG Mapped = 0, Dirty = 0; PROS_SHARED_CACHE_MAP SharedCacheMap; PUNICODE_STRING FileName; PWSTR Extra = L""; @@ -1393,13 +1388,7 @@ ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]) Vacbs != &SharedCacheMap->CacheMapVacbListHead; Vacbs = Vacbs->Flink) { - PROS_VACB Vacb; - - Vacb = CONTAINING_RECORD(Vacbs, ROS_VACB, CacheMapVacbListEntry); - if (Vacb->Valid) - { - Valid += VACB_MAPPING_GRANULARITY / 1024; - } + Mapped += VACB_MAPPING_GRANULARITY / 1024; } /* Setup name */ @@ -1423,7 +1412,7 @@ ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]) } /* And print */ - KdbpPrint("%p\t%d\t%d\t%wZ%S\n", SharedCacheMap, Valid, Dirty, FileName, Extra); + KdbpPrint("%p\t%d\t%d\t%wZ%S\n", SharedCacheMap, Mapped, Dirty, FileName, Extra); } return TRUE; diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h index 32692c01db0..6416b2e7d3d 100644 --- a/ntoskrnl/include/internal/cc.h +++ b/ntoskrnl/include/internal/cc.h @@ -206,8 +206,6 @@ typedef struct _ROS_VACB { /* Base address of the region where the view's data is mapped. */ PVOID BaseAddress; - /* Are the contents of the view valid. */ - BOOLEAN Valid; /* Are the contents of the view newer than those on disk. */ BOOLEAN Dirty; /* Page out in progress */ @@ -387,7 +385,6 @@ NTAPI CcRosReleaseVacb( PROS_SHARED_CACHE_MAP SharedCacheMap, PROS_VACB Vacb, - BOOLEAN Valid, BOOLEAN Dirty, BOOLEAN Mapped );
3 years, 10 months
1
0
0
0
[reactos] 71/100: [NTOS:MM] Disable APC while performing Paged Read
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e46f1a9af37ffd0fd9a99…
commit e46f1a9af37ffd0fd9a99293c66f23acb0990856 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Jan 4 18:26:18 2021 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:MM] Disable APC while performing Paged Read --- ntoskrnl/mm/section.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 1c7fbdbefc6..b30462094c7 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1187,6 +1187,7 @@ MiReadPage(PMEMORY_AREA MemoryArea, PMDL Mdl = (PMDL)MdlBase; PFILE_OBJECT FileObject = MemoryArea->SectionData.Segment->FileObject; LARGE_INTEGER FileOffset; + KIRQL OldIrql; FileOffset.QuadPart = MemoryArea->SectionData.Segment->Image.FileOffset + SegOffset; @@ -1203,6 +1204,9 @@ MiReadPage(PMEMORY_AREA MemoryArea, KeInitializeEvent(&Event, NotificationEvent, FALSE); + /* Disable APCs */ + KeRaiseIrql(APC_LEVEL, &OldIrql); + Status = IoPageRead(FileObject, Mdl, &FileOffset, &Event, &IoStatus); if (Status == STATUS_PENDING) { @@ -1215,6 +1219,8 @@ MiReadPage(PMEMORY_AREA MemoryArea, MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl); } + KeLowerIrql(OldIrql); + if (Status == STATUS_END_OF_FILE) { DPRINT1("Got STATUS_END_OF_FILE at offset %I64d for file %wZ.\n", SegOffset, &FileObject->FileName);
3 years, 10 months
1
0
0
0
[reactos] 70/100: [NTOS:CC] Properly return the public BCBs
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=02167f2fb3f144d259f42…
commit 02167f2fb3f144d259f4279003ede2e01e2105b4 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Dec 30 18:25:02 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Properly return the public BCBs --- ntoskrnl/cc/cacheman.c | 2 +- ntoskrnl/cc/fs.c | 2 +- ntoskrnl/cc/pin.c | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ntoskrnl/cc/cacheman.c b/ntoskrnl/cc/cacheman.c index 6086360db25..fa519d43e7a 100644 --- a/ntoskrnl/cc/cacheman.c +++ b/ntoskrnl/cc/cacheman.c @@ -308,7 +308,7 @@ CcSetBcbOwnerPointer ( IN PVOID Owner ) { - PINTERNAL_BCB iBcb = Bcb; + PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); CCTRACE(CC_API_DEBUG, "Bcb=%p Owner=%p\n", Bcb, Owner); diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c index 5a74ecee48c..7a4c8cf4df2 100644 --- a/ntoskrnl/cc/fs.c +++ b/ntoskrnl/cc/fs.c @@ -45,7 +45,7 @@ NTAPI CcGetFileObjectFromBcb ( IN PVOID Bcb) { - PINTERNAL_BCB iBcb = (PINTERNAL_BCB)Bcb; + PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); CCTRACE(CC_API_DEBUG, "Bcb=%p\n", Bcb); diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index 30cba0a248a..12b5f87018b 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -126,8 +126,8 @@ CcpGetAppropriateBcb( } RtlZeroMemory(iBcb, sizeof(*iBcb)); - iBcb->PFCB.NodeTypeCode = 0xDE45; /* Undocumented (CAPTIVE_PUBLIC_BCB_NODETYPECODE) */ - iBcb->PFCB.NodeByteSize = sizeof(PUBLIC_BCB); + iBcb->PFCB.NodeTypeCode = 0x2FD; /* As per KMTests */ + iBcb->PFCB.NodeByteSize = 0; iBcb->PFCB.MappedLength = Length; iBcb->PFCB.MappedFileOffset = *FileOffset; iBcb->Vacb = Vacb; @@ -308,8 +308,9 @@ CcpPinData( } _SEH2_END; - *Bcb = NewBcb; + *Bcb = &NewBcb->PFCB; *Buffer = (PVOID)((ULONG_PTR)NewBcb->Vacb->BaseAddress + VacbOffset); + return TRUE; } @@ -411,7 +412,7 @@ CcMapData ( } _SEH2_END; - *pBcb = iBcb; + *pBcb = &iBcb->PFCB; *pBuffer = (PVOID)((ULONG_PTR)iBcb->Vacb->BaseAddress + VacbOffset); CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> TRUE Bcb=%p, Buffer %p\n", @@ -451,14 +452,14 @@ CcPinMappedData ( return FALSE; } - iBcb = *Bcb; + iBcb = *Bcb ? CONTAINING_RECORD(*Bcb, INTERNAL_BCB, PFCB) : NULL; ++CcPinMappedDataCount; Result = CcpPinData(SharedCacheMap, FileOffset, Length, Flags, Bcb, &Buffer); if (Result) { - CcUnpinData(iBcb); + CcUnpinData(&iBcb->PFCB); } return Result; @@ -542,10 +543,9 @@ CcSetDirtyPinnedData ( IN PVOID Bcb, IN PLARGE_INTEGER Lsn) { - PINTERNAL_BCB iBcb = Bcb; + PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); - CCTRACE(CC_API_DEBUG, "Bcb=%p Lsn=%p\n", - Bcb, Lsn); + CCTRACE(CC_API_DEBUG, "Bcb=%p Lsn=%p\n", Bcb, Lsn); /* Tell Mm */ MmMakePagesDirty(NULL, @@ -580,7 +580,7 @@ CcUnpinDataForThread ( IN PVOID Bcb, IN ERESOURCE_THREAD ResourceThreadId) { - PINTERNAL_BCB iBcb = Bcb; + PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); CCTRACE(CC_API_DEBUG, "Bcb=%p ResourceThreadId=%lu\n", Bcb, ResourceThreadId); @@ -601,7 +601,7 @@ NTAPI CcRepinBcb ( IN PVOID Bcb) { - PINTERNAL_BCB iBcb = Bcb; + PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); CCTRACE(CC_API_DEBUG, "Bcb=%p\n", Bcb); @@ -618,7 +618,7 @@ CcUnpinRepinnedBcb ( IN BOOLEAN WriteThrough, IN PIO_STATUS_BLOCK IoStatus) { - PINTERNAL_BCB iBcb = Bcb; + PINTERNAL_BCB iBcb = CONTAINING_RECORD(Bcb, INTERNAL_BCB, PFCB); KIRQL OldIrql; PROS_SHARED_CACHE_MAP SharedCacheMap;
3 years, 10 months
1
0
0
0
[reactos] 69/100: [NTOS:CC] Simplify CcRosDeleteFileCache
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33cde2831225c26f4b7af…
commit 33cde2831225c26f4b7afed69dc1f56e4a6ab32b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Dec 30 10:53:31 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Simplify CcRosDeleteFileCache --- ntoskrnl/cc/view.c | 147 +++++++++++++++++++++++++---------------------------- 1 file changed, 68 insertions(+), 79 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 40413a91601..b6b7ec57560 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -974,105 +974,94 @@ CcRosDeleteFileCache ( */ { PLIST_ENTRY current_entry; - PROS_VACB current; - LIST_ENTRY FreeList; ASSERT(SharedCacheMap); + ASSERT(SharedCacheMap == FileObject->SectionObjectPointer->SharedCacheMap); + ASSERT(SharedCacheMap->OpenCount == 0); - SharedCacheMap->OpenCount++; - KeReleaseQueuedSpinLock(LockQueueMasterLock, *OldIrql); + /* Remove all VACBs from the global lists */ + KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock); + current_entry = SharedCacheMap->CacheMapVacbListHead.Flink; + while (current_entry != &SharedCacheMap->CacheMapVacbListHead) + { + PROS_VACB Vacb = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry); - CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, NULL); + RemoveEntryList(&Vacb->VacbLruListEntry); + InitializeListHead(&Vacb->VacbLruListEntry); - *OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); - SharedCacheMap->OpenCount--; - if (SharedCacheMap->OpenCount == 0) + if (Vacb->Dirty) + { + CcRosUnmarkDirtyVacb(Vacb, FALSE); + /* Mark it as dirty again so we know that we have to flush before freeing it */ + Vacb->Dirty = TRUE; + } + + current_entry = current_entry->Flink; + } + + /* Make sure there is no trace anymore of this map */ + FileObject->SectionObjectPointer->SharedCacheMap = NULL; + RemoveEntryList(&SharedCacheMap->SharedCacheMapLinks); + + KeReleaseSpinLockFromDpcLevel(&SharedCacheMap->CacheMapLock); + KeReleaseQueuedSpinLock(LockQueueMasterLock, *OldIrql); + + /* Now that we're out of the locks, free everything for real */ + while (!IsListEmpty(&SharedCacheMap->CacheMapVacbListHead)) { - FileObject->SectionObjectPointer->SharedCacheMap = NULL; + PROS_VACB Vacb = CONTAINING_RECORD(RemoveHeadList(&SharedCacheMap->CacheMapVacbListHead), ROS_VACB, CacheMapVacbListEntry); + ULONG RefCount; - /* - * Release all VACBs - */ - InitializeListHead(&FreeList); - KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock); - while (!IsListEmpty(&SharedCacheMap->CacheMapVacbListHead)) + InitializeListHead(&Vacb->CacheMapVacbListEntry); + + /* Flush to disk, if needed */ + if (Vacb->Dirty) { - current_entry = RemoveTailList(&SharedCacheMap->CacheMapVacbListHead); - KeReleaseSpinLockFromDpcLevel(&SharedCacheMap->CacheMapLock); + SIZE_T FlushSize = min(VACB_MAPPING_GRANULARITY, Vacb->SharedCacheMap->SectionSize.QuadPart - Vacb->FileOffset.QuadPart); + IO_STATUS_BLOCK Iosb; + NTSTATUS Status; - current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry); - RemoveEntryList(¤t->VacbLruListEntry); - InitializeListHead(¤t->VacbLruListEntry); - if (current->Dirty) - { - KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock); - CcRosUnmarkDirtyVacb(current, FALSE); - KeReleaseSpinLockFromDpcLevel(&SharedCacheMap->CacheMapLock); - DPRINT1("Freeing dirty VACB\n"); - } - if (current->MappedCount != 0) + Status = MmFlushVirtualMemory(NULL, &Vacb->BaseAddress, &FlushSize, &Iosb); + if (!NT_SUCCESS(Status)) { - current->MappedCount = 0; - NT_VERIFY(CcRosVacbDecRefCount(current) > 0); - DPRINT1("Freeing mapped VACB\n"); + /* Complain. There's not much we can do */ + DPRINT1("Failed to flush VACB to disk while deleting the cache entry. Status: 0x%08x\n", Status); } - InsertHeadList(&FreeList, ¤t->CacheMapVacbListEntry); - - KeAcquireSpinLockAtDpcLevel(&SharedCacheMap->CacheMapLock); + Vacb->Dirty = FALSE; } -#if DBG - SharedCacheMap->Trace = FALSE; -#endif - KeReleaseSpinLockFromDpcLevel(&SharedCacheMap->CacheMapLock); - KeReleaseQueuedSpinLock(LockQueueMasterLock, *OldIrql); - if(SharedCacheMap->Section) - ObDereferenceObject(SharedCacheMap->Section); - ObDereferenceObject(SharedCacheMap->FileObject); - - while (!IsListEmpty(&FreeList)) - { - ULONG Refs; - - current_entry = RemoveTailList(&FreeList); - current = CONTAINING_RECORD(current_entry, ROS_VACB, CacheMapVacbListEntry); - InitializeListHead(¤t->CacheMapVacbListEntry); - Refs = CcRosVacbDecRefCount(current); + RefCount = CcRosVacbDecRefCount(Vacb); #if DBG // CORE-14578 - if (Refs != 0) + if (RefCount != 0) + { + DPRINT1("Leaking VACB %p attached to %p (%I64d)\n", Vacb, FileObject, Vacb->FileOffset.QuadPart); + DPRINT1("There are: %d references left\n", RefCount); + DPRINT1("Map: %d\n", Vacb->MappedCount); + DPRINT1("Dirty: %d\n", Vacb->Dirty); + if (FileObject->FileName.Length != 0) { - DPRINT1("Leaking VACB %p attached to %p (%I64d)\n", current, FileObject, current->FileOffset.QuadPart); - DPRINT1("There are: %d references left\n", Refs); - DPRINT1("Map: %d\n", current->MappedCount); - DPRINT1("Dirty: %d\n", current->Dirty); - if (FileObject->FileName.Length != 0) - { - DPRINT1("File was: %wZ\n", &FileObject->FileName); - } - else if (FileObject->FsContext != NULL && - ((PFSRTL_COMMON_FCB_HEADER)(FileObject->FsContext))->NodeTypeCode == 0x0502 && - ((PFSRTL_COMMON_FCB_HEADER)(FileObject->FsContext))->NodeByteSize == 0x1F8 && - ((PUNICODE_STRING)(((PUCHAR)FileObject->FsContext) + 0x100))->Length != 0) - { - DPRINT1("File was: %wZ (FastFAT)\n", (PUNICODE_STRING)(((PUCHAR)FileObject->FsContext) + 0x100)); - } - else - { - DPRINT1("No name for the file\n"); - } + DPRINT1("File was: %wZ\n", &FileObject->FileName); } + else + { + DPRINT1("No name for the file\n"); + } + } #else - ASSERT(Refs == 0); + (void)RefCount; #endif - } + } - *OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); - RemoveEntryList(&SharedCacheMap->SharedCacheMapLinks); - KeReleaseQueuedSpinLock(LockQueueMasterLock, *OldIrql); + /* Release the references we own */ + if(SharedCacheMap->Section) + ObDereferenceObject(SharedCacheMap->Section); + ObDereferenceObject(SharedCacheMap->FileObject); + + ExFreeToNPagedLookasideList(&SharedCacheMapLookasideList, SharedCacheMap); + + /* Acquire the lock again for our caller */ + *OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); - ExFreeToNPagedLookasideList(&SharedCacheMapLookasideList, SharedCacheMap); - *OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); - } return STATUS_SUCCESS; }
3 years, 10 months
1
0
0
0
[reactos] 68/100: [NTOS:CC] Remove dead code
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a9193b5cc2891ae888afe…
commit a9193b5cc2891ae888afe059c4833985159efcb0 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Wed Dec 30 09:45:06 2020 +0100 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:CC] Remove dead code --- ntoskrnl/cc/view.c | 18 ------------------ ntoskrnl/include/internal/cc.h | 4 ---- 2 files changed, 22 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 4866db4f849..40413a91601 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -1092,24 +1092,6 @@ CcRosReferenceCache ( KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql); } -VOID -NTAPI -CcRosRemoveIfClosed ( - PSECTION_OBJECT_POINTERS SectionObjectPointer) -{ - PROS_SHARED_CACHE_MAP SharedCacheMap; - KIRQL OldIrql; - - DPRINT("CcRosRemoveIfClosed()\n"); - OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); - SharedCacheMap = SectionObjectPointer->SharedCacheMap; - if (SharedCacheMap && SharedCacheMap->OpenCount == 0) - { - CcRosDeleteFileCache(SharedCacheMap->FileObject, SharedCacheMap, &OldIrql); - } - KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql); -} - NTSTATUS NTAPI CcRosReleaseFileCache ( diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h index 65fd3fe6ffa..32692c01db0 100644 --- a/ntoskrnl/include/internal/cc.h +++ b/ntoskrnl/include/internal/cc.h @@ -382,10 +382,6 @@ VOID NTAPI CcRosReferenceCache(PFILE_OBJECT FileObject); -VOID -NTAPI -CcRosRemoveIfClosed(PSECTION_OBJECT_POINTERS SectionObjectPointer); - NTSTATUS NTAPI CcRosReleaseVacb(
3 years, 10 months
1
0
0
0
← Newer
1
...
31
32
33
34
35
36
37
...
44
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200