Is there any dirty page for a given stream?

Hi all,

I’ve been looking for a way to know whether a given stream has dirty data on the cache pages that was not flushed to the disk yet.

Looking at the Cache Manager interfaces I saw the CcGetDirtyPages routine about file system logging, but as far as I could see, this is for a bigger purpose and it would not fit as I expected.

Anyone knows any way to get that information?
I’m not looking for the specific dirty pages, a single BOOLEAN result would fit perfectly.

Thanks in advance,

Fernando Roberto da Silva
DriverEntry Kernel Development
http://www.driverentry.com.br/en

Not that I am aware of, particularly if you’re a filter driver where you
don’t have sufficient locking available to prevent this information from
immediately going stale. Also, I presume that you would also care about
dirty pages from memory mapped views, in which case any Cc API isn’t going
be a panacea.

What’s your overall goal? Maybe if you explain what problem you’re trying to
solve someone will have some guidance.

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntfsd…

Hi all,

I’ve been looking for a way to know whether a given stream has dirty data on
the cache pages that was not flushed to the disk yet.

Looking at the Cache Manager interfaces I saw the CcGetDirtyPages routine
about file system logging, but as far as I could see, this is for a bigger
purpose and it would not fit as I expected.

Anyone knows any way to get that information?
I’m not looking for the specific dirty pages, a single BOOLEAN result would
fit perfectly.

Thanks in advance,

Fernando Roberto da Silva
DriverEntry Kernel Development
http://www.driverentry.com.br/en

Hi Scott,

I’m working on a layered file system driver. Sorry not mentioning it is not a filter.
Sometimes, I need to take the file size from the underlying file system, but that information might not be correct due to some dirty pages that is still on the cache manager. In that case, I’d need ignore the file size on the underlying file system and take that information from my own FCB.

As you said, some data might get into the cache via memory mapped views and having a way to discover if a given stream still has dirty pages on the cache would make my change easier to be implemented due to several logical layers the product has.

Anyway, many thanks for your help.

Regards,

Fernando Roberto da Silva
DriverEntry Kernel Development
http://www.driverentry.com.br/en

Hi,

Sometimes, I need to take the file size from the underlying file system,
but that information might not be correct due to some dirty pages that is
still >on the cache manager. In that case, I’d need ignore the file size on
the underlying file system and take that information from my own FCB.

Which size are you talking about? Are you basing something on the
AdvanceOnly call coming in from the lazy writer? Also, are you digging
directly into the underlying FSD’s FCB? That’s generally a bad idea.

Sorry to answer a question with more questions, but I’m trying to determine
what decisions sent you down this path.

Regards,

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntfsd…

Hi Scott,

I’m working on a layered file system driver. Sorry not mentioning it is not
a filter.
Sometimes, I need to take the file size from the underlying file system, but
that information might not be correct due to some dirty pages that is still
on the cache manager. In that case, I’d need ignore the file size on the
underlying file system and take that information from my own FCB.

As you said, some data might get into the cache via memory mapped views and
having a way to discover if a given stream still has dirty pages on the
cache would make my change easier to be implemented due to several logical
layers the product has.

Anyway, many thanks for your help.

Regards,

Fernando Roberto da Silva
DriverEntry Kernel Development
http://www.driverentry.com.br/en

Hi Scott,

I’m talking about the EndOfFile, I do an IRP_MJ_QUERY_INFORMATION to get it from the underlying file system. When my file system driver receives a write that extends the file size, my driver updates my own FCB before calling CcSetFileSize, then the data goes to the cache manager. Eventually the Lazy Writer will flush that data to the underlying file system, making it to extend as well.

Sometimes I need to get the underlying file size (EndOfFile), but querying the underlying file system might return the “wrong” size because the Lazy Writer didn’t have the chance to flush the dirty pages yet. That makes the underlying file to be smaller than it is expected to be.

Because the expected file size (and the correct one on my view point) is on my own FCB, I’m taking the file size from there to use wherever I need. That solves my initial problem regardless of having the dirty pages already flushed or not.

Thanks for your help.

>might return the “wrong” size because the Lazy Writer didn’t have the chance to flush the dirty pages

yet.

Lazy Writer cannot extend the file size.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> >might return the “wrong” size because the Lazy Writer didn’t have the

>chance to flush the dirty pages
>yet.

Lazy Writer cannot extend the file size.

It will in his design, if I understand it correctly. If, in response to a
PAGING write he issues a non paging, extending write, that is exactly what
will happen.

In answer to the OP, I can add nothing to what Scott ahs already said, but
I’ll note that accepting a size change without making sure that there is
space available on disk can be a risky business. If you have said
STATUS_SUCCESS in response to an application’s extending write or
SetFileInformation, then they have a certain right to assume that, absent
hardware failures (and strange cases with compressed files), the file will
eventually become that length and the data will eventually contain that
data. By deferring the file extension until the paging write you are
significantly upping the chances of that not happening.

Rod Widdowson
Consulting Partner
Steading System Software