Allocation size with FltWriteFile() problem

I am having some troubles with allocation size of the opened file when writing with FltWriteFile() (non-cached and paged write). When writing to sparse file (allocation size 0, end of file properly set) allocation size is automatically set by FltWriteFile(). In case the buffer size (properly aligned to sector size) is not equal to allocation unit of NTFS, the allocation size is set to multiple of end-of-file. As an example, buffer size passed to FltWriteFile() is 1024 bytes, NTFS allocation unit size is 4096 bytes, end-of-file is set to 16384. The allocation size prior FltWriteFile() is 0, after first FltWriteFile() it is set to 65536 which is exactly 16384 * (4096/1024). The same story with different NTFS allocation sizes. It seems odd when NTFS allocation unit size is smaller then buffer size, allocation size of the file is set less then end-of-file which is by DDK documentation not possible (end-of-file must be at most the size of allocation size).

I tried manually set allocation size with FltSetInformationFile() with FILE_ALLOCATION_INFORMATION but even though STATUS_SUCCESS is returned, allocation size is not set.

Does anyone else experience similar troubles with FltWriteFile() or knows the solution. Or maybe one can point me how to use FltSetInformationFile().

Thanks in advance, Klemen

We did additional research and come to the bottom of the problem. Problem exists only with sparse files which, if not filled with FSCTL_SET_ZERO_DATA, occupy 16 allocation units of NTFS which is in our case exactly 64k.