filesystem dismount and prevent of a remount

Hello,

in my project I have a diskfilter (below partmgr) and a mini filter as file system filter.

Now think about the scenario that I redirect all blocks to a storage location A, after a dismount (why ever) a new storage location B will be choosen and with the new mount, the blocks will be directed to location B and so on. Sure all written blocks to A must be available for reads then also from B.

My question is, how can I detect, that during/after a dismount, that the filesystem has written all it’s blocks (cache etc.) and is really dismounted?

Another question is, how can I prevent that a filesystem will be automatically remounted?

Using FSCTL_LOCK_VOLUME / UNLOCK does not allways work, as the fs could be in use.

Norbert

I am not sure whether I understood you completely.

But I think what you are looking for is a dismount operation in your fs
filter.
I think catching FSCTL_DISMOUNT_VOLUME will do for you -
http://msdn.microsoft.com/en-us/library/aa364562(VS.85).aspx.

Regards
Deepak

On Tue, Jul 6, 2010 at 3:19 PM, wrote:

> Hello,
>
> in my project I have a diskfilter (below partmgr) and a mini filter as file
> system filter.
>
> Now think about the scenario that I redirect all blocks to a storage
> location A, after a dismount (why ever) a new storage location B will be
> choosen and with the new mount, the blocks will be directed to location B
> and so on. Sure all written blocks to A must be available for reads then
> also from B.
>
> My question is, how can I detect, that during/after a dismount, that the
> filesystem has written all it’s blocks (cache etc.) and is really
> dismounted?
>
> Another question is, how can I prevent that a filesystem will be
> automatically remounted?
>
> Using FSCTL_LOCK_VOLUME / UNLOCK does not allways work, as the fs could be
> in use.
>
>
> Norbert
>
>
>
>
> —
> 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
>

Another scenario is, that I like to power off my storage device when the current filesystem is dismounted.

So you think that after catching the FSCTL_DISMOUNT_VOLUME in a PostFileSystemControl routine in the minifilter, there will be no writes from the system (cache etc.) anymore to this disk?

I’d be rather surprised to see no further writes after an FSCTL_DISMOUNT_VOLUME is sent. This is clearly one of the cases that the FSD must handle (oddly, I spent several hours yesterday looking at a deadlock on CDFS in exactly their code handling race conditions between dismount and everything else.) Similarly, Cc or Mm might choose to flush changes out arbitrarily (even AFTER the dismount occurs, but the FSD should be able to handle this as it is a “normal” condition.)

Wouldn’t it be better to think of this as a device removal event (which isn’t the same as dismount, albeit similar?) When the device removal occurs you’d be safe to power down the device.

Tony
OSR

> Another scenario is, that I like to power off my storage device

Storage device has its own PPO, and you cannot make such decisions.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com