IRP_MJ_READ using IRP_NOCACHE

Hi All,

I need to clarify a doubt regarding Caching Read / Write.
When there is a IRP_MJ_READ / WRITE call, there is a flag called IRP_NOCACHE
to check whether it is going to be a cached operation or not or in other
way, we can disable the cached operation by setting the flag IRP_NOCACHE.
So, there is a possiblity that IRP_MJ_READ can be a cached operation.
If so, what exactly is the FASTIO_READ operation. As per my understanding
FASTIO_READ is the read operation on cache, then why will there be an
IRP_MJ_READ with IRP_NOCACHE flag set.

Thanks for your inputs.

Regards,
Shreshth Luthra

> As per my understanding FASTIO_READ is the read operation on cache,

then why will there be an IRP_MJ_READ with IRP_NOCACHE flag set.

If you read from cache, the cache cannot conjure the data.
Instead of this, it must read them from the storage device
or from network. That’s why IRP_MJ_READ + IRP_NOCACHE
(and also with IRP_PAGING_IO) is for.

L.

Thanks Ladislav.

But when we check the IRP_MJ_READ calls, in certain calls IRP_NOCACHE is set
and in rest of them it is not.
So, if its like, in case of a page fault, IRP_MJ_READ with IRP_NOCACHE set
is called then why is this flag reset for the next IRP_MJ_READ on the same
file, the next time.
I mean who is going to take care that this flag needs to be reset.

Regards,
Shreshth

On 4/5/06, Ladislav Zezula wrote:
>
> > As per my understanding FASTIO_READ is the read operation on cache,
> > then why will there be an IRP_MJ_READ with IRP_NOCACHE flag set.
>
> If you read from cache, the cache cannot conjure the data.
> Instead of this, it must read them from the storage device
> or from network. That’s why IRP_MJ_READ + IRP_NOCACHE
> (and also with IRP_PAGING_IO) is for.
>
> L.
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
>
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

The flag is not “reset” the flag is set based upon the desired operation
from the original caller.

For example, if this is satisfying a page fault, then Mm calls
IoPageRead (cf., ntifs.h). This actually sets the bits appropriate for
a paging read operation. If this is a user mode read, then the bit is
set if the user has explicitly requested non-cached I/O (“no
intermediate buffering”) otherwise the bit is not set.

The purpose of this bit is to tell the file system how to satisfy the
read - if the bit is set, the read is ideally satisfied directly from
the backing store (disk or across the network) but if the bit is not
set, the read is ideally satisfied from the cache. Note that I’m using
the term “ideally” here because a file system actually has tremendous
latitude in how to implement its functionality.

For example, NTFS ignores non-cached I/O operations for user-level reads
(IRP_PAGING_IO bit is not set but IRP_NOCACHE is set) if the file is
compressed - the read is satisfied from the cache. I’ve developed file
systems where we don’t respect it either (we convert a request to open
the file non-cached as being a request to open it FILE_WRITE_THROUGH,
for example.) But the I/O Manager sets the bits in a highly structured
way - if FO_NO_INTERMEDIATE_BUFFERING is set in the file object, it will
set IRP_NOCACHE on the individual I/O operation (for NtReadFile for
example) but if the I/O is a paging I/O then the operation always sets
IRP_NOCACHE (and IRP_PAGING_IO).

Of course, like everything else in the kernel, this is all subject to
change.

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shreshth Luthra
Sent: Wednesday, April 05, 2006 1:35 PM
To: ntfsd redirect
Subject: Re: [ntfsd] IRP_MJ_READ using IRP_NOCACHE

Thanks Ladislav.

But when we check the IRP_MJ_READ calls, in certain calls IRP_NOCACHE is
set and in rest of them it is not.

So, if its like, in case of a page fault, IRP_MJ_READ with IRP_NOCACHE
set is called then why is this flag reset for the next IRP_MJ_READ on
the same file, the next time.

I mean who is going to take care that this flag needs to be reset.

Regards,

Shreshth

On 4/5/06, Ladislav Zezula wrote:

> As per my understanding FASTIO_READ is the read operation on cache,
> then why will there be an IRP_MJ_READ with IRP_NOCACHE flag set.

If you read from cache, the cache cannot conjure the data.
Instead of this, it must read them from the storage device
or from network. That’s why IRP_MJ_READ + IRP_NOCACHE

(and also with IRP_PAGING_IO) is for.

L.


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

You are currently subscribed to ntfsd as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

— Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17 You are currently subscribed
to ntfsd as: unknown lmsubst tag argument: ‘’ To unsubscribe send a
blank email to xxxxx@lists.osr.com

>IRP_MJ_READ with IRP_NOCACHE flag set.

These IRPs move the data from the disk stack to the physical memory, be it the
cache pages or the mapped file pages or the app’s buffer (for noncached file).

FastIo and cached IO IRPs move the data between the cache and the app’s buffer.

The reason of existing both FastIo and cached IRPs is the FastIo only uses the
TryToAcquire semantics on the ERESOURCE locks which govern the file size, and
falls back to IRP way if TryToAcquire fails.

The IRPs use the real acquire semantics.

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