File preallocation
Reserving filesystem allocation for a file range before the application writes that range's data.
Successful Linux fallocate with mode 0 protects subsequent writes in the allocated range against lack of filesystem space; KEEP_SIZE avoids extending logical length. This is not just an advisory hint. A lower thin pool can still require backing allocations when data is written: an end-to-end capacity reservation is not established by the file operation alone, an inference from the separate layer contracts. Shared extents need an explicit sharing-aware contract; FALLOC_FL_UNSHARE_RANGE can make them private where supported.
On Windows, changing file size and advancing valid data length are distinct operations. SetFileValidData can expose bytes without initializing them; it is not an interchangeable zero-initializing reservation primitive. [7] [6]
Relations
- related
- Sparse file, Hole punching, Thin provisioning, fsync, File extent, Unwritten extent, Reflink, Delayed allocation, posix_fallocate, statvfs, Filesystem quota, Swapfile, FALLOC_FL_UNSHARE_RANGE, SetFileValidData
Advantages
- Reserves a selected range before later application writes need its filesystem allocation. [1]
Limitations
- Allocation is not proof that future application data has been persisted. [2]
- The fallocate interface also has deallocation and zeroing modes, so the API name alone does not identify preallocation. [1]
- glibc's posix_fallocate fallback can race concurrent writers when native allocation is unsupported; API choice and error handling matter. [5]
Citations
- Linux man-pages: fallocate(2), allocation and mode contracts
- util-linux 2.41.2: fallocate(1), preallocation, punching and zeroing
- Linux man-pages: posix_fallocate(3), return convention and glibc caveats
- Microsoft Learn: SetFileValidData, privilege requirements and stale-content disclosure
- Microsoft Learn: SetEndOfFile, file size versus valid data length