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

Function Ext2bhReaperThread

Ext4Fsd/memory.c:3211–3296  ·  view source on GitHub ↗

Reaper thread to release unused buffer heads */

Source from the content-addressed store, hash-verified

3209
3210/* Reaper thread to release unused buffer heads */
3211VOID
3212Ext2bhReaperThread(
3213 PVOID Context
3214)
3215{
3216 PEXT2_REAPER Reaper = Context;
3217 PEXT2_VCB Vcb = NULL;
3218 LIST_ENTRY List, *Link;
3219 LARGE_INTEGER Timeout;
3220
3221 BOOLEAN GlobalAcquired = FALSE;
3222 BOOLEAN DidNothing = FALSE;
3223 BOOLEAN NonWait = FALSE;
3224
3225 __try {
3226
3227 Reaper->Thread = PsGetCurrentThread();
3228
3229 /* wake up DirverEntry */
3230 KeSetEvent(&Reaper->Engine, 0, FALSE);
3231
3232 /* now process looping */
3233 while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3234
3235 /* wait until it is waken or it times out */
3236 if (NonWait) {
3237 Timeout.QuadPart = (LONGLONG)-10*1000*10;
3238 NonWait = FALSE;
3239 } else if (DidNothing) {
3240 Timeout.QuadPart = Timeout.QuadPart * 2;
3241 } else {
3242 Timeout.QuadPart = (LONGLONG)-10*1000*1000*10; /* 10 seconds */
3243 }
3244 KeWaitForSingleObject(
3245 &Reaper->Wait,
3246 Executive,
3247 KernelMode,
3248 FALSE,
3249 &Timeout
3250 );
3251
3252 if (IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP))
3253 break;
3254
3255 InitializeListHead(&List);
3256
3257 /* acquire global exclusive lock */
3258 ExAcquireResourceSharedLite(&Ext2Global->Resource, TRUE);
3259 GlobalAcquired = TRUE;
3260 /* search all Vcb to get unused resources freed to system */
3261 for (Link = Ext2Global->VcbList.Flink;
3262 Link != &(Ext2Global->VcbList);
3263 Link = Link->Flink ) {
3264
3265 Vcb = CONTAINING_RECORD(Link, EXT2_VCB, Next);
3266 NonWait = Ext2QueryUnusedBH(Vcb, &List);
3267 }
3268 DidNothing = IsListEmpty(&List);

Callers

nothing calls this directly

Calls 2

Ext2QueryUnusedBHFunction · 0.85
free_buffer_headFunction · 0.85

Tested by

no test coverage detected