]> git.hungrycats.org Git - bees/commit
tempfile: split pool into nocow and datacow variants
authorZygo Blaxell <bees@furryterror.org>
Wed, 22 Apr 2026 15:40:00 +0000 (11:40 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sun, 30 Aug 2026 23:48:46 +0000 (19:48 -0400)
commitc519f9815946daec81eb27f44ee432d799e320a2
treeada8b0a3c4e2b1a23f2596049e60474d9981ec35
parented667be7716a4384607f73a04e828acf642837a9
tempfile: split pool into nocow and datacow variants

Replace the single Pool<BeesTempFile> m_tmpfile_pool with a
two-element array<Pool<BeesTempFile>, 2> m_tmpfile_pools keyed by
the datacow flag.  Each pool pre-configures its generator with the
matching BeesTempFileConfig::m_datacow, so callers get temp files
of the right shape without the pool having to plumb the flag
through a factory lambda per borrow.

Add a new BeesContext::tmpfile(bool datacow) overload that returns
from the matching pool.  The no-arg BeesContext::tmpfile() preserves
its legacy meaning by delegating to tmpfile(true); all existing
callers continue to get a datacow temp file.

BeesTempFile already honors config.m_datacow when it opens the
O_TMPFILE: if datacow=false the NOCOW inode flag is set, which is
required for extent rewriters to punch PREALLOC holes without btrfs
forcing a data copy.  Prior to this commit the NOCOW path existed
in BeesTempFile but there was no pool that produced nocow temp
files; this commit wires the infrastructure together.

Standalone refactor in preparation for the extent planner, which
needs to borrow a temp file with the same datacow state as the
extent being rewritten.

Assisted-by: Claude-Code:claude-opus-4-7
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-context.cc
src/bees.h