Volume parameter block and IO manager

I have some queries regarding volume parameter block. When do reference count of VPB gets incremented/decremented ? Is it at file object creation time IO manager increments it and at close time decrements it ? Any other place where this gets incremented/decremented ?
For a file system driver to dismount completely ( deleting mounted device object and VCB ),is it mandatory VPB reference count to be zero ?

> Is it at file object creation time IO manager increments it and at close

time decrements it ?

Pretty much, but the rules are a complicated implementation detail and can
change over time (relative opens, device opens, stream file objects, etc.
all have different behavior). Why do you care?

For a file system driver to dismount completely ( deleting mounted device
object and VCB ),is it mandatory VPB reference count to be > zero ?

Not necessarily zero, see FastFat source (trimmed for clarity):

if ((IrpContext->MajorFunction == IRP_MJ_CREATE) &&
(IrpContext->RealDevice == Vcb->CurrentDevice)) {

ResidualReferenceCount = 3;

} else {

ResidualReferenceCount = 2;
}

IoAcquireVpbSpinLock( &SavedIrql );

if (Vcb->Vpb->ReferenceCount == ResidualReferenceCount) {

PVPB Vpb = Vcb->Vpb;

ClearFlag( Vpb->Flags, VPB_MOUNTED );

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntfsd…
>I have some queries regarding volume parameter block. When do reference
>count of VPB gets incremented/decremented ? Is it at file object creation
>time IO manager increments it and at close time decrements it ? Any other
>place where this gets incremented/decremented ?
> For a file system driver to dismount completely ( deleting mounted device
> object and VCB ),is it mandatory VPB reference count to be zero ?
>

xxxxx@gmail.com wrote:

For a file system driver to dismount completely ( deleting mounted device object and VCB ),is it mandatory VPB reference count to be zero ?

Yes.

The filesystem must ensure:

  1. That there are no open objects on the volume, since those could sent
    requests to the device object that is a candidate for deletion.
  2. That there are no in-flight creates which have not yet reached the
    filesystem, but have left the IOmgr. These will be sent to the device
    object that is a candidate for deletion.

The VPB reference count check is to enforce the second condition.

  • M