Repository navigation
fix(batch): carry hardlinks through --write-batch and --read-batch - #7596
Merged
Merged
Conversation
A batch recorded by the local copy path described every hardlink cluster member as an independent file: build_protocol_file_entry() never set the hardlink identity, so the flist carried neither XMIT_HLINKED nor a group index and the payload was repeated once per member. Replay had the matching hole - it decoded the hardlink fields upstream sends but never acted on them, so a cluster came back as unrelated copies. Both ends are needed: a batch written by oc-rsync and replayed by upstream rsync 3.5.0 lost the links because the writer said nothing, and one written by upstream and replayed by oc-rsync lost them because the reader ignored what it was told. Writer: capture_batch_file_entry() now groups non-directories with st_nlink > 1 by (st_dev, st_ino) in traversal order, marking the first sighting XMIT_HLINK_FIRST and every repeat a follower carrying the leader's index (flist.c:599-625, flist.c:668-672, flist.c:741-753 for the pre-30 dev/ino form). flush_batch_delta_to_batch() then drops the duplicated payloads, leaving one per cluster as hlink.c:113-194 match_gnums() and generator.c's hard_link_check() skip make upstream do. Replay: gnums are stamped in wire order before the sort, matching flist.c:1335-1341, and a pass after the delta phase links each cluster to the member the batch actually fed - hlink.c:496-565 finish_hard_link() picks the same file for the same reason. Flips batch-only-remove-source-regression to ok in the 3.5.0 expect manifests.
oferchen
force-pushed
the
fix/batch-hardlink-roundtrip
branch
from
September 1, 2026 10:05
e50f9b8 to
ce74ca5
Compare
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.
Upstream testsuite cell
batch-only-remove-source-regressionfails on bothpipe legs (nonroot and root) with
the retained batch did not reproduce the source hard link. Upstream rsync 3.5.0 passes it. Content was alreadybyte-correct; only the
-Hhardlink data was lost, and only on the batch path(a plain
-aHlocal transfer links correctly).Two coupled defects
A cross matrix of writer x replayer,
-aH --only-write-batchthen-aH --read-batch, on a source directory holding two names for one inode(aarch64 Linux, upstream 3.5.0 built from the pinned tarball):
Both directions failed, so both ends were wrong and fixing one would have left
the cell red.
Writer.
build_protocol_file_entry()never set any hardlink identity onthe flist entry it built, so the encoded batch flist carried neither
XMIT_HLINKEDnor a group index, and the payload was written once per clustermember (the batch was 1878 bytes where upstream's was 1005 for the same tree).
Replay.
batch::replaydecoded the hardlink fields an upstream-writtenbatch does carry -
FileListReaderalready resolves the abbreviated followerentry - but nothing ever acted on them, so a cluster came back as unrelated
copies and the follower kept its pre-replay bytes.
The format, from upstream
Mirrored rather than invented; the citations are to the pinned 3.5.0 tree.
flist.c:1628-1635make_file(): an entry is a cluster candidate when!S_ISDIR(st.st_mode) && st.st_nlink > 1(protocol >= 28).flist.c:599-625send_file_entry():idev_find(dev, ino)returns -1 for afirst sighting, which records
first_ndx + ndxand setsXMIT_HLINK_FIRST;every repeat becomes a follower.
XMIT_HLINKEDis set either way.flist.c:668-672: a follower writeswrite_varint(first_hlink_ndx)rightafter the name and then
goto the_end- no length, mtime, mode or ownershipfollows.
flist.c:741-753: below protocol 30 there is no index; the cluster is namedby a trailing
(dev, ino)pair instead.flist.c:1335-1341recv_file_entry():F_HL_GNUMis stamped while theentry is still in wire order - the leader records its own index, a follower
the one it was sent.
hlink.c:113-194match_gnums(): clusters by that tag over the sortedlist and marks the sorted-first member
FLAG_HLINK_FIRST;generator.croutes every other member through
hlink.c:300 hard_link_check(), whichreturns 1 (skip), so the payload is requested exactly once per cluster.
hlink.c:496-565finish_hard_link(): the member that completes becomes thelink source - "FIRST combined with DONE means we were the first to get done".
No divergence from that format. The one place this implementation has a choice
upstream does not is which member the replay treats as the link source: the
replay uses the member the batch actually fed rather than assuming the
sorted-first, which is the same rule
finish_hard_link()applies and keeps abatch written by either implementation replayable.
The fix
Writer (
crates/engine):capture_batch_file_entry()groups candidates by(st_dev, st_ino)in traversal order, stamping the first sighting with theu32::MAXsentinelFileListWriterreads asXMIT_HLINK_FIRSTand everyrepeat with the leader's index (or the
(dev, ino)pair below protocol 30).flush_batch_delta_to_batch()then drops the duplicated payloads through thetraversal-to-sorted mapping it already builds, leaving one per cluster - the
sorted-first, as
match_gnums()makes upstream do.Replay (
crates/batch): group tags are stamped in wire order before the sort(and per segment under INC_RECURSE, where the tags live in that segment's NDX
space), the delta phase records which entries it wrote, and a pass after it
links each cluster to the member the batch fed. A member that already shares
the source's inode is left alone, matching
hlink.c:224-256 maybe_hard_link().Evidence
PASS, and undersudoPASS.failures (
basis-xname-traversal,filter-merge-content-echo,partial-protected-regular-retry-linux,rrsync-backup-dir-inband-pivot,rrsync-merge-file-confine) are already recordedfailin the manifest, sonothing regressed.
batch-mode,write-batch-quoting,write-batch-filter-injection,operator-path-write-batch,scanner-batch-flag-mismatch,hardlinks);batch-file-symlinkstill skipsas non-root.
assign_batch_hlink_groupforced tofind no cluster): the two writer rows redden and only those -
oc->upstreamandoc->ocNOTLINKED,upstream->ocstill LINKED - and thecell fails at
the retained batch did not reproduce the source hard link,the original message.
link_hardlink_clustersdisabled): thetwo replay rows redden and only those -
upstream->ocandoc->ocNOTLINKED with stale follower content,
oc->upstreamstill LINKED - and thecell fails at
the retained batch did not install hard-linked payloads.crates/engine/tests/only_write_batch_hard_links.rscovers a three-membercluster whose sorted-first member is not the one the walk reaches first, plus
a same-content file that was never linked. Both mutations above kill it.
Manifests
batch-only-remove-source-regressionflippedfail->passintools/ci/upstream-3.5.0-expect.nonroot.txtand.root.txt, in the samecommit as the fix.