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

Function Ext2FcbReaperThread

Ext4Fsd/memory.c:3359–3444  ·  view source on GitHub ↗

Reaper thread to release Fcb */

Source from the content-addressed store, hash-verified

3357
3358/* Reaper thread to release Fcb */
3359VOID
3360Ext2FcbReaperThread(
3361 PVOID Context
3362)
3363{
3364 PEXT2_REAPER Reaper = Context;
3365 PEXT2_VCB Vcb = NULL;
3366 LIST_ENTRY List, *Link;
3367 LARGE_INTEGER Timeout;
3368
3369 BOOLEAN GlobalAcquired = FALSE;
3370 BOOLEAN DidNothing = FALSE;
3371 BOOLEAN NonWait = FALSE;
3372
3373 __try {
3374
3375 Reaper->Thread = PsGetCurrentThread();
3376
3377 /* wake up DirverEntry */
3378 KeSetEvent(&Reaper->Engine, 0, FALSE);
3379
3380 /* now process looping */
3381 while (!IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP)) {
3382
3383 /* wait until it is waken or it times out */
3384 if (NonWait) {
3385 Timeout.QuadPart = (LONGLONG)-10*1000*100;
3386 NonWait = FALSE;
3387 } else if (DidNothing) {
3388 Timeout.QuadPart = Timeout.QuadPart * 2;
3389 } else {
3390 Timeout.QuadPart = (LONGLONG)-10*1000*1000*20; /* 20 seconds */
3391 }
3392 KeWaitForSingleObject(
3393 &Reaper->Wait,
3394 Executive,
3395 KernelMode,
3396 FALSE,
3397 &Timeout
3398 );
3399
3400 if (IsFlagOn(Reaper->Flags, EXT2_REAPER_FLAG_STOP))
3401 break;
3402
3403 InitializeListHead(&List);
3404
3405 /* acquire global exclusive lock */
3406 ExAcquireResourceSharedLite(&Ext2Global->Resource, TRUE);
3407 GlobalAcquired = TRUE;
3408 /* search all Vcb to get unused resources freed to system */
3409 for (Link = Ext2Global->VcbList.Flink;
3410 Link != &(Ext2Global->VcbList);
3411 Link = Link->Flink ) {
3412
3413 Vcb = CONTAINING_RECORD(Link, EXT2_VCB, Next);
3414 NonWait = Ext2QueryUnusedFcb(Vcb, &List);
3415 }
3416 DidNothing = IsListEmpty(&List);

Callers

nothing calls this directly

Calls 2

Ext2QueryUnusedFcbFunction · 0.85
Ext2FreeFcbFunction · 0.85

Tested by

no test coverage detected