The mdl from IRP_MN_MDL read

What kind of mdl does one get from IRP_MN_MDL read? Should I call
MmProbeAndLockPages on it before handing it to TDI_SEND?


Nyhet! Hotmail direkt i Mobilen! http://mobile.msn.com/

No. MDLs in the IRPs coming up to your dispatch routines are always probed
and locked.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Peter Hallberg”
To: “Windows File Systems Devs Interest List”
Sent: Saturday, April 08, 2006 7:51 PM
Subject: [ntfsd] The mdl from IRP_MN_MDL read

> What kind of mdl does one get from IRP_MN_MDL read? Should I call
> MmProbeAndLockPages on it before handing it to TDI_SEND?
>
> _________________________________________________________________
> Nyhet! Hotmail direkt i Mobilen! http://mobile.msn.com/
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Do you mean to be specific which of these following?

a. IRP_MJ_READ where MinorFunction is equal to IRP_MN_MDL
b. IRP_MJ_READ where MinorFunction is not equal to IRP_MN_MDL and the
MdlAddress is not null

However, the short answer, in neither case, do you need to call
MmProbeAndLockPages.

“Peter Hallberg” wrote in message
news:xxxxx@ntfsd…
> What kind of mdl does one get from IRP_MN_MDL read? Should I call
> MmProbeAndLockPages on it before handing it to TDI_SEND?
>
> _________________________________________________________________
> Nyhet! Hotmail direkt i Mobilen! http://mobile.msn.com/
>
>

>Do you mean to be specific which of these following?

a. IRP_MJ_READ where MinorFunction is equal to IRP_MN_MDL

Yes, thats what I meant, I have find very little documentation on this kind
of read, so is it true that I don’t need to do MmProbeAndLockPages on it.
Also can I close the file and still use the Mdl until I deallocate it?
Another question, can the Mdl be returned with
IRP_MN_MDL_COMPLETE at dispatch level from a completion routine?


Nyhet! Hotmail direkt i din Mobil! http://mobile.msn.com/

Indeed you find little documentation of these minor functions. These are
implemented for SRV and its ilk and I suppose are not intended for general
use. I have the impression you are sending these IRP yourself as opposed to
these being something you happen to see in a filter driver?

It is true you need not (should not) do MmProbeAndLockPages on the Mdl which
is created with IRP_MJ_READ IRP_MN_MDL and destroyed with IRP_MJ_READ
IRP_MN_MDL_COMPLETE. MmGetSystemAddressForMdlSafe will be your friend here I
think.

I do not know about closing the file. It seems a strange notion to me
however since if you have in hand the Mdl from IRP_MJ_READ IRP_MN_MDL for
sure you need to send IRP_MJ_READ IRP_MN_MDL_COMPLETE for that same Mdl and
AFAIK you will need to have same FileObject in both IRP.

You must not AFAIK ever send an IRP to file system device stack at dispatch
level. I suppose you should not send IRP_MJ_READ IRP_MN_MDL_COMPLETE at
dispatch level from a completion routine.

“Peter Hallberg” wrote in message
news:xxxxx@ntfsd…
> >Do you mean to be specific which of these following?
>
>>a. IRP_MJ_READ where MinorFunction is equal to IRP_MN_MDL
>
> Yes, thats what I meant, I have find very little documentation on this
> kind of read, so is it true that I don’t need to do MmProbeAndLockPages on
> it. Also can I close the file and still use the Mdl until I deallocate it?
> Another question, can the Mdl be returned with
> IRP_MN_MDL_COMPLETE at dispatch level from a completion routine?
>
> _________________________________________________________________
> Nyhet! Hotmail direkt i din Mobil! http://mobile.msn.com/
>
>

>It is true you need not (should not) do MmProbeAndLockPages

It is sometimes said that it doesn’t hurt to do MmProbeAndLockPages when it
isn’t needed so I did some testing on Windows 2000 and discovered that if I
do MmProbeAndLockPages the mdl whill never be fully deallocated by the fsd
even if I do MmUnlockPages before IRP_MN_MDL_COMPLETE. However it seems to
work if I skip MmProbeAndLockPages as you said.

I do not know about closing the file. It seems a strange notion to me

After some thinking I have come to the conclusion that it should be possible
to close the file handle and only save a fileobject pointer after getting
the mdl because this will only send CLEANUP to the fsd, then I can access
the memory in the cache through the mdl without the fsd intervention and
when finally releasing the mdl the fsd can terminate caching (CLOSE).

ou must not AFAIK ever send an IRP to file system device stack at dispatch

Yes, even IRP_MN_MDL_COMPLETE must be called at passive level, there was
_DPC versions of them but I asume they have been obsolete.


Nyhet! MSN Messenger i Mobiltelefonen! http://mobile.msn.com/

> After some thinking I have come to the conclusion that it should be

possible
to close the file handle and only save a fileobject pointer after getting
the mdl because this will only send CLEANUP to the fsd, then I can access
the memory in the cache through the mdl without the fsd intervention and
when finally releasing the mdl the fsd can terminate caching (CLOSE).

I guess the one concern in my mind is the lore there must be nothing but
paging i/o between CLEANUP and CLOSE.

Yes, even IRP_MN_MDL_COMPLETE must be called at passive level, there was
_DPC versions of them but I asume they have been obsolete.

AFAIK these DPC versations have always been obsolete; these arent supported
in filter manager.