Increase the write back count in CcRosFlushDirtyPages

according to the dirty page count from cache manager.

svn path=/trunk/; revision=4086
This commit is contained in:
Hartmut Birr 2003-01-30 18:30:53 +00:00
parent 945450876a
commit ec65b164ca

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: view.c,v 1.55 2003/01/11 15:24:38 hbirr Exp $ /* $Id: view.c,v 1.56 2003/01/30 18:30:53 hbirr Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/view.c * FILE: ntoskrnl/cc/view.c
@ -82,6 +82,7 @@ static LIST_ENTRY DirtySegmentListHead;
static LIST_ENTRY CacheSegmentListHead; static LIST_ENTRY CacheSegmentListHead;
static LIST_ENTRY CacheSegmentLRUListHead; static LIST_ENTRY CacheSegmentLRUListHead;
static LIST_ENTRY ClosedListHead; static LIST_ENTRY ClosedListHead;
static ULONG DirtyPageCount=0;
static FAST_MUTEX ViewLock; static FAST_MUTEX ViewLock;
@ -123,6 +124,7 @@ CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment)
KeAcquireSpinLock(&CacheSegment->Bcb->BcbLock, &oldIrql); KeAcquireSpinLock(&CacheSegment->Bcb->BcbLock, &oldIrql);
CacheSegment->Dirty = FALSE; CacheSegment->Dirty = FALSE;
RemoveEntryList(&CacheSegment->DirtySegmentListEntry); RemoveEntryList(&CacheSegment->DirtySegmentListEntry);
DirtyPageCount -= CacheSegment->Bcb->CacheSegmentSize / PAGE_SIZE;
CacheSegment->ReferenceCount--; CacheSegment->ReferenceCount--;
KeReleaseSpinLock(&CacheSegment->Bcb->BcbLock, oldIrql); KeReleaseSpinLock(&CacheSegment->Bcb->BcbLock, oldIrql);
ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&ViewLock);
@ -141,12 +143,35 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
ULONG PagesPerSegment; ULONG PagesPerSegment;
BOOLEAN Locked; BOOLEAN Locked;
NTSTATUS Status; NTSTATUS Status;
static ULONG WriteCount[4] = {0, 0, 0, 0};
ULONG NewTarget;
DPRINT("CcRosFlushDirtyPages(Target %d)\n", Target); DPRINT("CcRosFlushDirtyPages(Target %d)\n", Target);
(*Count) = 0; (*Count) = 0;
ExAcquireFastMutex(&ViewLock); ExAcquireFastMutex(&ViewLock);
WriteCount[0] = WriteCount[1];
WriteCount[1] = WriteCount[2];
WriteCount[2] = WriteCount[3];
WriteCount[3] = 0;
NewTarget = WriteCount[0] + WriteCount[1] + WriteCount[2];
if (NewTarget < DirtyPageCount)
{
NewTarget = (DirtyPageCount - NewTarget + 3) / 4;
WriteCount[0] += NewTarget;
WriteCount[1] += NewTarget;
WriteCount[2] += NewTarget;
WriteCount[3] += NewTarget;
}
NewTarget = WriteCount[0];
Target = max(NewTarget, Target);
current_entry = DirtySegmentListHead.Flink; current_entry = DirtySegmentListHead.Flink;
if (current_entry == &DirtySegmentListHead) if (current_entry == &DirtySegmentListHead)
{ {
@ -184,6 +209,10 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
ExAcquireFastMutex(&ViewLock); ExAcquireFastMutex(&ViewLock);
current_entry = DirtySegmentListHead.Flink; current_entry = DirtySegmentListHead.Flink;
} }
if (*Count < NewTarget)
{
WriteCount[1] += (NewTarget - *Count);
}
ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&ViewLock);
DPRINT("CcRosFlushDirtyPages() finished\n"); DPRINT("CcRosFlushDirtyPages() finished\n");
@ -276,6 +305,7 @@ CcRosReleaseCacheSegment(PBCB Bcb,
if (!WasDirty && CacheSeg->Dirty) if (!WasDirty && CacheSeg->Dirty)
{ {
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry); InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
} }
RemoveEntryList(&CacheSeg->CacheSegmentLRUListEntry); RemoveEntryList(&CacheSeg->CacheSegmentLRUListEntry);
InsertTailList(&CacheSegmentLRUListHead, &CacheSeg->CacheSegmentLRUListEntry); InsertTailList(&CacheSegmentLRUListHead, &CacheSeg->CacheSegmentLRUListEntry);
@ -351,6 +381,7 @@ CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
{ {
ExAcquireFastMutex(&ViewLock); ExAcquireFastMutex(&ViewLock);
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry); InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&ViewLock);
} }
else else
@ -395,6 +426,7 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
{ {
ExAcquireFastMutex(&ViewLock); ExAcquireFastMutex(&ViewLock);
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry); InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
DirtyPageCount += Bcb->CacheSegmentSize / PAGE_SIZE;
ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&ViewLock);
} }
@ -754,6 +786,8 @@ CcRosFreeCacheSegment(PBCB Bcb, PCACHE_SEGMENT CacheSeg)
if (CacheSeg->Dirty) if (CacheSeg->Dirty)
{ {
RemoveEntryList(&CacheSeg->DirtySegmentListEntry); RemoveEntryList(&CacheSeg->DirtySegmentListEntry);
DirtyPageCount -= Bcb->CacheSegmentSize / PAGE_SIZE;
} }
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&ViewLock);
@ -883,6 +917,7 @@ CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
if (current->Dirty) if (current->Dirty)
{ {
RemoveEntryList(&current->DirtySegmentListEntry); RemoveEntryList(&current->DirtySegmentListEntry);
DirtyPageCount -= Bcb->CacheSegmentSize / PAGE_SIZE;
DPRINT1("Freeing dirty segment\n"); DPRINT1("Freeing dirty segment\n");
} }
InsertHeadList(&FreeList, &current->BcbSegmentListEntry); InsertHeadList(&FreeList, &current->BcbSegmentListEntry);