How to get real read length in advance when the read is paging io?

In a file system filter driver’s irp_mj_read handler, I found when the irp is pagin io, usually the read length is page-aligned, but sometimes the real read length isn’t always a page-aligned value. How can I know then real length in advance before the Irp is passed to lower driver. Any advice is appreciated!

> I found when the irp is pagin io, usually the read length is page-aligned, but sometimes

the real read length isn’t always a page-aligned value.

What is “real read”???

If I got it right, you are speaking about the following scenario:

ZwReadFile() is called on a cached file, with read length not necessarily a multiple of page size. Requested read operation results in cache miss. Therefore, FS receives a secondary IRP_MJ_READ with IRP_NOCACHE flag set and with read length a multiple of page size (because this IRP is the result of the Memory Manager’s involvement) while the original request is still being processed.

Your FS filter driver wants to relate this secondary IRP_MJ_READ with IRP_NOCACHE flag set to the original ZwReadFile() call.

Is it what you are asking about?

Anton Bassov

I’m not quite sure. In my irp_mj_read, before setting completion routine and waiting for lower driver to finished reading, the length for paging io is usually page-aligned value, but after lower driver finished, the REAL length is revealed in the Irp->IoStatus.Information and it’s not page-aligned. How can I get this REAL length and don’t have to let lower drive to get it?

> the REAL length is revealed in the Irp->IoStatus.Information and it’s not

page-aligned. How can I get this REAL length and don’t have to let lower
drive to get it?

The underlying file system driver truncates paging request if it exceeds
beyond a data stream end, so if you know the data stream size( i.e. file
size ) you might predict how many bytes will be written, but this is
unreliable prediction, because not all FSD’d locks might have been acquired
at the moment of predicition, but it will work for many cases.


Slava Imameyev, xxxxx@hotmail.com

wrote in message news:xxxxx@ntfsd…
> I’m not quite sure. In my irp_mj_read, before setting completion routine
> and waiting for lower driver to finished reading, the length for paging io
> is usually page-aligned value, but after lower driver finished, the REAL
> length is revealed in the Irp->IoStatus.Information and it’s not
> page-aligned. How can I get this REAL length and don’t have to let lower
> drive to get it?
>

Are there a reliable way to get the REAL length?

??2007-07-04??“Slava Imameyev” д???
>> the REAL length is revealed in the Irp->IoStatus.Information and it’s not
>> page-aligned. How can I get this REAL length and don’t have to let lower
>> drive to get it?
>
>The underlying file system driver truncates paging request if it exceeds
>beyond a data stream end, so if you know the data stream size( i.e. file
>size ) you might predict how many bytes will be written, but this is
>unreliable prediction, because not all FSD’d locks might have been acquired
>at the moment of predicition, but it will work for many cases.
>
>–
> Slava Imameyev, xxxxx@hotmail.com
>
>
> wrote in message news:xxxxx@ntfsd…
>> I’m not quite sure. In my irp_mj_read, before setting completion routine
>> and waiting for lower driver to finished reading, the length for paging io
>> is usually page-aligned value, but after lower driver finished, the REAL
>> length is revealed in the Irp->IoStatus.Information and it’s not
>> page-aligned. How can I get this REAL length and don’t have to let lower
>> drive to get it?
>>
>
>
>
>—
>Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: liyuncheng@163.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>

If you know as a fact the end of file then you can compute the number of
bytes which can be read; otherwise you cannot know what you seek to know. If
you tell us why you think you need to know this then perhaps we can gove you
a better idea.

wrote in message news:xxxxx@ntfsd…
> In a file system filter driver’s irp_mj_read handler, I found when the irp
> is pagin io, usually the read length is page-aligned, but sometimes the
> real read length isn’t always a page-aligned value. How can I know then
> real length in advance before the Irp is passed to lower driver. Any
> advice is appreciated!
>