Skip to content

feat(fast_io): add Windows ReFS reflink via FSCTL_DUPLICATE_EXTENTS (#1389)#3997

Merged
oferchen merged 2 commits into
masterfrom
feat/windows-refs-reflink-1389
May 13, 2026
Merged

feat(fast_io): add Windows ReFS reflink via FSCTL_DUPLICATE_EXTENTS (#1389)#3997
oferchen merged 2 commits into
masterfrom
feat/windows-refs-reflink-1389

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

  • Add try_refs_reflink_range() for partial-file CoW block cloning via FSCTL_DUPLICATE_EXTENTS_TO_FILE on Windows ReFS volumes, complementing the existing whole-file try_refs_reflink()
  • Extract compute_duplicate_extents_params() to encapsulate cluster alignment arithmetic (offsets rounded down, byte count rounded up to cluster boundary), making the logic testable without ReFS hardware
  • Add ReFS reflink to platform_io_capabilities() output on Windows

Test plan

  • 9 parameter construction tests verify cluster alignment for 4KB and 64KB cluster sizes, boundary crossings, zero byte count, and single-byte edge cases
  • Non-Windows platforms return ErrorKind::Unsupported for both range and zero-byte calls
  • Windows/NTFS tests verify graceful failure (CI uses NTFS, not ReFS)
  • Windows tests verify missing source and missing destination produce clean errors
  • Zero-byte range short-circuits to Ok(()) on Windows (no ioctl issued)
  • Formatting verified via cargo fmt --all -- --check

…1389)

Add partial-file reflink support via FSCTL_DUPLICATE_EXTENTS_TO_FILE
alongside the existing whole-file reflink. The new
try_refs_reflink_range() accepts source offset, destination offset, and
byte count, enabling block-level CoW clones of file subranges on ReFS.

Extract compute_duplicate_extents_params() to encapsulate cluster
alignment arithmetic, making parameter construction testable without
requiring a ReFS volume. Nine pure-logic tests verify alignment for
various cluster sizes (4KB, 64KB), boundary conditions, and edge cases.

Platform-specific tests validate graceful fallback on NTFS (CI) and
Unsupported on non-Windows. ReFS reflink added to
platform_io_capabilities() output.
@github-actions github-actions Bot added the enhancement New feature or request label May 13, 2026
Add #[cfg(any(target_os = "windows", test))] to DuplicateExtentsParams
and compute_duplicate_extents_params so they compile on all platforms
for tests but don't trigger dead_code errors in production builds on
Linux/macOS. Replace manual ((x + n - 1) / n) * n with .div_ceil(n).
@oferchen oferchen merged commit 3e75a6f into master May 13, 2026
39 checks passed
@oferchen oferchen deleted the feat/windows-refs-reflink-1389 branch May 14, 2026 14:57
oferchen added a commit that referenced this pull request May 18, 2026
…1389) (#3997)

* feat(fast_io): add Windows ReFS reflink via FSCTL_DUPLICATE_EXTENTS (#1389)

Add partial-file reflink support via FSCTL_DUPLICATE_EXTENTS_TO_FILE
alongside the existing whole-file reflink. The new
try_refs_reflink_range() accepts source offset, destination offset, and
byte count, enabling block-level CoW clones of file subranges on ReFS.

Extract compute_duplicate_extents_params() to encapsulate cluster
alignment arithmetic, making parameter construction testable without
requiring a ReFS volume. Nine pure-logic tests verify alignment for
various cluster sizes (4KB, 64KB), boundary conditions, and edge cases.

Platform-specific tests validate graceful fallback on NTFS (CI) and
Unsupported on non-Windows. ReFS reflink added to
platform_io_capabilities() output.

* fix: gate ReFS reflink helpers with cfg(windows|test) and use div_ceil

Add #[cfg(any(target_os = "windows", test))] to DuplicateExtentsParams
and compute_duplicate_extents_params so they compile on all platforms
for tests but don't trigger dead_code errors in production builds on
Linux/macOS. Replace manual ((x + n - 1) / n) * n with .div_ceil(n).
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