alternative to FltAllocatePoolAlignedWithTag?

I would like to allocate a sector-aligned buffer before any volume instance
exists. Is there any reason FltAllocatePoolAlignedWithTag requires a volume
instance as a parameter except to look up the volume’s sector size? It
would seem possible to use an assumed sector size that is a multiple of any
possible value instead. (My driver only works with NTFS and FAT).

Is there an alternative to FltAllocatePoolAlignedWithTag? How do legacy
filters allocate buffers for non-cached writes?

Assuming you are willing to allocate this yourself, just use
ExAllocatePoolWithTag and specify that you want aligned pool memory.
For example, you could allocate an entire page (PAGE_SIZE) and
(surprise!) you’ll get back a page aligned block of memory.

The pool allocator on Windows (has always and still does) allocates
smaller than pages from a buddy list and page size or larger from a page
allocator. This could change in a future release of Windows, but not
terribly likely…

Regards,

Tony

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Hahn
Sent: Wednesday, May 25, 2005 9:22 PM
To: ntfsd redirect
Subject: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

I would like to allocate a sector-aligned buffer before any volume
instance
exists. Is there any reason FltAllocatePoolAlignedWithTag requires a
volume
instance as a parameter except to look up the volume’s sector size? It
would seem possible to use an assumed sector size that is a multiple of
any
possible value instead. (My driver only works with NTFS and FAT).

Is there an alternative to FltAllocatePoolAlignedWithTag? How do legacy

filters allocate buffers for non-cached writes?


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

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

1.) ExAllocatePoolWithTag only gives you pool aligned on 8-bytes. If the buffer is PAGE_SIZE or greater however, it does give you page-aligned pool.

2.) You do not need sector aligned buffers to do non-cached i/o. Devices just need buffers that are aligned on their alignment requirement. This is far lesser than sector size (512) usually.

FltAllocatePoolAlignedWithTag() guarantees that you get pool aligned on the device alignment requirement that you can use for non-cached i/o. The instance is required because the routine determines the device alignment requirement based on the underlying device that the volume (and therefore the instance) requires.

Ravi


From: xxxxx@lists.osr.com on behalf of Tony Mason
Sent: Wed 5/25/2005 6:53 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

Assuming you are willing to allocate this yourself, just use
ExAllocatePoolWithTag and specify that you want aligned pool memory.
For example, you could allocate an entire page (PAGE_SIZE) and
(surprise!) you’ll get back a page aligned block of memory.

The pool allocator on Windows (has always and still does) allocates
smaller than pages from a buddy list and page size or larger from a page
allocator. This could change in a future release of Windows, but not
terribly likely…

Regards,

Tony

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Hahn
Sent: Wednesday, May 25, 2005 9:22 PM
To: ntfsd redirect
Subject: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

I would like to allocate a sector-aligned buffer before any volume
instance
exists. Is there any reason FltAllocatePoolAlignedWithTag requires a
volume
instance as a parameter except to look up the volume’s sector size? It
would seem possible to use an assumed sector size that is a multiple of
any
possible value instead. (My driver only works with NTFS and FAT).

Is there an alternative to FltAllocatePoolAlignedWithTag? How do legacy

filters allocate buffers for non-cached writes?


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

You are currently subscribed to ntfsd as: xxxxx@osr.com
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

Windows does not support sectors > PAGE_SIZE.

So, allocate the page-aligned memory - and all is OK. VirtualAlloc in user
mode, ExAllocate for size >= PAGE_SIZE in kernel mode.

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

----- Original Message -----
From: “Mark Hahn”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Thursday, May 26, 2005 5:22 AM
Subject: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

> I would like to allocate a sector-aligned buffer before any volume instance
> exists. Is there any reason FltAllocatePoolAlignedWithTag requires a volume
> instance as a parameter except to look up the volume’s sector size? It
> would seem possible to use an assumed sector size that is a multiple of any
> possible value instead. (My driver only works with NTFS and FAT).
>
> Is there an alternative to FltAllocatePoolAlignedWithTag? How do legacy
> filters allocate buffers for non-cached writes?
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Right - I thought about the pool alignment as I wrote my response, but
was focused on suggesting PAGE_SIZED alignment, so sorry about not
properly explaining how to align from the small pool allocations.

In cases where you need alignment larger than that guaranteed by the
pool allocator, you need to overallocate and round to the appropriate
boundary. For example, SList headers need to be on 16 byte boundaries
for x64 systems. If you allocate 24 bytes from pool, either the
returned pointer, or the returned pointer plus 8 bytes is going to be on
a 16 byte boundary. All of the supported platforms have similar
situations. Note that this issue has nothing to do with device
alignment requirements, and thus is something generally useful to keep
in mind when constructing your driver.

I’ve never seen a controller that requires really large alignment, but
I’ve never gone looking for it, either. I just write the code to use
the underlying alignment, allocate size + alignment modifier, align the
actual buffer, and use it.

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com http:</http:>


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ravisankar Pudipeddi
Sent: Thursday, May 26, 2005 12:03 AM
To: ntfsd redirect
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

1.) ExAllocatePoolWithTag only gives you pool aligned on 8-bytes. If the
buffer is PAGE_SIZE or greater however, it does give you page-aligned
pool.

2.) You do not need sector aligned buffers to do non-cached i/o. Devices
just need buffers that are aligned on their alignment requirement. This
is far lesser than sector size (512) usually.

FltAllocatePoolAlignedWithTag() guarantees that you get pool aligned on
the device alignment requirement that you can use for non-cached i/o.
The instance is required because the routine determines the device
alignment requirement based on the underlying device that the volume
(and therefore the instance) requires.

Ravi


From: xxxxx@lists.osr.com on behalf of Tony Mason
Sent: Wed 5/25/2005 6:53 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

Assuming you are willing to allocate this yourself, just use
ExAllocatePoolWithTag and specify that you want aligned pool memory.
For example, you could allocate an entire page (PAGE_SIZE) and
(surprise!) you’ll get back a page aligned block of memory.

The pool allocator on Windows (has always and still does) allocates
smaller than pages from a buddy list and page size or larger from a page
allocator. This could change in a future release of Windows, but not
terribly likely…

Regards,

Tony

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Hahn
Sent: Wednesday, May 25, 2005 9:22 PM
To: ntfsd redirect
Subject: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

I would like to allocate a sector-aligned buffer before any volume
instance
exists. Is there any reason FltAllocatePoolAlignedWithTag requires a
volume
instance as a parameter except to look up the volume’s sector size? It
would seem possible to use an assumed sector size that is a multiple of
any
possible value instead. (My driver only works with NTFS and FAT).

Is there an alternative to FltAllocatePoolAlignedWithTag? How do legacy

filters allocate buffers for non-cached writes?


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

You are currently subscribed to ntfsd as: xxxxx@osr.com
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


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

RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?Thanks to all.
Once again reality is much simpler than what my imagination came up with.


“Tony Mason” wrote in message news:xxxxx@ntfsd…
Right - I thought about the pool alignment as I wrote my response, but was
focused on suggesting PAGE_SIZED alignment, so sorry about not properly
explaining how to align from the small pool allocations.

In cases where you need alignment larger than that guaranteed by the pool
allocator, you need to overallocate and round to the appropriate boundary.
For example, SList headers need to be on 16 byte boundaries for x64 systems.
If you allocate 24 bytes from pool, either the returned pointer, or the
returned pointer plus 8 bytes is going to be on a 16 byte boundary. All of
the supported platforms have similar situations. Note that this issue has
nothing to do with device alignment requirements, and thus is something
generally useful to keep in mind when constructing your driver.

I’ve never seen a controller that requires really large alignment, but I’ve
never gone looking for it, either. I just write the code to use the
underlying alignment, allocate size + alignment modifier, align the actual
buffer, and use it.

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 Ravisankar Pudipeddi
Sent: Thursday, May 26, 2005 12:03 AM
To: ntfsd redirect
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

1.) ExAllocatePoolWithTag only gives you pool aligned on 8-bytes. If the
buffer is PAGE_SIZE or greater however, it does give you page-aligned pool.

2.) You do not need sector aligned buffers to do non-cached i/o. Devices
just need buffers that are aligned on their alignment requirement. This is
far lesser than sector size (512) usually.

FltAllocatePoolAlignedWithTag() guarantees that you get pool aligned on the
device alignment requirement that you can use for non-cached i/o. The
instance is required because the routine determines the device alignment
requirement based on the underlying device that the volume (and therefore
the instance) requires.

Ravi

From: xxxxx@lists.osr.com on behalf of Tony Mason
Sent: Wed 5/25/2005 6:53 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?
Assuming you are willing to allocate this yourself, just use
ExAllocatePoolWithTag and specify that you want aligned pool memory.
For example, you could allocate an entire page (PAGE_SIZE) and
(surprise!) you’ll get back a page aligned block of memory.

The pool allocator on Windows (has always and still does) allocates
smaller than pages from a buddy list and page size or larger from a page
allocator. This could change in a future release of Windows, but not
terribly likely…

Regards,

Tony

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Hahn
Sent: Wednesday, May 25, 2005 9:22 PM
To: ntfsd redirect
Subject: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

I would like to allocate a sector-aligned buffer before any volume
instance
exists. Is there any reason FltAllocatePoolAlignedWithTag requires a
volume
instance as a parameter except to look up the volume’s sector size? It
would seem possible to use an assumed sector size that is a multiple of
any
possible value instead. (My driver only works with NTFS and FAT).

Is there an alternative to FltAllocatePoolAlignedWithTag? How do legacy

filters allocate buffers for non-cached writes?


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

You are currently subscribed to ntfsd as: xxxxx@osr.com
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

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

That’s exactly how FltAllocatePoolAlignedWithTag works. Device alignment
can be obtained via DeviceObject->AlignmentRequirement if you know the
volume’s device object.

The sector alignment myth is perpetuated I think because there are no
APIs to return the alignment requirement to user mode. The user mode
APIs encourage sending down sector aligned buffers since that will cover
all controllers.

Ravi


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tony Mason
Sent: Thursday, May 26, 2005 6:49 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

Right - I thought about the pool alignment as I wrote my response, but
was focused on suggesting PAGE_SIZED alignment, so sorry about not
properly explaining how to align from the small pool allocations.

In cases where you need alignment larger than that guaranteed by the
pool allocator, you need to overallocate and round to the appropriate
boundary. For example, SList headers need to be on 16 byte boundaries
for x64 systems. If you allocate 24 bytes from pool, either the
returned pointer, or the returned pointer plus 8 bytes is going to be on
a 16 byte boundary. All of the supported platforms have similar
situations. Note that this issue has nothing to do with device
alignment requirements, and thus is something generally useful to keep
in mind when constructing your driver.

I’ve never seen a controller that requires really large alignment, but
I’ve never gone looking for it, either. I just write the code to use
the underlying alignment, allocate size + alignment modifier, align the
actual buffer, and use it.

Regards,

Tony

Tony Mason

Consulting Partner

OSR Open Systems Resources, Inc.

http://www.osr.com http:</http:>


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ravisankar Pudipeddi
Sent: Thursday, May 26, 2005 12:03 AM
To: ntfsd redirect
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

1.) ExAllocatePoolWithTag only gives you pool aligned on 8-bytes. If the
buffer is PAGE_SIZE or greater however, it does give you page-aligned
pool.

2.) You do not need sector aligned buffers to do non-cached i/o. Devices
just need buffers that are aligned on their alignment requirement. This
is far lesser than sector size (512) usually.

FltAllocatePoolAlignedWithTag() guarantees that you get pool aligned on
the device alignment requirement that you can use for non-cached i/o.
The instance is required because the routine determines the device
alignment requirement based on the underlying device that the volume
(and therefore the instance) requires.

Ravi


From: xxxxx@lists.osr.com on behalf of Tony Mason
Sent: Wed 5/25/2005 6:53 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

Assuming you are willing to allocate this yourself, just use
ExAllocatePoolWithTag and specify that you want aligned pool memory.
For example, you could allocate an entire page (PAGE_SIZE) and
(surprise!) you’ll get back a page aligned block of memory.

The pool allocator on Windows (has always and still does) allocates
smaller than pages from a buddy list and page size or larger from a page
allocator. This could change in a future release of Windows, but not
terribly likely…

Regards,

Tony

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

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark Hahn
Sent: Wednesday, May 25, 2005 9:22 PM
To: ntfsd redirect
Subject: [ntfsd] alternative to FltAllocatePoolAlignedWithTag?

I would like to allocate a sector-aligned buffer before any volume
instance
exists. Is there any reason FltAllocatePoolAlignedWithTag requires a
volume
instance as a parameter except to look up the volume’s sector size? It
would seem possible to use an assumed sector size that is a multiple of
any
possible value instead. (My driver only works with NTFS and FAT).

Is there an alternative to FltAllocatePoolAlignedWithTag? How do legacy

filters allocate buffers for non-cached writes?


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

You are currently subscribed to ntfsd as: xxxxx@osr.com
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


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