IRP_MJ_WRITE on LanmanRedirector - cache issue

Hello

I’ve searched the whole forum and found this topic very popular. I’ve also read the ‘Caching in Network File Systems’ article, but still I’m not sure what should I do.

My filter driver is a type of ‘a filter driver that is modifying the data (…) look for and operate on non-cached I/O operations’. And I have a problem with writing on remote shares.

I already understand that IRP_NOCACHE means nothing inside filter driver, because FSD may ignore it as a result of it’s internal cache policy (NTFS & FAT are usefull exceptions). And I know that there are few solutions for this problem, ie. monitoring FCB structure, minifilter driver that disables caching for LanmanRedirector.

But I haven’t found any summary on that subject. What I mean is, although this topic was discussed many times, I couldn’t find any useful bottom-line effect.

Please help me in that matter.
Is File Control Block & FCB_STATE_READCACHING_ENABLED the best approach (the only one) that guaranties a proper cache/nocache information? What about:
‘state of this field does not change between the time the filter checks it and the time the call is actually processed by the file system’?

Thanks in advance
AK

If you use the “reach into the FCB” approach you will very likely break
in Windows Vista because your filter will be above MUP, not above the
individual redirector. In addition, we’ve seen this break with hot
fixes (W2K).

I don’t recommend using the technique you describe. If you want to
know, disable caching or build a layer (like we’ve done in our own
toolkit) that doesn’t care if it is cached or not.

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Thank You Tony

But could You please advise me how to actually disable the cache?
I’ve read that doing something like:

pIrp->Flags |= IRP_NOCACHE;

is a bad idea, because it eventually ends with BSOD.

I’m not quite familiar with the minifilter drivers, but from my knowledge (based mostly on this forum and MSDN), I’m guessing I can’t disable it from there. Well, at least I don’t know how. The only idea I came up with is to force increasing reference counter on particular file on the server side of share, so that it report shared acces to client driver, which in conclusion should turn off file cache. But still it’s nothing more than a hack onto MS technology and it doesn’t give any guaranties.

Or maybe there’s a way to turn off Cache Manager for remote files from system Control Panel? I mean some administrative tool?

Thanks for all the help
AK

> I already understand that IRP_NOCACHE means nothing inside filter driver,

No, it have a meaning. Requests without IRP_NOCACHE will go to Cc for sure.

because FSD may ignore it as a result of it’s internal cache policy (NTFS &
FAT
are usefull exceptions).

FSD’s do not ignore it. They ignore the “write-through” file flag, and this
ignorance is IIRC NTFS-only and is implemented as cached write followed by
immediate flush
.


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



>because FSD may ignore it as a result of it’s internal cache policy
(NTFS &
FAT
>are usefull exceptions).

FSD’s do not ignore it. They ignore the “write-through” file flag, and
this
ignorance is IIRC NTFS-only and is implemented as cached write followed
by
immediate flush
.

Actually, I believe that what you meant is they ignore the “no
intermediate buffering” option - this happens in NTFS (for example) and
is implemented as “write through” and is related to the specific of how
compressed files are implemented.

The issue for the OP is that converting cached I/O to non-cached I/O
means that he’s going to hit all the limitations associated with
non-cached I/O. I explained the solution we’ve used in our own work (we
add a layer of caching so frankly we don’t care what the underlying
system does) but he wants a far simpler solution than that.

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

>> I already understand that IRP_NOCACHE means nothing inside filter driver,

No, it have a meaning. Requests without IRP_NOCACHE will go to Cc for
sure.

This I do not “get”; surely so long as the data model is consistent the file
system (and cohorts) can peform write/read without IRP_NO_CACHE as if were
write/read with IRP_NO_CACHE (on other words, dont bother with the cache) as
the file system (and cohorts) should choose.