Repository navigation
feat(receiver): stage a --partial-dir resume in place - #7599
Merged
Merged
Conversation
oferchen
force-pushed
the
feat/one-inplace-partial-dir-staging
branch
3 times, most recently
from
September 1, 2026 11:53
27aab00 to
6b3c998
Compare
Mirror upstream's `one_inplace`: when a `--partial-dir` entry for a file
already exists as a regular file, the local-copy executor now writes the
reconstruction straight into that entry and renames it onto the
destination on commit, instead of building a separate temp beside the
destination and deleting the partial entry afterwards.
receiver.c:1195-1196 is the shape being mirrored:
if (inplace || one_inplace) {
fnametmp = one_inplace ? partialptr : fname;
The in-place target is `partialptr`, the file inside the partial dir -
never the live destination. The entry is opened through fast_io's
three-arm chain (`O_WRONLY|O_CREAT`, the Linux `protected_regular` retry
without `O_CREAT`, then the read-only-destination arm) with
`InplaceResolution::OperatorWalk`, which is upstream's `one_inplace`
argument to `secure_recv_open()` at every arm: the partial dir is an
operator-supplied path, so each component is walked and a foreign-owned
symlink is refused. `OperatorWalk` had been implemented and left with no
production construction site; this is its first one.
Measured end to end on aarch64 Linux, an ordinary `--partial-dir`
transfer with nothing refusing anything:
openat(<mod>, "pdir", O_PATH|O_DIRECTORY|O_NOFOLLOW) = 5
openat(5, "victim", O_WRONLY|O_CREAT|O_TRUNC|O_NOFOLLOW, 0600)
renameat(<pdir>, "victim", <mod>, "victim") = 0
unlinkat(AT_FDCWD, "<mod>/pdir", AT_REMOVEDIR) = 0
rc 0, destination byte-identical to the source, no unlink of the entry
(upstream skips it under `one_inplace`, receiver.c:1291).
The ownership walk now issues its `openat`/`fstatat`/`readlinkat` through
fast_io's own libc-backed `*at` primitives rather than rustix, whose
`linux_raw` backend issues the syscall instruction directly. Upstream's
walk is plain C against libc (syscall.c:469), so an interposition layer
an operator has in place sees upstream's resolution; it did not see oc's.
Measured, driving `--exclude-from` through the walk: both component opens
appear under strace and neither appears to an LD_PRELOAD `openat` shim.
`O_LARGEFILE` is added explicitly on Linux because rustix added it, so
the emitted flag word is unchanged.
`resolve_use_inplace`'s comment argued the wire receiver's exclusion on
data-integrity grounds - that taking the in-place path would leave a
full-size incomplete file at the live destination. That reasoning read
upstream's in-place target as `fname`; it is `partialptr`. The comment
now states the real reason: this receiver has no partial-dir output mode
to write into, and the suppression is unreachable anyway because
`--inplace` and `--partial-dir` are rejected together.
Flips `partial-protected-regular-retry-linux` to pass in both 3.5.0
expect manifests. Upstream 3.5.0 passes the cell; oc failed at its
positive control. Two independent causes, each proven by reverting it
alone and watching the cell redden with the original message:
- the missing staging (no O_CREAT open of the partial entry at all);
- the rustix backend (the walk's opens invisible to the cell's shim,
which is how it models `fs.protected_regular`).
Full 3.5.0 suite against the manifests on that host: nonroot 254 pass /
5 fail / 86 skip, root 281/7/57. The only mismatch attributable to the
run rather than the host is none - `simd-checksum` skips on aarch64 in
both legs, and the root leg's `batch-file-symlink` passes 3/3 in
isolation (that run had the host at 98% disk).
Known remaining gap, unchanged: the local `--partial-dir` leaf is now a
staging target but still not a delta basis (generator.c:2270-2273), so
the entry is opened `O_TRUNC` where upstream relies on a final
`ftruncate`. Stated at the call site.
Append keeps precedence over the new strategy even though upstream's
ternary would not: this executor derives `append_offset` from the
destination's length, while upstream's comes from `sx.st` after the
generator replaced it with `partial_st` (generator.c:2271) - the partial
file's length. Honouring it here would seek to the wrong offset in the
wrong file. Stated at the selector, with a unit test.
oferchen
force-pushed
the
feat/one-inplace-partial-dir-staging
branch
from
September 1, 2026 11:59
6b3c998 to
3a491ff
Compare
clippy fires useless_conversion on u32::from(mode.bits()) because rustix's RawMode is already u32 on Linux. The conversion is not redundant on macOS, where mode_t is u16, so taking clippy's suggestion breaks that build. Neither spelling is clean on both targets - .. as u32 trips unnecessary_cast on Linux for the same reason - so the widening is kept and the lint allowed at the one site, matching the unused_mut allow the same function already carries for its cfg-conditional O_LARGEFILE.
…est sites
`fmt + clippy` failed with four instances of
error[E0061]: this function takes 8 arguments but 7 arguments were supplied
`select_write_strategy` gained `one_inplace_partial_dir` as its seventh
parameter in this branch. Two call sites in the test module were updated;
the four inside `#[cfg(target_os = "linux")]` blocks were not, so a macOS
build cannot see them and every Linux cell fails to compile the lib test.
All four assert O_TMPFILE/anonymous strategy selection, which is
orthogonal to the one_inplace staging gate, so they pass `false` — the
same value the shared `strategy()` helper already passes.
Verified by compiling the Linux-gated blocks on macOS: the four cfgs were
temporarily made unconditional, `cargo check -p engine --tests` reported
zero errors, and reverting one call site to seven arguments reproduced
E0061 exactly. The cfgs are restored to `target_os = "linux"`.
This was referenced Sep 2, 2026
oferchen
added a commit
that referenced
this pull request
Sep 2, 2026
…e tree (#7626) An accuracy audit of every performance, coverage and security claim in README.md and SECURITY.md against a workflow file, a committed manifest, a test or a measured number. Most of the 3.5.0 alignment already checked out; what follows is what did not. Stale testsuite outcomes. Both files carried 254/6 and 282/7 for the two full-corpus legs, "7 of 345 tests currently diverge", and "32 across all four". The committed manifests say 257/3 and 286/3, with 3 distinct divergences on the pipe legs and 29 across all four; #7596, #7598 and #7599 each fixed a divergence and flipped its manifest rows without refreshing the prose. Re-derived with the awk one-liner both files already publish. An unmeasured measurement. Both files said "a measured run of 100,000 sessions consumed a single bgid" as the evidence that the u16 bgid namespace cannot be exhausted. No such run exists in the tree, and it could not: per docs/audits/bgid-lifecycle.md section 5, BufferRing and BgidAllocator are constructed only inside fast_io and its tests, so an accepted connection consumes no bgid at all. The conclusion holds; the evidence for it is now the structural fact rather than an invented number. A benchmark shape no published release carries. The Performance section described the dual-baseline, peak-RSS, corpus-rate, spread-carrying report as what is "attached to every GitHub release", and the image alt text named both baselines. The linked image is served from the latest release, v0.6.4, whose benchmark_results.json has one baseline (3.4.4), a 148 MB corpus, and only mean/min/max per series. The paragraph now describes the harness and says plainly which releases predate it. MAX_WIRE_DEL_STAT. SECURITY cited crates/protocol/src/flist/delete_stats.rs, which does not exist, and claimed a cap "well below the upstream lowered ceiling". The reader is crates/protocol/src/stats/delete.rs and its cap is 1 << 28 - exactly upstream's rsync.h:187 value, unchanged in 3.4.4 and 3.5.0 - and it rejects rather than clamps. Parity is the right answer; "well below" was not. Landlock framing. README presented the daemon's Landlock layer as "cargo feature landlock", which reads as opt-in. crates/daemon pins fast_io with that feature under cfg(target_os = "linux"), so it is on in every Linux build including the released binaries. SECURITY's ABI enumeration stopped at v3 while the helper requests AccessFs::from_all(ABI::V5). Benchmark report: publish the sample size. stats() records `runs` with the stated intent that "a reader can tell a three-run cell from a six-run one", but the report left it in the JSON. A reset cell is timed 3 times with the warm-up discarded, so its median rests on 2 samples, and it rendered identically to a 6-run cell's median over 5. One `Runs` column per row states it - compare() hands every series in a row the same count - and the footnote now names which population the median and the spread each describe. benchmark_chart.py's no-baselines fallback said "3.4.4" while benchmark_report.py's said "3.5.0"; two renderers of one file would have named different upstream releases for the same run. Verified and left alone: the 33-CVE count, the five new options and three new daemon directives, the 13 Aug 2026 date, PROTOCOL_VERSION 32 / SUBPROTOCOL_VERSION 0 and byte-identical errcode.h (checked against the pinned 3.5.0 source); the 345/155 corpus sizes and the two tcp manifest rows; the interop version lists against run_interop.sh; the 26 fuzz targets against fuzz/Cargo.toml, name for name; the empty known-failures roster already described as historical; daemon-seccomp absent from the default set and from the release build; and every 3.4.4 mention that is deliberately about 3.4.4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Mirrors upstream's
one_inplacein the local-copy receiver: when a--partial-direntry for a file already exists as a regular file, the reconstruction is written into that entry and the entry is renamed onto the destination on commit.rsync-3.5.0/receiver.c:1195-1196:The in-place target under
one_inplaceispartialptr- the file inside the partial dir - never the live destination.receiver.c:1137-1138gates it (inplace_partial && fnamecmp_type == FNAMECMP_PARTIAL_DIR && fd1 != -1),receiver.c:1204-1224opens it through the three-arm chain withone_inplacethreaded into every arm, andreceiver.c:1288-1299renames it onto the destination and then removes the emptied partial dir - without unlinking the entry, becausefinish_transfer()already renamed it away.Before this, oc reconstructed into a temp beside the destination and deleted the partial entry afterwards, so
pdir/<name>was never opened at all.Measured end to end on aarch64 Linux - an ordinary
--partial-dirtransfer, nothing refusing anything, 90000-byte stale partial replaced by a 40960-byte source:rc=0, destination byte-identical to the source, no unlink of the entry.OperatorWalkgets its first production call sitefast_io::InplaceResolution::OperatorWalkand the three-armopen_inplace_outputchain were already ported and correct, butOperatorWalkwas constructed at zero production sites - all 10 occurrences repo-wide were infast_io's own unit tests.DestinationWriteGuard::new_one_inplaceis its first. No parallel resolver was written.The ownership walk now issues its syscalls through libc
fast_io::owner_walkusedrustix, whoselinux_rawbackend issues the syscall instruction directly and bypasses libc. Upstream's walk is plain C against libc (syscall.c:469), so an interposition layer an operator has in place -fakeroot, an audit or sandbox preload - sees upstream's resolution and did not see oc's. Measured, driving--exclude-fromthrough the walk:openatshimopenat(3, "cfg", …O_PATH|O_DIRECTORY)openat(4, "excl", …)The walk now routes onto
fast_io's own libc-backed*atprimitives (at_syscalls::openat/fstatat_nofollow/readlinkat), which the crate already owns and audits. Same syscalls, same flags (O_LARGEFILEis re-added explicitly on Linux because rustix added it), same checks - the resolver logic is untouched. This is the same class as theam_root/fakerootdivergence: a raw syscall answers a different question than upstream's libc call in an interposed process.The doc comment that argued the opposite
resolve_use_inplace's comment argued the wire receiver's exclusion on data-integrity grounds - that taking the in-place path for a--partial-dirresume "would write the reconstruction directly to the live destination and leave a full-size but incomplete file there on interrupt". That read upstream's in-place target asfname; it ispartialptr, so the hazard it described was a property of oc's implementation, not of upstream's design. The comment now states the real reason - this receiver has no partial-dir output mode to write into - and records that the suppression is unreachable today anyway, because--inplaceand--partial-dirare rejected together during config validation. The parity test's comment is corrected to match, and a stalecleanup.c:105-115citation is retargeted to thehandle_partial_dir()call atcleanup.c:169-170.Testsuite
tools/ci/upstream-3.5.0-expect.{nonroot,root}.txt:partial-protected-regular-retry-linuxfail → pass, measured on both legs.The cell builds an
LD_PRELOADshim that synthesises theEACCESanfs.protected_regularkernel raises on theO_CREATopen of the partial entry, swaps the partial dir for a foreign-owned symlink inside that window, and checks the retry keeps the ownership walk.Two independent causes, each proven by reverting it alone and rebuilding - the cell reddens with the original
receiver did not open the existing partial file with O_CREAT:one_inplace_partial_fileforced toNone(staging reverted, walk kept)walk_openatreverted torustix::fs::openat(walk backend reverted, staging kept)Upstream 3.5.0 itself passes the cell on the same host; that was the control run.
Full 3.5.0 suite against the manifests on that host: nonroot 254 pass / 5 fail / 86 skip, root 281 / 7 / 57. Expected-result mismatches:
simd-checksumskips on aarch64 in both legs (no x86 SIMD), and the root leg'sbatch-file-symlinkfailed once during a run with the host at 98% disk and three other builds active - it passes 3/3 in isolation there.Non-vacuity companions
New engine tests: an ordinary
--partial-dirtransfer stays byte-correct with and without a delta pass and clears the partial dir; the committed destination wears the inode the partial entry had (a rename, not a fresh temp - this one fails on the old behaviour); a symlink at the partial leaf is refused as a staging target (link_stat+S_ISREG,generator.c:2173-2179) and its target is untouched; andselect_write_strategyreturnsInplacePartialDironly when the gate is on.Known remaining gap
The local
--partial-dirleaf is now aone_inplacestaging target but is still not a delta basis: upstream's generator also setsfnamecmp = partialptr(generator.c:2270-2273) and lets a finalftruncatesize the result, whereas this executor still picks its basis from the destination or a--fuzzycandidate only. Because nothing reads the entry back, it is openedO_TRUNCwhere upstream does not - stated in full at the call site so the compensating half is visible. The wire receiver has neither half;resolve_use_inplace's comment now says so.One deliberate departure from upstream's precedence
--appendkeeps its own strategy even when a partial-dir entry exists, where upstream's ternary would pickpartialptr. Upstream's append seek (receiver.c:372-373) takes its offset fromsx.st, which the generator has already replaced withpartial_st(generator.c:2271) - the partial file's length. This executor derivesappend_offsetfrom the destination's length, which is not the fileone_inplacewrites into, so honouring it there would seek to the wrong offset in the wrong file.--appendand--partial-dirare rejected together through the CLI anyway. Stated at the selector, with a unit test.