Lock the MainResource from fcb, if we are trying to write back a modified cache segment.

Usually we have to call the callback function from FSD.

svn path=/trunk/; revision=19691
This commit is contained in:
Hartmut Birr 2005-11-27 15:59:32 +00:00
parent 0c068e7775
commit 30321765c2

View file

@ -244,21 +244,34 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count)
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
DirtySegmentListEntry); DirtySegmentListEntry);
current_entry = current_entry->Flink; current_entry = current_entry->Flink;
// Locked = current->Bcb->Callbacks.AcquireForLazyWrite(current->Bcb->Context, FALSE);
Locked = ExTryToAcquireResourceExclusiveLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
if (!Locked)
{
continue;
}
Locked = CcTryToAcquireBrokenMutex(&current->Lock); Locked = CcTryToAcquireBrokenMutex(&current->Lock);
if (!Locked) if (!Locked)
{ {
// current->Bcb->Callbacks.ReleaseFromLazyWrite(current->Bcb->Context);
ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
continue; continue;
} }
ASSERT(current->Dirty); ASSERT(current->Dirty);
if (current->ReferenceCount > 1) if (current->ReferenceCount > 1)
{ {
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&current->Lock); ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&current->Lock);
// current->Bcb->Callbacks.ReleaseFromLazyWrite(current->Bcb->Context);
ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
continue; continue;
} }
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&ViewLock); ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&ViewLock);
PagesPerSegment = current->Bcb->CacheSegmentSize / PAGE_SIZE; PagesPerSegment = current->Bcb->CacheSegmentSize / PAGE_SIZE;
Status = CcRosFlushCacheSegment(current); Status = CcRosFlushCacheSegment(current);
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&current->Lock); ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&current->Lock);
// current->Bcb->Callbacks.ReleaseFromLazyWrite(current->Bcb->Context);
ExReleaseResourceLite(((FSRTL_COMMON_FCB_HEADER*)(current->Bcb->FileObject->FsContext))->Resource);
if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE)) if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
{ {
DPRINT1("CC: Failed to flush cache segment.\n"); DPRINT1("CC: Failed to flush cache segment.\n");