fs: use ftruncate on OpenBSD in AllocateFileRange #36189

pull HouseOfHufflepuff wants to merge 1 commits into bitcoin:master from HouseOfHufflepuff:fs-openbsd-ftruncate-allocatefilerange changing 1 files +4 −0
  1. HouseOfHufflepuff commented at 1:29 AM on September 8, 2026: contributor

    Summary

    OpenBSD provides neither fallocate nor posix_fallocate, so AllocateFileRange() always fell through to the slow fallback path there: writing the entire range one 64KiB buffer at a time instead of just advising the OS of the eventual file size.

    This adds an __OpenBSD__ branch that uses ftruncate, matching the guidance in #32643 and the same pattern already used for the macOS branch just above it in this function.

    Fixes #32643

    Test plan

    I don't have OpenBSD hardware to run this on directly, so it's verified by:

    • The "OpenBSD Cross" CI job, which compiles this exact branch for the target and passes.
    • Full local build (macOS, Clang) with no new warnings.
    • Full unit test suite (test_bitcoin, 825 cases) passes.
    • test/lint/lint-files.py, lint-includes.py, and lint-locale-dependence.py all pass.

    The approach mirrors a previous attempt at this issue (#32645, closed unmerged) which was hand-tested on real OpenBSD 7.7 via a signet IBD run, confirming the fallback path is no longer hit.

  2. fs: use ftruncate on OpenBSD in AllocateFileRange
    OpenBSD doesn't provide fallocate or posix_fallocate, so
    AllocateFileRange() was always taking the slow fallback path there,
    writing the whole range one 64KiB chunk at a time.
    
    ftruncate is available and, like on the other platforms handled here,
    is sufficient to advise the OS of the eventual file size in the
    non-Windows, non-macOS case.
    
    Fixes #32643
    cafd88ca4a
  3. DrahtBot commented at 1:29 AM on September 8, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36189.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. sedited commented at 11:10 AM on September 8, 2026: contributor

    Please don't post LLM PR descriptions. That "Test Plan" doesn't tell anything besides the bare minimum required to make CI pass.

  5. HouseOfHufflepuff commented at 5:11 PM on September 8, 2026: contributor

    Ready for review: @theStack @fanquake


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-09-09 07:56 UTC