You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Apple allocate can succeed after partial F_PREALLOCATE #1
The Apple implementation inherited through rustix::fs::fallocate can report success after F_ALLOCATECONTIG reserves only part of the requested space. The implementation checks only the fcntl return code and ignores fstore_t.fst_bytesalloc, then extends the logical EOF with ftruncate.
This violates FileExt::allocate / AsyncFileExt::allocate: later writes are not guaranteed to succeed for lack of disk space.
128 MiB request with ample free space: inherited implementation returned Ok(()), but only 4,046,848 bytes were physically allocated after sync_all().
200 MiB request on a disposable APFS volume with 132,771,840 bytes available: inherited implementation returned Ok(()), partially allocated 99,115,008 bytes, and set logical EOF to 209,715,200 bytes.
Direct F_ALLOCATEALL for 128 MiB returned fst_bytesalloc = 134,217,728 and fully reserved the file.
Direct F_ALLOCATEALL for 200 MiB on the limited volume returned ENOSPC, fst_bytesalloc = 0, and left logical and allocated sizes at zero.
Control evidence:
Linux fallocate fully reserves normal requests and fails without partial allocation on a size-limited tmpfs.
Windows FileAllocationInfo fully reserves normal requests and returns ERROR_DISK_FULL without partial allocation on a size-limited NTFS VHDX.
Required behavior
On Apple platforms, use all-or-nothing allocation and validate fst_bytesalloc before extending logical EOF.
Preserve sparse-file recovery: request only the physical bytes not already allocated.
Share the corrected backend between sync and async traits.
Add a normal APFS regression and an ENOSPC test using a disposable size-limited APFS image in CI.
This issue started as an AsterDrive upload failure, but direct-library and native-filesystem tests showed that the broken contract belonged in the filesystem abstraction. The complete resolution is now merged in #2 and consumed by AsterDrive in AsterCommunity/AsterDrive#626.
Discovery path
AsterDrive upload Init repeatedly failed after FileExt::allocate returned success because only roughly 2-5 MiB of 117-263 MiB requests appeared physically allocated.
The destination storage policy had ample capacity; the failing filesystem was the local staging volume on APFS.
Direct calls to the inherited library reproduced the mismatch independently of AsterDrive.
A size-limited APFS image demonstrated the dangerous case: the contiguous-allocation path could partially reserve space, return success, and then extend logical EOF.
Direct F_ALLOCATEALL control probes demonstrated the required behavior: a feasible request reserved the full amount, while an oversized request returned ENOSPC with no reservation and no EOF extension on a new file.
Native Linux and Windows controls showed that their supported allocation paths already provided the expected success/failure boundary.
Root cause
F_ALLOCATECONTIG is useful as a best-effort request for contiguous extents, but Apple explicitly reports the actual completed amount through fstore_t.fst_bytesalloc. Treating only the fcntl return code as proof of complete reservation was incorrect. Extending EOF afterward converted partial physical work into an apparently complete sparse file.
The correction therefore could not be “ignore st_blocks in AsterDrive.” That would merely hide the false success. The allocation layer had to establish and test the complete physical-reservation postcondition itself.
New Apple extents use F_ALLOCATEALL and validate the returned fst_bytesalloc before logical EOF is extended.
Existing sparse files are recovered by locating and materializing their actual holes rather than subtracting an unrelated total allocated-block count.
Existing bytes and file cursor position are preserved.
High-offset extents cannot be mistaken for coverage of low-offset holes.
Allocation remains idempotent when physical blocks already cover the requested range, while logical EOF is still extended when required.
Non-Apple supported backends continue to invoke their native allocation primitive instead of incorrectly short-circuiting from total block accounting.
Async Tokio, fs-err Tokio, async-std, and Smol integrations run the synchronous native work on the appropriate blocking pool.
New empty Apple reservations are all-or-nothing. Existing sparse-file recovery may have partial side effects before a later ENOSPC, but it never returns false success; the consumer can retain, fail, retry, or clean that session explicitly.
Native macOS tests, Apple preallocation contract job, macOS coverage and Clippy
Linux
Normal native allocation and limited-tmpfs ENOSPC in Docker
Ubuntu build/test/coverage/Clippy plus affected GNU, musl, Android, and architecture cross checks
Windows / NTFS
Normal native reservation and limited-VHDX ERROR_DISK_FULL in a Windows VM
Windows build/test/coverage/Clippy plus GNU and MSVC cross checks
Rust compatibility
Sync-only public contract
Rust 1.75 MSRV check plus pinned Rust 1.95 development/CI toolchain and feature matrix
The final PR head 8698896abcfb6b641f2ede685255efc8f8a07c0e passed all required CI, CodeRabbit's final incremental review produced no new actionable comments, and the squash merge is 913ed30598119c184f49f18e5b339fc98869fff2.
Consumer result
AsterDrive#626 pins aster-fs to that exact merge revision. Its staging path remains inside tokio::task::spawn_blocking and preserves the product semantics around HTTP 507, failed-Init cleanup, restart recovery, chunk data, cancel, and completion.
Consumer validation includes 2/2 staging unit tests, 14/14 staging integration tests, 11/11 staged-upload tests, a dedicated 128 MiB APFS Init regression, full test compilation, Clippy with warnings denied, documentation validation, formatting, and whitespace checks.
This closes the loop from a user-visible upload 500 to a directly tested cross-platform allocation contract, rather than papering over APFS block accounting in the consumer.
Activity
AptS-1547 commentedon Sep 18, 2026
Resolution report and consumer integration
This issue started as an AsterDrive upload failure, but direct-library and native-filesystem tests showed that the broken contract belonged in the filesystem abstraction. The complete resolution is now merged in #2 and consumed by AsterDrive in AsterCommunity/AsterDrive#626.
Discovery path
FileExt::allocatereturned success because only roughly 2-5 MiB of 117-263 MiB requests appeared physically allocated.F_ALLOCATEALLcontrol probes demonstrated the required behavior: a feasible request reserved the full amount, while an oversized request returnedENOSPCwith no reservation and no EOF extension on a new file.Root cause
F_ALLOCATECONTIGis useful as a best-effort request for contiguous extents, but Apple explicitly reports the actual completed amount throughfstore_t.fst_bytesalloc. Treating only thefcntlreturn code as proof of complete reservation was incorrect. Extending EOF afterward converted partial physical work into an apparently complete sparse file.The correction therefore could not be “ignore
st_blocksin AsterDrive.” That would merely hide the false success. The allocation layer had to establish and test the complete physical-reservation postcondition itself.Implemented contract
#2 introduced the following behavior:
F_ALLOCATEALLand validate the returnedfst_bytesallocbefore logical EOF is extended.ENOSPC, but it never returns false success; the consumer can retain, fail, retry, or clean that session explicitly.Evidence matrix
ENOSPC; allocation rounding; existing sparse holes; high-offset data; cursor/data preservation; blocking-pool isolationERROR_DISK_FULLin a Windows VMThe final PR head
8698896abcfb6b641f2ede685255efc8f8a07c0epassed all required CI, CodeRabbit's final incremental review produced no new actionable comments, and the squash merge is913ed30598119c184f49f18e5b339fc98869fff2.Consumer result
AsterDrive#626 pins
aster-fsto that exact merge revision. Its staging path remains insidetokio::task::spawn_blockingand preserves the product semantics around HTTP 507, failed-Init cleanup, restart recovery, chunk data, cancel, and completion.Consumer validation includes 2/2 staging unit tests, 14/14 staging integration tests, 11/11 staged-upload tests, a dedicated 128 MiB APFS Init regression, full test compilation, Clippy with warnings denied, documentation validation, formatting, and whitespace checks.
This closes the loop from a user-visible upload 500 to a directly tested cross-platform allocation contract, rather than papering over APFS block accounting in the consumer.