Repository navigation
feat: wire --write-batch into SSH and daemon transfer paths - #3026
Merged
Merged
Conversation
oferchen
force-pushed
the
feature/batch-remote-tee
branch
from
March 27, 2026 17:52
5c01347 to
c133664
Compare
…ecording Record demuxed protocol bytes at the multiplex layer instead of raw I/O, matching upstream rsync's write_batch_monitor_in/out taps in io.c. - Add BatchRecording struct in transfer crate with on_setup_complete callback for deferred header writing after protocol negotiation - Refactor ServerReader from enum to struct+inner for pending recorder propagation across Plain->Multiplex transitions - Add batch_recorder field to MultiplexReader (post-demux) and MultiplexWriter (pre-mux) for correct protocol data capture - Replace TeeReader/TeeWriter approach with BatchWriteAdapter bridging BatchWriter::write_data() to std::io::Write trait - Delete dead tee.rs module
… batch support Extract BatchContext, build_batch_context, build_batch_recording, and BatchWriteAdapter from ssh_transfer.rs into a shared batch_support module. Wire the batch recording through run_daemon_transfer -> run_pull_transfer / run_push_transfer -> run_server_with_handshake, enabling --write-batch for rsync:// daemon connections.
Verify that batch recording correctly captures pre-mux data on the writer side and post-demux data on the reader side. Includes roundtrip test confirming both sides capture identical protocol bytes.
Add a fast path in execute_transfer() that attempts clonefile() before falling back to the normal read/write copy pipeline. On APFS, this creates an instant copy-on-write clone with zero I/O overhead. Conditions: new file, whole-file mode, no inplace/partial/sparse/ compress/bandwidth-limiter/delay-updates/temp-dir/copy-dest-override. On failure (cross-device, non-APFS), falls through to normal copy. Also adds has_bandwidth_limiter() accessor to CopyContext.
Only caller is the APFS clonefile path which is macOS-only.
oferchen
force-pushed
the
feature/batch-remote-tee
branch
3 times, most recently
from
March 27, 2026 18:56
a27ee56 to
2e9d10f
Compare
oferchen
force-pushed
the
feature/batch-remote-tee
branch
from
March 27, 2026 19:10
2e9d10f to
1e1e242
Compare
Increase test payload from 256KB to 4MB so intermediate progress updates are emitted even on fast systems. Remove timing-dependent \r assertion - carriage returns depend on transfer speed.
The test created a new destination file (no pre-existing file) with source mode 0o511. With typical umask 0o022, the resulting mode 0o511 & ~0o022 = 0o511 was unchanged, making the assert_ne!(mode & 0o666, 0o511 & 0o666) always fail since both sides equal 0o400. Fix: pre-create destination with known different permissions (0o620) and use --ignore-times to force transfer. This matches the engine-level test pattern and reliably verifies that --executability only toggles execute bits while preserving the destination's non-execute bits.
oferchen
force-pushed
the
feature/batch-remote-tee
branch
4 times, most recently
from
March 27, 2026 20:11
47f5007 to
ccbda6e
Compare
clonefile() preserves source metadata verbatim. When metadata preservation is disabled (--no-perms, --no-times), finalize_guard_and_metadata skips corrections assuming open()-created defaults. This left cloned files with source permissions and mtime instead of umask/current-time defaults. Add normalize_cloned_metadata() to bridge the gap: after a successful clonefile, reset permissions to source_mode & ~umask and mtime to current time when the respective preservation flags are off. This makes the clonefile path transparent - finalize_guard_and_metadata produces identical results regardless of whether clonefile or read/write copy was used. Also fix flaky tests that depended on specific umask/mtime behavior: - executability test: use pre-existing destination with known permissions - no_perms test: use 0o777 source mode so umask always makes a difference - no_times test: use SystemTime::now() comparison instead of exact equality
oferchen
force-pushed
the
feature/batch-remote-tee
branch
from
March 27, 2026 20:21
ccbda6e to
e791a16
Compare
clonefile() preserves source permissions verbatim, so a source with mode 0o444 produces a read-only destination. The previous approach of opening the file with write access to call set_modified() fails with PermissionDenied on such files. Switch to rustix::fs::utimensat() with UTIME_NOW, which operates on the path via syscall and does not require write access to the file. This matches the ownership-based permission model of utimensat(2).
clonefile() copies all xattrs from the source verbatim. When xattr filter rules are configured to exclude specific attributes, the clonefile fast path bypasses the selective xattr copy logic in finalize_guard_and_metadata. Fall back to the standard read/write path so that xattr filtering is applied correctly.
normalize_cloned_metadata used source_mode & 0o7777 which preserves setuid/setgid/sticky bits. When open() creates files, special bits are never set - only standard permission bits are applied with umask. Mask to 0o777 to match open() semantics and also skip clonefile when xattr filter rules are active since clonefile copies all xattrs verbatim, preventing selective filtering.
Refactor clonefile conditions into a single clonefile_eligible block that centralizes all safety checks. Add xattr_ok guard that requires xattrs_enabled when the xattr feature is active - clonefile copies all xattrs verbatim, so it must be skipped when xattrs should not appear on the destination (xattrs disabled) or when selective xattr filtering is needed (xattr filter rules active).
oferchen
added a commit
that referenced
this pull request
May 1, 2026
* feat: wire --write-batch into SSH transfer path via multiplex-level recording Record demuxed protocol bytes at the multiplex layer instead of raw I/O, matching upstream rsync's write_batch_monitor_in/out taps in io.c. - Add BatchRecording struct in transfer crate with on_setup_complete callback for deferred header writing after protocol negotiation - Refactor ServerReader from enum to struct+inner for pending recorder propagation across Plain->Multiplex transitions - Add batch_recorder field to MultiplexReader (post-demux) and MultiplexWriter (pre-mux) for correct protocol data capture - Replace TeeReader/TeeWriter approach with BatchWriteAdapter bridging BatchWriter::write_data() to std::io::Write trait - Delete dead tee.rs module * feat: wire --write-batch into daemon transfer path and extract shared batch support Extract BatchContext, build_batch_context, build_batch_recording, and BatchWriteAdapter from ssh_transfer.rs into a shared batch_support module. Wire the batch recording through run_daemon_transfer -> run_pull_transfer / run_push_transfer -> run_server_with_handshake, enabling --write-batch for rsync:// daemon connections. * test: add batch recorder tests for multiplex writer and reader Verify that batch recording correctly captures pre-mux data on the writer side and post-demux data on the reader side. Includes roundtrip test confirming both sides capture identical protocol bytes. * feat: wire macOS clonefile into transfer hot path Add a fast path in execute_transfer() that attempts clonefile() before falling back to the normal read/write copy pipeline. On APFS, this creates an instant copy-on-write clone with zero I/O overhead. Conditions: new file, whole-file mode, no inplace/partial/sparse/ compress/bandwidth-limiter/delay-updates/temp-dir/copy-dest-override. On failure (cross-device, non-APFS), falls through to normal copy. Also adds has_bandwidth_limiter() accessor to CopyContext. * fix: gate has_bandwidth_limiter behind cfg(target_os = "macos") Only caller is the APFS clonefile path which is macOS-only. * fix: correct MultiplexWriter import path in reader tests * fix: eliminate flaky progress test on fast macOS CI runners Increase test payload from 256KB to 4MB so intermediate progress updates are emitted even on fast systems. Remove timing-dependent \r assertion - carriage returns depend on transfer speed. * fix: correct flaky executability test that depended on umask behavior The test created a new destination file (no pre-existing file) with source mode 0o511. With typical umask 0o022, the resulting mode 0o511 & ~0o022 = 0o511 was unchanged, making the assert_ne!(mode & 0o666, 0o511 & 0o666) always fail since both sides equal 0o400. Fix: pre-create destination with known different permissions (0o620) and use --ignore-times to force transfer. This matches the engine-level test pattern and reliably verifies that --executability only toggles execute bits while preserving the destination's non-execute bits. * style: fix rustfmt formatting in executability test * fix: normalize cloned metadata for seamless clonefile integration clonefile() preserves source metadata verbatim. When metadata preservation is disabled (--no-perms, --no-times), finalize_guard_and_metadata skips corrections assuming open()-created defaults. This left cloned files with source permissions and mtime instead of umask/current-time defaults. Add normalize_cloned_metadata() to bridge the gap: after a successful clonefile, reset permissions to source_mode & ~umask and mtime to current time when the respective preservation flags are off. This makes the clonefile path transparent - finalize_guard_and_metadata produces identical results regardless of whether clonefile or read/write copy was used. Also fix flaky tests that depended on specific umask/mtime behavior: - executability test: use pre-existing destination with known permissions - no_perms test: use 0o777 source mode so umask always makes a difference - no_times test: use SystemTime::now() comparison instead of exact equality * fix: use utimensat for mtime reset on read-only cloned files clonefile() preserves source permissions verbatim, so a source with mode 0o444 produces a read-only destination. The previous approach of opening the file with write access to call set_modified() fails with PermissionDenied on such files. Switch to rustix::fs::utimensat() with UTIME_NOW, which operates on the path via syscall and does not require write access to the file. This matches the ownership-based permission model of utimensat(2). * style: fix rustfmt formatting in utimensat call * fix: skip clonefile when xattr filter rules are active clonefile() copies all xattrs from the source verbatim. When xattr filter rules are configured to exclude specific attributes, the clonefile fast path bypasses the selective xattr copy logic in finalize_guard_and_metadata. Fall back to the standard read/write path so that xattr filtering is applied correctly. * fix: strip special bits in clonefile metadata normalization normalize_cloned_metadata used source_mode & 0o7777 which preserves setuid/setgid/sticky bits. When open() creates files, special bits are never set - only standard permission bits are applied with umask. Mask to 0o777 to match open() semantics and also skip clonefile when xattr filter rules are active since clonefile copies all xattrs verbatim, preventing selective filtering. * fix: centralize clonefile eligibility with xattr guard Refactor clonefile conditions into a single clonefile_eligible block that centralizes all safety checks. Add xattr_ok guard that requires xattrs_enabled when the xattr feature is active - clonefile copies all xattrs verbatim, so it must be skipped when xattrs should not appear on the destination (xattrs disabled) or when selective xattr filtering is needed (xattr filter rules active).
oferchen
added a commit
that referenced
this pull request
May 5, 2026
* feat: wire --write-batch into SSH transfer path via multiplex-level recording Record demuxed protocol bytes at the multiplex layer instead of raw I/O, matching upstream rsync's write_batch_monitor_in/out taps in io.c. - Add BatchRecording struct in transfer crate with on_setup_complete callback for deferred header writing after protocol negotiation - Refactor ServerReader from enum to struct+inner for pending recorder propagation across Plain->Multiplex transitions - Add batch_recorder field to MultiplexReader (post-demux) and MultiplexWriter (pre-mux) for correct protocol data capture - Replace TeeReader/TeeWriter approach with BatchWriteAdapter bridging BatchWriter::write_data() to std::io::Write trait - Delete dead tee.rs module * feat: wire --write-batch into daemon transfer path and extract shared batch support Extract BatchContext, build_batch_context, build_batch_recording, and BatchWriteAdapter from ssh_transfer.rs into a shared batch_support module. Wire the batch recording through run_daemon_transfer -> run_pull_transfer / run_push_transfer -> run_server_with_handshake, enabling --write-batch for rsync:// daemon connections. * test: add batch recorder tests for multiplex writer and reader Verify that batch recording correctly captures pre-mux data on the writer side and post-demux data on the reader side. Includes roundtrip test confirming both sides capture identical protocol bytes. * feat: wire macOS clonefile into transfer hot path Add a fast path in execute_transfer() that attempts clonefile() before falling back to the normal read/write copy pipeline. On APFS, this creates an instant copy-on-write clone with zero I/O overhead. Conditions: new file, whole-file mode, no inplace/partial/sparse/ compress/bandwidth-limiter/delay-updates/temp-dir/copy-dest-override. On failure (cross-device, non-APFS), falls through to normal copy. Also adds has_bandwidth_limiter() accessor to CopyContext. * fix: gate has_bandwidth_limiter behind cfg(target_os = "macos") Only caller is the APFS clonefile path which is macOS-only. * fix: correct MultiplexWriter import path in reader tests * fix: eliminate flaky progress test on fast macOS CI runners Increase test payload from 256KB to 4MB so intermediate progress updates are emitted even on fast systems. Remove timing-dependent \r assertion - carriage returns depend on transfer speed. * fix: correct flaky executability test that depended on umask behavior The test created a new destination file (no pre-existing file) with source mode 0o511. With typical umask 0o022, the resulting mode 0o511 & ~0o022 = 0o511 was unchanged, making the assert_ne!(mode & 0o666, 0o511 & 0o666) always fail since both sides equal 0o400. Fix: pre-create destination with known different permissions (0o620) and use --ignore-times to force transfer. This matches the engine-level test pattern and reliably verifies that --executability only toggles execute bits while preserving the destination's non-execute bits. * style: fix rustfmt formatting in executability test * fix: normalize cloned metadata for seamless clonefile integration clonefile() preserves source metadata verbatim. When metadata preservation is disabled (--no-perms, --no-times), finalize_guard_and_metadata skips corrections assuming open()-created defaults. This left cloned files with source permissions and mtime instead of umask/current-time defaults. Add normalize_cloned_metadata() to bridge the gap: after a successful clonefile, reset permissions to source_mode & ~umask and mtime to current time when the respective preservation flags are off. This makes the clonefile path transparent - finalize_guard_and_metadata produces identical results regardless of whether clonefile or read/write copy was used. Also fix flaky tests that depended on specific umask/mtime behavior: - executability test: use pre-existing destination with known permissions - no_perms test: use 0o777 source mode so umask always makes a difference - no_times test: use SystemTime::now() comparison instead of exact equality * fix: use utimensat for mtime reset on read-only cloned files clonefile() preserves source permissions verbatim, so a source with mode 0o444 produces a read-only destination. The previous approach of opening the file with write access to call set_modified() fails with PermissionDenied on such files. Switch to rustix::fs::utimensat() with UTIME_NOW, which operates on the path via syscall and does not require write access to the file. This matches the ownership-based permission model of utimensat(2). * style: fix rustfmt formatting in utimensat call * fix: skip clonefile when xattr filter rules are active clonefile() copies all xattrs from the source verbatim. When xattr filter rules are configured to exclude specific attributes, the clonefile fast path bypasses the selective xattr copy logic in finalize_guard_and_metadata. Fall back to the standard read/write path so that xattr filtering is applied correctly. * fix: strip special bits in clonefile metadata normalization normalize_cloned_metadata used source_mode & 0o7777 which preserves setuid/setgid/sticky bits. When open() creates files, special bits are never set - only standard permission bits are applied with umask. Mask to 0o777 to match open() semantics and also skip clonefile when xattr filter rules are active since clonefile copies all xattrs verbatim, preventing selective filtering. * fix: centralize clonefile eligibility with xattr guard Refactor clonefile conditions into a single clonefile_eligible block that centralizes all safety checks. Add xattr_ok guard that requires xattrs_enabled when the xattr feature is active - clonefile copies all xattrs verbatim, so it must be skipped when xattrs should not appear on the destination (xattrs disabled) or when selective xattr filtering is needed (xattr filter rules active).
Merged
5 tasks
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.
Summary
--write-batchrecording into SSH transfer path via multiplex-level taps (post-demux for reads, pre-mux for writes), matching upstream rsync'swrite_batch_monitor_in/write_batch_monitor_outinio.c--write-batchrecording into daemon (rsync://) transfer path for both pull and push operationsBatchContext,BatchWriteAdapter,build_batch_recording) intobatch_support.rsto keep SSH and daemon paths DRYServerReaderfrom enum to struct+inner for pending batch recorder propagation across Plain->Multiplex transitionsBatchRecordingstruct in transfer crate withon_setup_completecallback for deferred header writing after protocol negotiationtee.rsmodule (replaced by multiplex-level recording)Design
Uses the Adapter Pattern (
BatchWriteAdapter) to bridgeBatchWriter::write_data()tostd::io::Write, and a callback hook (on_setup_complete) to defer batch header writing until negotiated protocol values are available aftersetup_protocol().Test plan
--write-batchproduces valid batch files over SSH transfers--write-batchproduces valid batch files over daemon transfers--read-batchcan replay files written by--write-batch