Hi,
I have a question regarding the implementation of the AcquireForModWrite
callback.
In one edge case, this callback is blocked waiting on an event. During the
same time,
another thread calls CcPurgeCacheSection, and gets stuck in
KeWaitForSingleObject.
So what are my choices? Return STATUS_CANT_WAIT and hope that the MPW
will retry in its next scan? Or will it simply throw these dirty pages
away?
I understand that returning any status other than SUCCESS or CANT_WAIT will
result in the default behavior (Main/PagingIo resource dependent on
FCB->Flags),
which is not sufficient in our FSD’s case.
So, I shouldn’t really block at all in this callback? Or is there any way to
avoid this
deadlock. I was under the assumption that during AcquireForModWrite,
no VM resources are acquired, to enforce the FSD-CM-VM locking hierarchy.
In this case, it looks like though that the MiMappedPageWriter is holding
some
internal dispatcher object which the MmPurgeSection now wants!
The following are the 2 threads:
0: kd> .thread 85e203a0
Implicit thread is now 85e203a0
0: kd> kbL
*** Stack trace for last set context - .thread/.cxr resets it
ChildEBP RetAddr Args to Child
eb473a34 8042bfc7 eb473b2c eb473a78 80065634 nt!KiSwapThread+0x1b1
eb473a5c f00ee1cf 85984408 00000000 00000000 nt!KeWaitForSingleObject+0x1a3
eb473a8c f012a378 e234af9c e234af30 00000001 MYFSD!__wait+0x3f
eb473aa4 f0105707 e234af8c 00000000 e234af30 MYFSD!__acquire_shared+0x98
eb473ad0 f00f0a3c e234aed0 00000001 00000000 MYFSD!__AcquireObject+0xaf
eb473b2c f00f06a6 e234aed0 00000002 00000000 MYFSD!acq_lock+0x14f
eb473b50 f00f058a e234aed0 00000002 00000000 MYFSD!__LockDataW+0x106
eb473b6c f005649a e234aed0 00000002 00000000 MYFSD!__LockData+0x1a
eb473ca4 f00533f4 00000002 cccccc00 8586db68 MYFSD!LockDataI+0x35a
eb473cec f0058e05 00000002 00000000 8586db68 MYFSD!LockData+0x54
eb473d40 f0052f12 85e207f8 85e2081c eb473d74 MYFSD!AcquireForModWrite+0x175
eb473d50 8049b960 8586db68 85e207f8 85e2081c
MYFSD!FastIoAcquireForModWrite+0x22
eb473d74 8043d0ec 8586db68 85e207f8 85e2081c
nt!FsRtlAcquireFileForModWrite+0x2e
eb473da8 804554ce 00000000 00000000 00000000 nt!MiMappedPageWriter+0xaa
eb473ddc 8046a9d2 8043d042 00000000 00000000 nt!PspSystemThreadStartup+0x54
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16
0: kd> .thread 85864da0
Implicit thread is now 85864da0
0: kd> kbL
*** Stack trace for last set context - .thread/.cxr resets it
ChildEBP RetAddr Args to Child
f01a3a84 8042bfc7 8598f328 8641cd38 85cbeb88 nt!KiSwapThread+0x1b1
f01a3aac 8043e2d6 80483e70 00000013 00000000 nt!KeWaitForSingleObject+0x1a3
f01a3af4 80411158 8598f328 00000000 00000001 nt!MmPurgeSection+0x328
f01a3b5c f0057d9e 858972ec 00000000 00000000 nt!CcPurgeCacheSection+0x108
f01a3b98 f0057a65 00000000 00000000 cccccccc MYFSD!PurgeCacheI+0x28e
f01a3bc8 f0066df1 f01a3cf0 f01a3ca4 00000000 MYFSD!PurgeCache+0xf5
f01a3c88 f006689b 00000000 f01a3cf0 f00f30ee MYFSD!SyncFunctionI+0x541
f01a3c94 f00f30ee 85897148 00000000 f01a3d90 MYFSD!SyncFunction+0x1b
f01a3cf0 f0126c65 e131e788 e25bb020 00000000 MYFSD!DemandLock+0x1c5
f01a3d10 f01267db e23b0c68 e25bb020 e25bb020 MYFSD!process_request+0xc1
f01a3d2c f0151a00 e23b0e28 00000000 00000000 MYFSD!ThreadRoot+0x127
f01a3da8 804554ce 85c7f188 00000000 00000000 MYFSD!ThreadMain+0x109
f01a3ddc 8046a9d2 f01518f7 85c7f188 00000000 nt!PspSystemThreadStartup+0x54
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16
Thanks in advance.
-Vipul.