* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: view.c,v 1.66 2003/07/11 01:23:14 royce Exp $
+/* $Id: view.c,v 1.67 2003/07/15 19:30:33 hbirr Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/view.c
return(Status);
}
-VOID CcRosRemoveUnusedFiles(VOID);
-
-
NTSTATUS
CcRosFlushDirtyPages(ULONG Target, PULONG Count)
{
*/
{
PLIST_ENTRY current_entry;
- PCACHE_SEGMENT current;
+ PCACHE_SEGMENT current, last = NULL;
ULONG PagesPerSegment;
ULONG PagesFreed;
KIRQL oldIrql;
}
else
{
- KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
+ if (last != current && current->MappedCount > 0 && !current->Dirty)
+ {
+ ULONG i;
+ NTSTATUS Status;
+
+ current->ReferenceCount++;
+ last = current;
+ KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
+ ExReleaseFastMutex(&ViewLock);
+ for (i = 0; i < current->Bcb->CacheSegmentSize / PAGE_SIZE; i++)
+ {
+ PHYSICAL_ADDRESS Page;
+ Page = MmGetPhysicalAddress(current->BaseAddress + i * PAGE_SIZE);
+ Status = MmPageOutPhysicalAddress(Page);
+ if (!NT_SUCCESS(Status))
+ {
+ break;
+ }
+ }
+ ExAcquireFastMutex(&ViewLock);
+ KeAcquireSpinLock(¤t->Bcb->BcbLock, &oldIrql);
+ current->ReferenceCount--;
+ KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
+ current_entry = ¤t->CacheSegmentLRUListEntry;
+ continue;
+ }
+ KeReleaseSpinLock(¤t->Bcb->BcbLock, oldIrql);
}
}
ExReleaseFastMutex(&ViewLock);
{
current->ReferenceCount++;
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
+ ExAcquireFastMutex(¤t->Lock);
return(current);
}
current_entry = current_entry->Flink;
{
KeBugCheck(0);
}
- ExAcquireFastMutex(&CacheSeg->Lock);
if (!CacheSeg->Dirty)
{
ExAcquireFastMutex(&ViewLock);
{
return(STATUS_UNSUCCESSFUL);
}
- ExAcquireFastMutex(&CacheSeg->Lock);
WasDirty = CacheSeg->Dirty;
CacheSeg->Dirty = CacheSeg->Dirty || NowDirty;
NTSTATUS STATIC
CcRosCreateCacheSegment(PBCB Bcb,
ULONG FileOffset,
- PCACHE_SEGMENT* CacheSeg,
- BOOLEAN Lock)
+ PCACHE_SEGMENT* CacheSeg)
{
ULONG i;
PCACHE_SEGMENT current;
ExReleaseFastMutex(&ViewLock);
ExFreeToNPagedLookasideList(&CacheSegLookasideList, *CacheSeg);
*CacheSeg = current;
- if (Lock)
- {
- ExAcquireFastMutex(¤t->Lock);
- }
+ ExAcquireFastMutex(¤t->Lock);
return STATUS_SUCCESS;
}
if (current->FileOffset < FileOffset)
KeBugCheck(0);
}
}
- if (!Lock)
- {
- ExReleaseFastMutex(¤t->Lock);
- }
-
return(STATUS_SUCCESS);
}
}
else
{
- CcRosCreateCacheSegment(Bcb, CurrentOffset, ¤t, FALSE);
+ CcRosCreateCacheSegment(Bcb, CurrentOffset, ¤t);
CacheSegList[i] = current;
}
}
for (i = 0; i < (Length / Bcb->CacheSegmentSize); i++)
{
- ExAcquireFastMutex(&CacheSegList[i]->Lock);
if (i == 0)
{
*CacheSeg = CacheSegList[i];
* Look for a cache segment already mapping the same data.
*/
current = CcRosLookupCacheSegment(Bcb, FileOffset);
- if (current != NULL)
- {
- ExAcquireFastMutex(¤t->Lock);
- }
- else
+ if (current == NULL)
{
/*
* Otherwise create a new segment.
*/
- Status = CcRosCreateCacheSegment(Bcb, FileOffset, ¤t, TRUE);
+ Status = CcRosCreateCacheSegment(Bcb, FileOffset, ¤t);
if (!NT_SUCCESS(Status))
{
return Status;
current = CcRosLookupCacheSegment (Bcb, Offset.u.LowPart);
if (current != NULL)
{
- ExAcquireFastMutex(¤t->Lock);
if (current->Dirty)
{
Status = CcRosFlushCacheSegment(current);
VOID CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer)
{
PBCB Bcb;
-// DPRINT1("CcRosSetRemoveOnClose()\n");
+ DPRINT("CcRosSetRemoveOnClose()\n");
ExAcquireFastMutex(&ViewLock);
Bcb = (PBCB)SectionObjectPointer->SharedCacheMap;
if (Bcb)