Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

is storport io request related to pagefile

James_HarperJames_Harper Member Posts: 1,615
Is there a "correct" way to tell if a storport (or scsiport) io request is related to pagefile access?

Under Xen I have access to a type of storage that is faster than disk but (slightly) slower than memory and is considered volatile, and any given write may be denied if Xen currently has insufficient storage. As such it would be a good candidate for using as a cache for pagefile, but to make that work I would need to be able to reliably identify writes to and reads from the Windows pagefile, and also to know when the pagefile metadata changes (eg pagefile grows or shrinks etc). And to really do it properly I would also need to know when the page stored on the pagefile was invalidated, but simply maintaining a LRU write-back cache would probably be sufficient.

Or maybe a filesystem filter driver would be a better way to do this, taking care of such things before storport gets involved? Do paging requests go "via" the filesystem or does the filesystem only handle the metadata for pagefile and the virtual memory manager performs io direct to disk?

(maybe we need an additional mailing list like ntcrackpot for ideas that might turn out to be crazy?)

Thanks

James

Comments

  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    >As such it would be a good candidate for using as a cache for pagefile,

    It would be a good candidate for using as a cache for _everything_, not only pagefile.

    >Or maybe a filesystem filter driver would be a better way to do this

    Maybe.

    >Do paging requests go "via" the filesystem

    IIRC yes, and the file object is marked by some FO_xxx flag.

    --
    Maxim S. Shatskih
    Microsoft MVP on File System And Storage
    xxxxx@storagecraft.com
    http://www.storagecraft.com
  • James_HarperJames_Harper Member Posts: 1,615
    >
    > >As such it would be a good candidate for using as a cache for pagefile,
    >
    > It would be a good candidate for using as a cache for _everything_, not only
    > pagefile.

    Not really. Pagefile contents to not need to persist across reboots (as long as I handle the hiber and dump cases as exceptions to that) but otherwise it's as dangerous as using a volatile write cache without the OS knowing that you are doing so. I guess you could use it as a write-through cache to avoid that, and only write-back in the case of pagefile... the xen provide cache isn't infinite though so pagefile access is probably best.

    Xen also provides another type of cache that you can write data to but have no guarantee it will still be there when you go to get it later... under Linux this can be used as a second level page cache (eg if your 2cached data got thrown out you just go read it from disk again and have lost nothing apart from a few extra microseconds of lookup). I'm not sure I have visibility under windows to when data gets evicted from the page cache though, or if the other required hooks exist.

    > >Or maybe a filesystem filter driver would be a better way to do this
    >
    > Maybe.

    I'm now thinking definitely... at storport level I think I'm too blind to the IO happening in the layers above.

    >
    > >Do paging requests go "via" the filesystem
    >
    > IIRC yes, and the file object is marked by some FO_xxx flag.
    >

    Thanks for that. I also found a FsRtlIsPagingFile too.

    James
  • Igor_SharovarIgor_Sharovar Member Posts: 614
    >but to make that work I would need to be able to reliably identify writes to and reads from the >Windows pagefile, and also to know when the pagefile metadata changes (eg pagefile grows or >shrinks etc).

    Have you looked "IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES"(DeviceDsmAction_Notification)? If a driver registers this IOCTL Windows sends a range of LBA's belonging to a page file. And Windows resend the IOCTL in case if the size of page file is changed(pagefile grows or shrinks).

    Igor Sharovar
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,138
    <quote>
    Is there a "correct" way to tell if a storport (or scsiport) io request is
    related to pagefile access?
    </quote>

    Weeeellll... I don't know about once you're into Storport, but if you have a PFILE_OBJECT you can call FsRtlIsPagingFile. This is pretty reliable, IIRC.

    I'm not sure that helps you any, but...

    Peter
    OSR

    Peter Viscarola
    OSR
    @OSRDrivers

  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    What about older Windows versions?

    --
    Maxim S. Shatskih
    Microsoft MVP on File System And Storage
    xxxxx@storagecraft.com
    http://www.storagecraft.com

    <xxxxx@hotmail.com> wrote in message news:xxxxx@ntdev...
    > >but to make that work I would need to be able to reliably identify writes to and reads from the >Windows pagefile, and also to know when the pagefile metadata changes (eg pagefile grows or >shrinks etc).
    >
    > Have you looked "IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES"(DeviceDsmAction_Notification)? If a driver registers this IOCTL Windows sends a range of LBA's belonging to a page file. And Windows resend the IOCTL in case if the size of page file is changed(pagefile grows or shrinks).
    >
    > Igor Sharovar
    >
    >
  • James_HarperJames_Harper Member Posts: 1,615
    >
    > <quote>
    > Is there a "correct" way to tell if a storport (or scsiport) io request is
    > related to pagefile access?
    > </quote>
    >
    > Weeeellll... I don't know about once you're into Storport, but if you have a
    > PFILE_OBJECT you can call FsRtlIsPagingFile. This is pretty reliable, IIRC.
    >
    > I'm not sure that helps you any, but...
    >

    I wrote my skeleton fs filter and FsRtlIsPagingFile returns true on reads and writes to the paging file. Nothing is straightforward though - no stream context allowed on paging file, and file context doesn't exist for <vista (an increasingly small problem but still...). Also seems like streamhandle context isn't allowed either (unless I'm doing it wrong) so I'll have to handle context myself...

    James
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 25 Feb 2019 OSR Seminar Space
Developing Minifilters 8 April 2019 OSR Seminar Space