Skip to content

fix: report logical bytes for zero-copy clonefile/FICLONE/ReFS paths#3394

Closed
oferchen wants to merge 1 commit intomasterfrom
fix/macos-clonefile-bytes-copied
Closed

fix: report logical bytes for zero-copy clonefile/FICLONE/ReFS paths#3394
oferchen wants to merge 1 commit intomasterfrom
fix/macos-clonefile-bytes-copied

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

Root cause

dispatch::platform_copy_impl correctly returns CopyResult { bytes_copied: 0, method: Clonefile } because no bytes physically traversed userspace. The win_copy user-facing wrapper passed this through, so WinCopyResult::StandardCopy(0) was reported even when a multi-MB file was cloned.

Fix

Use CopyResult::is_zero_copy() (already exists for exactly this distinction) to substitute the source size_hint for the user-facing byte count when the operation went through a zero-copy path. Statistics and progress now reflect the data made available at the destination, matching upstream rsync's accounting.

Test plan

  • Local build/lint clean (per workflow policy, full nextest deferred to CI)
  • CI: macOS stable
  • CI: Linux musl + Windows stable (regression check)
  • CI: fmt + clippy

Zero-copy reflink methods (clonefile, FICLONE, ReFS DUPLICATE_EXTENTS)
return bytes_copied=0 from the platform_copy dispatch layer because no
data physically traversed userspace. The user-facing copy_file_optimized_with
wrapper was passing this through unchanged, causing macOS test failures
(test_copy_large_file, test_copy_file_optimized_result_type) and
under-reporting transfer statistics.

Substitute the source file size_hint when CopyResult::is_zero_copy() so
progress and statistics reflect the data made available at the destination.
The lower-layer dispatch contract is preserved (it still reports 0 for
zero-copy methods, as required by platform_copy/tests.rs).
@github-actions github-actions Bot added the bug Something isn't working label Apr 26, 2026
@oferchen
Copy link
Copy Markdown
Owner Author

Superseded by #3395 - the macOS clonefile fix (commit 91f594b) was cherry-picked onto #3395 to break the cross-PR CI dependency, and merged via that PR.

@oferchen oferchen closed this Apr 26, 2026
@oferchen oferchen deleted the fix/macos-clonefile-bytes-copied branch April 26, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant