Skip to content

feat: add Linux FICLONE reflink support via rustix - #3025

Merged
oferchen merged 1 commit into
masterfrom
feature/ficlone-reflink
Mar 27, 2026
Merged

oferchen merged 1 commit into
masterfrom
feature/ficlone-reflink

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Add copy-on-write reflink cloning using rustix::fs::ioctl_ficlone - fully safe, no raw FFI, zero new dependencies
  • On Btrfs, XFS (reflink enabled), and bcachefs, FICLONE creates instant O(1) clones sharing storage blocks until modification
  • Linux copy dispatch chain is now: FICLONE -> copy_file_range -> std::fs::copy
  • Graceful fallback on unsupported filesystems (ext4, tmpfs, NFS, FUSE)

Changes

  • CopyMethod::Ficlone variant with Display and is_zero_copy support
  • try_ficlone() standalone function re-exported from fast_io
  • platform_supports_reflink() returns true on Linux
  • platform_preferred_method() prefers Ficlone on Linux
  • 4 new Linux-specific tests + 5 updated existing tests

Test plan

  • CI passes on all platforms (Linux, macOS, Windows)
  • Linux tests exercise FICLONE fallback on non-reflink filesystems
  • macOS/Windows tests confirm Unsupported stub behavior
  • Existing platform_copy tests updated for new enum variant

Add copy-on-write reflink cloning using rustix::fs::ioctl_ficlone -
fully safe, no raw FFI, zero new dependencies. On Btrfs, XFS (reflink
enabled), and bcachefs, FICLONE creates instant O(1) clones sharing
storage blocks until modification.

Linux copy dispatch chain is now: FICLONE -> copy_file_range -> std::fs::copy.
Graceful fallback on unsupported filesystems (ext4, tmpfs, NFS, FUSE).

- Add CopyMethod::Ficlone variant with Display, is_zero_copy support
- Add try_ficlone() standalone function and re-export from fast_io
- Update platform_supports_reflink() to return true on Linux
- Update platform_preferred_method() to prefer Ficlone on Linux
- Add tests: graceful fallback, missing source, dispatch chain, stubs
@github-actions github-actions Bot added the enhancement New feature or request label Mar 27, 2026
@oferchen
oferchen merged commit a56f5f4 into master Mar 27, 2026
34 of 35 checks passed
@oferchen
oferchen deleted the feature/ficlone-reflink branch March 27, 2026 10:55
oferchen added a commit that referenced this pull request May 1, 2026
Add copy-on-write reflink cloning using rustix::fs::ioctl_ficlone -
fully safe, no raw FFI, zero new dependencies. On Btrfs, XFS (reflink
enabled), and bcachefs, FICLONE creates instant O(1) clones sharing
storage blocks until modification.

Linux copy dispatch chain is now: FICLONE -> copy_file_range -> std::fs::copy.
Graceful fallback on unsupported filesystems (ext4, tmpfs, NFS, FUSE).

- Add CopyMethod::Ficlone variant with Display, is_zero_copy support
- Add try_ficlone() standalone function and re-export from fast_io
- Update platform_supports_reflink() to return true on Linux
- Update platform_preferred_method() to prefer Ficlone on Linux
- Add tests: graceful fallback, missing source, dispatch chain, stubs
oferchen added a commit that referenced this pull request May 5, 2026
Add copy-on-write reflink cloning using rustix::fs::ioctl_ficlone -
fully safe, no raw FFI, zero new dependencies. On Btrfs, XFS (reflink
enabled), and bcachefs, FICLONE creates instant O(1) clones sharing
storage blocks until modification.

Linux copy dispatch chain is now: FICLONE -> copy_file_range -> std::fs::copy.
Graceful fallback on unsupported filesystems (ext4, tmpfs, NFS, FUSE).

- Add CopyMethod::Ficlone variant with Display, is_zero_copy support
- Add try_ficlone() standalone function and re-export from fast_io
- Update platform_supports_reflink() to return true on Linux
- Update platform_preferred_method() to prefer Ficlone on Linux
- Add tests: graceful fallback, missing source, dispatch chain, stubs
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