The DFS allocation functions allow a great deal of control in determining where and how file space is allocated. The application NLM might allow the OS to allocate required space for a file using OS default allocation, or might request allocation to be on a specific volume segment and/or specify the actual volume blocks to be allocated. File allocation can be used to fill holes in sparse files or to extend existing files. Writing to a nonexistent area in a file (either to a hole or beyond the allocated file space) is not allowed with the DFS functions.
See the following related tasks as well:
Causing a file to be allocated with striping has different effects on different configurations. A drive array normally provides optimum throughput using internal striping, so specifying striping by the OS in this case would defeat optimum throughput, while specifying striping on files on a SCSI host adapter providing disconnect with multiple drives normally provides more optimal performance. Striping does not necessarily provide significant performance benefits for extremely large files accessed in true random fashion, but provides performance benefits when accessed sequentially.
The size of a file can be specified independent of the actual file space allocated by calling DFSSetEndOfFile. Reads attempted beyond the current end-of-file (indicated by the file size) are always rejected as an attempted operation beyond the current file size.
If the file size is expanded beyond its previous value, the additional file area incorporated in the new file size is zero-filled, provided that the file space is actually allocated. If the file size specified is smaller than the previously indicated file size and the returnTrunctatedBlocksFlag is nonzero, blocks previously allocated beyond the newly defined file size are truncated, that is, returned to the OS for future use.
The file size is also modified by calling DFSWrite (only the "wait" version) indicating a write to a file sector address beyond the current file size (the file size is updated accordingly) but within the range of blocks allocated for the file. If the write does not start immediately following the current file size, the intervening blocks are zero-filled.
When a file has additional space allocated at the end of the file by calling DFSExpandFile, the additional file space is not zero-filled immediately. Subsequent writes to the file set a new file size and eliminate the requirement to zero-fill the additional file space. Calling DFSSetEndOfFile also sets a new file size, and zero-fills any sectors in the new file size that are beyond the previous file size.
When a file has additional space allocated to fill a hole in a sparse file, the DFSExpandFile function also zero-fills the additional space if the space is not beyond the current file size.