Thank you.
Fastfat code for 2K3 as below to finalize dismount ( delete datastructures
and devicee ) waits till reference count of Vpb becomes zero.
if (Vcb->Vpb->ReferenceCount == 0 && Vcb->InternalOpenCount == 0) {
Vpb->DeviceObject = NULL;
IoReleaseVpbSpinLock( SavedIrql );
FatDeleteVcb( IrpContext, Vcb );
IoDeleteDevice( (PDEVICE_OBJECT)
CONTAINING_RECORD( Vcb,
VOLUME_DEVICE_OBJECT,
Vcb ) );
VcbDeleted = TRUE;
}
Consider a case, I have couple of files open on the volume, then I do force
dismount. Force dismount will just not allow further opens/creates but
process current open files to be cleaned up. When all files/volume
opens/root directory gets cleaned up then above code snippet will execute.
Correct me if I am wrong ?
I wrote a simple file system driver, which supports IRP_MJ_CREATE,
IRP_MJ_CLEANUP and IRP_MJ_CLOSE and few FSCTLs. It only supports volume and
root directory () open/close. I am handling volume open properly ( Filling
FsContext and Fscontext2 properly and setting FILE_OPENED flag in create and
handling cleanup ( setting FO_CLEANUP_COMPLETE) and close with status
success) but for root directory I just return success setting FILE_OPENED
flag in create handling cleanup and close with status success.
I observed when code only support volume open, reference count of vpb
becomes zero. But when I enable root directory it never becomes zero or
decrements after cleanup. (In case volume, after cleanup reference count
decrements). I put counters for create and cleanup, they match. but still
vpb reference count doesnt become zero and cleanup for the device and data
structure never happens. Any idea, what could be wrong ?
>count doesnt become zero and cleanup for the device and data structure never happens. Any idea,
what could be wrong ?
Just read all FASTFAT source for all places where it touches this counter.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
Thanks Maxim
I looked at fastfat code. Fastfat is touching it in FatPnpQueryRemove path.
Currently, I am not supporting PNP in my driver.
I put counters for create and cleanup, they match. Still, Vpb reference
count equals number of times root directory got opened. Even I am processing
cleanup and close for the same, stlll it is not becoming zero. What could be
wrong in this case ?
On Sat, Aug 29, 2009 at 3:49 AM, Maxim S. Shatskih
wrote:
> >count doesnt become zero and cleanup for the device and data structure
> never happens. Any idea,
> >what could be wrong ?
>
> Just read all FASTFAT source for all places where it touches this counter.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>I looked at fastfat code. Fastfat is touching it in FatPnpQueryRemove path. Currently, I am not
supporting PNP in my driver.
Then support PnP. PnP is not optional modern days.
I put counters for create and cleanup, they match. Still, Vpb reference count equals number of times
root directory got opened
Add instrumentation which will make a list of “Vpb addref causes”, then dump it in the debugger.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com