MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2McbReaperThread

Function Ext2McbReaperThread

Ext4Fsd/memory.c:3031–3157  ·  view source on GitHub ↗

Reaper thread to release unused Mcb blocks */

Source from the content-addressed store, hash-verified

3029
3030/* Reaper thread to release unused Mcb blocks */
3031VOID
3032Ext2McbReaperThread(
3033 PVOID Context
3034)
3035{
3036 PEXT2_REAPER Reaper = Context;
3037 PLIST_ENTRY List = NULL;
3038 LARGE_INTEGER Timeout;
3039
3040 PEXT2_VCB Vcb = NULL;
3041 PEXT2_MCB Mcb = NULL;
3042
3043 ULONG i, NumOfMcbs;
3044
3045 BOOLEAN GlobalAcquired = FALSE;
3046
3047 BOOLEAN DidNothing = TRUE;
3048 BOOLEAN LastState = TRUE;
3049 BOOLEAN WaitLock;
3050
3051 __try {
3052
3053 Reaper->Thread = PsGetCurrentThread();
3054
3055 /* wake up DirverEntry */
3056 KeSetEvent(&Reaper->Engine, 0, FALSE);
3057
3058 /* now process looping */
3059 while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3060
3061 WaitLock = FALSE;
3062
3063 /* calculate how long we need wait */
3064 if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 128)) {
3065 Timeout.QuadPart = (LONGLONG)-1000*1000; /* 0.1 second */
3066 NumOfMcbs = Ext2Global->MaxDepth * 4;
3067 WaitLock = TRUE;
3068 } else if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 32)) {
3069 Timeout.QuadPart = (LONGLONG)-1000*1000*5; /* 0.5 second */
3070 NumOfMcbs = Ext2Global->MaxDepth * 2;
3071 WaitLock = TRUE;
3072 } else if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 8)) {
3073 Timeout.QuadPart = (LONGLONG)-1000*1000*10; /* 1 second */
3074 NumOfMcbs = Ext2Global->MaxDepth;
3075 } else if (Ext2Global->PerfStat.Current.Mcb > (((ULONG)Ext2Global->MaxDepth) * 2)) {
3076 Timeout.QuadPart = (LONGLONG)-2*1000*1000*10; /* 2 second */
3077 NumOfMcbs = Ext2Global->MaxDepth / 4;
3078 } else if (Ext2Global->PerfStat.Current.Mcb > (ULONG)Ext2Global->MaxDepth) {
3079 Timeout.QuadPart = (LONGLONG)-4*1000*1000*10; /* 4 seconds */
3080 NumOfMcbs = Ext2Global->MaxDepth / 8;
3081 } else if (DidNothing) {
3082 Timeout.QuadPart = (LONGLONG)-8*1000*1000*10; /* 8 seconds */
3083 if (LastState) {
3084 Timeout.QuadPart *= 2;
3085 }
3086 NumOfMcbs = Ext2Global->MaxDepth / 16;
3087 } else {
3088 Timeout.QuadPart = (LONGLONG)-5*1000*1000*10; /* 5 seconds */

Callers

nothing calls this directly

Calls 2

Ext2FirstUnusedMcbFunction · 0.85
Ext2FreeMcbFunction · 0.85

Tested by

no test coverage detected