* FILE: ntoskrnl/cc/copy.c
* PURPOSE: Implements cache managers copy interface
*
- * PROGRAMMERS:
+ * PROGRAMMERS: Some people?
+ * Pierre Schweitzer (pierre@reactos.org)
*/
/* INCLUDES ******************************************************************/
IN BOOLEAN Wait,
IN BOOLEAN Retrying)
{
+ PFSRTL_COMMON_FCB_HEADER Fcb;
+ PROS_SHARED_CACHE_MAP SharedCacheMap;
+
CCTRACE(CC_API_DEBUG, "FileObject=%p BytesToWrite=%lu Wait=%d Retrying=%d\n",
FileObject, BytesToWrite, Wait, Retrying);
return FALSE;
}
- /* FIXME: Handle per-file threshold */
+ /* Is there a limit per file object? */
+ Fcb = FileObject->FsContext;
+ SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap;
+ if (!BooleanFlagOn(Fcb->Flags, FSRTL_FLAG_LIMIT_MODIFIED_PAGES) ||
+ SharedCacheMap->DirtyPageThreshold == 0)
+ {
+ /* Nope, so that's fine, allow write operation */
+ return TRUE;
+ }
+
+ /* Is dirty page count above local threshold? */
+ if (SharedCacheMap->DirtyPages > SharedCacheMap->DirtyPageThreshold)
+ {
+ return FALSE;
+ }
+
+ /* We cannot write if dirty pages count will bring use above
+ * XXX: Might not be accurate
+ */
+ if (SharedCacheMap->DirtyPages + (BytesToWrite / PAGE_SIZE) > SharedCacheMap->DirtyPageThreshold)
+ {
+ return FALSE;
+ }
return TRUE;
}