Skip to content

feat: wire O_TMPFILE + linkat finalization into AnonymousTempFile write strategy - #2957

Merged
oferchen merged 1 commit into
masterfrom
feat/linkat-anonymous-tmpfile
Mar 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/linkat-anonymous-tmpfile

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Converts fast_io::o_tmpfile from a single file to a directory module, adding higher-level AnonymousTempFile, OTmpfileSupport, TempFileResult, o_tmpfile_probe, and open_temp_file types on top of the existing low-level syscall wrappers (which are preserved unchanged in low_level.rs)
  • Extends DestinationWriteGuard with an Anonymous strategy variant that uses O_TMPFILE + linkat(2) instead of named temp file + rename, with zero cleanup on failure (kernel reclaims the anonymous inode)
  • Adds AnonymousTempFile variant to WriteStrategy in the transfer executor; select_write_strategy probes the destination filesystem and prefers anonymous when available (Linux 3.11+, ext4/xfs/btrfs/tmpfs), falling back to TempFileRename at runtime if the open fails
  • Partial mode (--partial) and --temp-dir correctly force the named temp file path since partial files need a visible staging path and cross-device linkat would fail

Test plan

  • Existing named temp file tests pass unchanged (strategy selection, guard commit/discard/drop)
  • New unit tests for AnonymousTempFile strategy selection with filesystem probe
  • Linux-specific guard tests: anonymous write+commit, commit-replaces-existing, discard-leaves-no-file, drop-without-commit cleanup
  • Integration tests in engine/tests/o_tmpfile_write_path.rs exercise the full anonymous workflow
  • Non-Linux platforms: probe returns Unavailable, AnonymousTempFile::open returns Unsupported, strategy falls back to TempFileRename
  • CI: fmt+clippy, nextest, Windows, macOS, Linux musl

@oferchen
oferchen merged commit c34b37f into master Mar 22, 2026
5 of 10 checks passed
@oferchen
oferchen deleted the feat/linkat-anonymous-tmpfile branch March 22, 2026 09:39
@github-actions github-actions Bot added the enhancement New feature or request label Mar 22, 2026
oferchen added a commit that referenced this pull request May 1, 2026
oferchen added a commit that referenced this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant