[Backport]bug-fix macos: give free bytes to F_PREALLOCATE
Summary:
The Initial Block Download (IBD) on macOS Catalina uses a lot more disk space than expected.
The macos manpage for fcntl (for F_PEOFPOSMODE) states:
Allocate from the physical end of file. In this case, fst_length indicates the number of newly allocated bytes desired.
This would result in the rev files being essentially pre-allocating 2x their necessary size (this is the case for block files as well, but these are flushed down to their right sizes every time) as they would pre-allocate pos + length free bytes, rather than allocating length bytes after pos, as expected.
Note: more explanations on the issue from Apple in this bug report
https://openradar.appspot.com/radar?id=4930713610616832
Backport of Bitcoin Core PR17887
Test Plan:
ninja check to verify that the patch does not accidentaly break anything else.
But I do not have a MacOS to run the tests on, and try to replicate the issue.
Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix
Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix
Subscribers: deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D7526