buffer validity in IRP_MJ_WRITE

Couple of queries regarding IRP_MJ_WRITE…
1.Does the buffer/MDL passed in IRP_MJ_WRITE remain valid in completion routine of IRP_MJ_WRITE?
2.What is the maximum size of buffer/MDL that can be passed in IRP_MJ_WRITE?

Thanks in advance.

  1. The MDL won’t be torn down until after completion, unless someone else is
    not playing by the rules. If you are accessing a user mode buffer in the
    completion routine, you may not be in the correct context for the address to
    be valid but if it is mapped to an MDL then you can always grab a system
    address.

  2. For paging requests, you will get up to 64KB requests, described by an
    MDL, but this will change in Vista. For non-cached requests, the size of the
    buffer can be any size the user requests.

Pete

Kernel Drivers
Windows Filesystem and Device Driver Consulting
www.KernelDrivers.com
(303)546-0300

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-257851-
xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Monday, July 31, 2006 12:24 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] buffer validity in IRP_MJ_WRITE

Couple of queries regarding IRP_MJ_WRITE…
1.Does the buffer/MDL passed in IRP_MJ_WRITE remain valid in completion
routine of IRP_MJ_WRITE?
2.What is the maximum size of buffer/MDL that can be passed in
IRP_MJ_WRITE?

Thanks in advance.


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi,

  1. Depend from the request. For example, MDLs for PAGING_IO can’t be freed
    by the underlying driver( may be unlocked, but due to caller’s PFN
    references pages will be valid ), because this MDLs are not allocated in
    IoAllocateMdl. For non paging write the MDL may be unlocked and freed by the
    underlying driver.

  2. I think theoretically it is the minimum from the full size of the
    kernel’s virtual memory( the system must be able to map MDL, on IA-32 the
    kernel’s VA size is 2 or 1 GB ) and the machine’s physical memory( the MDL
    describes the resident pages ).

wrote in message news:xxxxx@ntfsd…
> Couple of queries regarding IRP_MJ_WRITE…
> 1.Does the buffer/MDL passed in IRP_MJ_WRITE remain valid in completion
> routine of IRP_MJ_WRITE?
> 2.What is the maximum size of buffer/MDL that can be passed in
> IRP_MJ_WRITE?
>
> Thanks in advance.
>

Missprint - instead “MDLs for PAGING_IO … may be unlocked” read “MDLs
for PAGING_IO … may be unmapped”,
the underlying driver can’t unlock it, this results in premature PFN’s
reference count dropping to zero.

“Slava Imameyev” wrote in message news:xxxxx@ntfsd…
> Hi,
>
> 1. Depend from the request. For example, MDLs for PAGING_IO can’t be freed
> by the underlying driver( may be unlocked, but due to caller’s PFN
> references pages will be valid ), because this MDLs are not allocated in
> IoAllocateMdl. For non paging write the MDL may be unlocked and freed by
> the underlying driver.
>
> 2. I think theoretically it is the minimum from the full size of the
> kernel’s virtual memory( the system must be able to map MDL, on IA-32 the
> kernel’s VA size is 2 or 1 GB ) and the machine’s physical memory( the MDL
> describes the resident pages ).
>
> wrote in message news:xxxxx@ntfsd…
>> Couple of queries regarding IRP_MJ_WRITE…
>> 1.Does the buffer/MDL passed in IRP_MJ_WRITE remain valid in completion
>> routine of IRP_MJ_WRITE?
>> 2.What is the maximum size of buffer/MDL that can be passed in
>> IRP_MJ_WRITE?
>>
>> Thanks in advance.
>>
>
>
>

> 1.Does the buffer/MDL passed in IRP_MJ_WRITE remain valid in completion

routine of IRP_MJ_WRITE?

Yes.

2.What is the maximum size of buffer/MDL that can be passed in
IRP_MJ_WRITE?

32MB in 32bit Windows IIRC.

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