On Read

Hello,

I hooked DispatchRead in my filter driver.

Is it okay to ExAllocatePool(IrpSp->Parameters.Read.Length) then ExFree()
upon start of read/after read completion?

Or it is better to once allocate a buffer w/ fixed aligned size then read
the file by chunks (loop ReadLength/MyChunkSize, then %) into that buffer
then transfer memory from my buffer to the user buffer as each read chunk is
completed?

Won’t continious allocation / deallocation fragment the system memory?


Elias

I would do both. The problem with initially allocated buffer would be
that you have to share it among multiple reads coming from different
threads thus blocking rest of the reads while satisfying one. Besides,
if you break a big single read into multiple small ones you will be hit
(and hit hard) with performance degradation. Besides, you permanently
hold big chunk of memory out of the system. So, an alternative would be:

  1. For big reads (actual numbers should be statistically calculated) use
    ExAllocatePool (in this case an overhead of allocation will be small
    comparing to actual read time)
  2. For small reads use lookaside list to allocate temp. buffer. This way
    you will have quick allocation and eventually that memory will be
    returned to the system.

-----Original Message-----
From: lallous [mailto:xxxxx@lgwm.org]
Sent: Wednesday, December 10, 2003 2:18 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] On Read

Hello,

I hooked DispatchRead in my filter driver.

Is it okay to ExAllocatePool(IrpSp->Parameters.Read.Length) then
ExFree()
upon start of read/after read completion?

Or it is better to once allocate a buffer w/ fixed aligned size then
read
the file by chunks (loop ReadLength/MyChunkSize, then %) into that
buffer
then transfer memory from my buffer to the user buffer as each read
chunk is
completed?

Won’t continious allocation / deallocation fragment the system memory?


Elias


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

You are currently subscribed to ntfsd as:
xxxxx@borland.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> Is it okay to ExAllocatePool(IrpSp->Parameters.Read.Length) then ExFree()

upon start of read/after read completion?

Yes, your own chunk management will nearly always be worse.

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