Skip to content

Fix unreachable arch dispatcher code - #1921

Merged
oferchen merged 1 commit into
masterfrom
fix-unreachable-code-in-checksum.rs
Nov 4, 2025
Merged

oferchen merged 1 commit into
masterfrom
fix-unreachable-code-in-checksum.rs

Conversation

@oferchen

@oferchen oferchen commented Nov 4, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • split the rolling checksum arch dispatcher into per-target implementations
  • provide a no-op fallback for targets without SIMD support to avoid unreachable code diagnostics

Testing

  • cargo check -p rsync-checksums

@oferchen
oferchen merged commit fb9f05c into master Nov 4, 2025
@oferchen
oferchen deleted the fix-unreachable-code-in-checksum.rs branch November 4, 2025 00:46
oferchen added a commit that referenced this pull request May 6, 2026
Closes #1921, #1923.

Adds a typed wrapper around `IORING_OP_LINKAT` (Linux 5.15+) so the
receiver can submit hardlink creation alongside disk writes on the same
ring instead of issuing a synchronous `linkat(2)` syscall per hardlinked
file.

The new `linkat` submodule mirrors the conventions used by
`shared_ring::probe_poll_add` and `splice::is_splice_available`:

- `LINKAT_MIN_KERNEL = (5, 15)` and `IORING_OP_LINKAT = 39` constants.
- `linkat_supported()` short-circuits on `is_io_uring_available()`,
  builds a throwaway ring, and asks the kernel via
  `IORING_REGISTER_PROBE` whether opcode 39 is supported. The result is
  cached in a process-wide `OnceLock`.
- `LinkAtArgs<'a>` borrows source/destination `&CStr` paths plus dirfds
  and `flags` so the compiler enforces the kernel's path lifetime
  contract.
- `build_linkat_sqe` returns `io::ErrorKind::Unsupported` when the probe
  is `false`; `build_linkat_sqe_unchecked` exposes the encoder for unit
  tests.
- `submit_linkat_blocking` builds a private 2-entry ring, submits the
  SQE, and returns the kernel's CQE result.

The non-Linux stub in `io_uring_stub.rs` provides the same names with
`linkat_supported() -> false` and `Unsupported` round-trips. Public
re-exports in `crates/fast_io/src/lib.rs` and the Linux `io_uring`
module make the API available to consumer crates.

Tests:

- Unit tests verify `opcode::LinkAt::CODE == 39`, the cached probe is
  idempotent, the unchecked SQE encoder accepts user_data, and the stub
  consistently returns `Unsupported`.
- `tests/io_uring_linkat.rs` (Linux+`io_uring` feature) submits a real
  LINKAT, verifies the destination hardlink, and unlinks it; skips when
  the kernel does not advertise the opcode.
oferchen added a commit that referenced this pull request May 6, 2026
* feat(fast_io): add io_uring LINKAT wrapper and kernel probe

Closes #1921, #1923.

Adds a typed wrapper around `IORING_OP_LINKAT` (Linux 5.15+) so the
receiver can submit hardlink creation alongside disk writes on the same
ring instead of issuing a synchronous `linkat(2)` syscall per hardlinked
file.

The new `linkat` submodule mirrors the conventions used by
`shared_ring::probe_poll_add` and `splice::is_splice_available`:

- `LINKAT_MIN_KERNEL = (5, 15)` and `IORING_OP_LINKAT = 39` constants.
- `linkat_supported()` short-circuits on `is_io_uring_available()`,
  builds a throwaway ring, and asks the kernel via
  `IORING_REGISTER_PROBE` whether opcode 39 is supported. The result is
  cached in a process-wide `OnceLock`.
- `LinkAtArgs<'a>` borrows source/destination `&CStr` paths plus dirfds
  and `flags` so the compiler enforces the kernel's path lifetime
  contract.
- `build_linkat_sqe` returns `io::ErrorKind::Unsupported` when the probe
  is `false`; `build_linkat_sqe_unchecked` exposes the encoder for unit
  tests.
- `submit_linkat_blocking` builds a private 2-entry ring, submits the
  SQE, and returns the kernel's CQE result.

The non-Linux stub in `io_uring_stub.rs` provides the same names with
`linkat_supported() -> false` and `Unsupported` round-trips. Public
re-exports in `crates/fast_io/src/lib.rs` and the Linux `io_uring`
module make the API available to consumer crates.

Tests:

- Unit tests verify `opcode::LinkAt::CODE == 39`, the cached probe is
  idempotent, the unchecked SQE encoder accepts user_data, and the stub
  consistently returns `Unsupported`.
- `tests/io_uring_linkat.rs` (Linux+`io_uring` feature) submits a real
  LINKAT, verifies the destination hardlink, and unlinks it; skips when
  the kernel does not advertise the opcode.

* fix(fast_io): use io::Error::other for clippy::io_other_error

* fix(fast_io): use c"..." CStr literals to satisfy clippy manual_c_str_literals
oferchen added a commit that referenced this pull request May 13, 2026
Wire the existing IORING_OP_RENAMEAT (task #1920) and IORING_OP_LINKAT
(task #1921) opcode wrappers into the temp-file commit and hardlink
finalization paths respectively.

On Linux 5.11+ with io_uring available, temp-file renames in
DestinationWriteGuard::commit_named_temp_file() now submit an
IORING_OP_RENAMEAT SQE instead of a synchronous rename(2) syscall.

On Linux 5.15+ with io_uring available, hardlink creation in
HardlinkApplyTracker, create_hard_link(), and the --link-dest path
now submit an IORING_OP_LINKAT SQE instead of a synchronous link(2).

Both paths fall back transparently to std::fs::rename / std::fs::hard_link
on non-Linux platforms, older kernels, or when io_uring is disabled.

Two new convenience functions in fast_io expose the try-or-fallback
pattern: try_rename_via_io_uring() and try_hard_link_via_io_uring(),
returning Option<io::Result<()>> so callers can fall through to the
portable implementation when None is returned.

Closes #1924, closes #1925.
oferchen added a commit that referenced this pull request May 18, 2026
* feat(fast_io): add io_uring LINKAT wrapper and kernel probe

Closes #1921, #1923.

Adds a typed wrapper around `IORING_OP_LINKAT` (Linux 5.15+) so the
receiver can submit hardlink creation alongside disk writes on the same
ring instead of issuing a synchronous `linkat(2)` syscall per hardlinked
file.

The new `linkat` submodule mirrors the conventions used by
`shared_ring::probe_poll_add` and `splice::is_splice_available`:

- `LINKAT_MIN_KERNEL = (5, 15)` and `IORING_OP_LINKAT = 39` constants.
- `linkat_supported()` short-circuits on `is_io_uring_available()`,
  builds a throwaway ring, and asks the kernel via
  `IORING_REGISTER_PROBE` whether opcode 39 is supported. The result is
  cached in a process-wide `OnceLock`.
- `LinkAtArgs<'a>` borrows source/destination `&CStr` paths plus dirfds
  and `flags` so the compiler enforces the kernel's path lifetime
  contract.
- `build_linkat_sqe` returns `io::ErrorKind::Unsupported` when the probe
  is `false`; `build_linkat_sqe_unchecked` exposes the encoder for unit
  tests.
- `submit_linkat_blocking` builds a private 2-entry ring, submits the
  SQE, and returns the kernel's CQE result.

The non-Linux stub in `io_uring_stub.rs` provides the same names with
`linkat_supported() -> false` and `Unsupported` round-trips. Public
re-exports in `crates/fast_io/src/lib.rs` and the Linux `io_uring`
module make the API available to consumer crates.

Tests:

- Unit tests verify `opcode::LinkAt::CODE == 39`, the cached probe is
  idempotent, the unchecked SQE encoder accepts user_data, and the stub
  consistently returns `Unsupported`.
- `tests/io_uring_linkat.rs` (Linux+`io_uring` feature) submits a real
  LINKAT, verifies the destination hardlink, and unlinks it; skips when
  the kernel does not advertise the opcode.

* fix(fast_io): use io::Error::other for clippy::io_other_error

* fix(fast_io): use c"..." CStr literals to satisfy clippy manual_c_str_literals
oferchen added a commit that referenced this pull request May 18, 2026
Wire the existing IORING_OP_RENAMEAT (task #1920) and IORING_OP_LINKAT
(task #1921) opcode wrappers into the temp-file commit and hardlink
finalization paths respectively.

On Linux 5.11+ with io_uring available, temp-file renames in
DestinationWriteGuard::commit_named_temp_file() now submit an
IORING_OP_RENAMEAT SQE instead of a synchronous rename(2) syscall.

On Linux 5.15+ with io_uring available, hardlink creation in
HardlinkApplyTracker, create_hard_link(), and the --link-dest path
now submit an IORING_OP_LINKAT SQE instead of a synchronous link(2).

Both paths fall back transparently to std::fs::rename / std::fs::hard_link
on non-Linux platforms, older kernels, or when io_uring is disabled.

Two new convenience functions in fast_io expose the try-or-fallback
pattern: try_rename_via_io_uring() and try_hard_link_via_io_uring(),
returning Option<io::Result<()>> so callers can fall through to the
portable implementation when None is returned.

Closes #1924, closes #1925.
oferchen added a commit that referenced this pull request Aug 24, 2026
Wire the existing IORING_OP_RENAMEAT (task #1920) and IORING_OP_LINKAT
(task #1921) opcode wrappers into the temp-file commit and hardlink
finalization paths respectively.

On Linux 5.11+ with io_uring available, temp-file renames in
DestinationWriteGuard::commit_named_temp_file() now submit an
IORING_OP_RENAMEAT SQE instead of a synchronous rename(2) syscall.

On Linux 5.15+ with io_uring available, hardlink creation in
HardlinkApplyTracker, create_hard_link(), and the --link-dest path
now submit an IORING_OP_LINKAT SQE instead of a synchronous link(2).

Both paths fall back transparently to std::fs::rename / std::fs::hard_link
on non-Linux platforms, older kernels, or when io_uring is disabled.

Two new convenience functions in fast_io expose the try-or-fallback
pattern: try_rename_via_io_uring() and try_hard_link_via_io_uring(),
returning Option<io::Result<()>> so callers can fall through to the
portable implementation when None is returned.

Closes #1924, closes #1925.
oferchen added a commit that referenced this pull request Aug 24, 2026
* feat(fast_io): add io_uring LINKAT wrapper and kernel probe

Closes #1921, #1923.

Adds a typed wrapper around `IORING_OP_LINKAT` (Linux 5.15+) so the
receiver can submit hardlink creation alongside disk writes on the same
ring instead of issuing a synchronous `linkat(2)` syscall per hardlinked
file.

The new `linkat` submodule mirrors the conventions used by
`shared_ring::probe_poll_add` and `splice::is_splice_available`:

- `LINKAT_MIN_KERNEL = (5, 15)` and `IORING_OP_LINKAT = 39` constants.
- `linkat_supported()` short-circuits on `is_io_uring_available()`,
  builds a throwaway ring, and asks the kernel via
  `IORING_REGISTER_PROBE` whether opcode 39 is supported. The result is
  cached in a process-wide `OnceLock`.
- `LinkAtArgs<'a>` borrows source/destination `&CStr` paths plus dirfds
  and `flags` so the compiler enforces the kernel's path lifetime
  contract.
- `build_linkat_sqe` returns `io::ErrorKind::Unsupported` when the probe
  is `false`; `build_linkat_sqe_unchecked` exposes the encoder for unit
  tests.
- `submit_linkat_blocking` builds a private 2-entry ring, submits the
  SQE, and returns the kernel's CQE result.

The non-Linux stub in `io_uring_stub.rs` provides the same names with
`linkat_supported() -> false` and `Unsupported` round-trips. Public
re-exports in `crates/fast_io/src/lib.rs` and the Linux `io_uring`
module make the API available to consumer crates.

Tests:

- Unit tests verify `opcode::LinkAt::CODE == 39`, the cached probe is
  idempotent, the unchecked SQE encoder accepts user_data, and the stub
  consistently returns `Unsupported`.
- `tests/io_uring_linkat.rs` (Linux+`io_uring` feature) submits a real
  LINKAT, verifies the destination hardlink, and unlinks it; skips when
  the kernel does not advertise the opcode.

* fix(fast_io): use io::Error::other for clippy::io_other_error

* fix(fast_io): use c"..." CStr literals to satisfy clippy manual_c_str_literals
oferchen added a commit that referenced this pull request Aug 24, 2026
Wire the existing IORING_OP_RENAMEAT (task #1920) and IORING_OP_LINKAT
(task #1921) opcode wrappers into the temp-file commit and hardlink
finalization paths respectively.

On Linux 5.11+ with io_uring available, temp-file renames in
DestinationWriteGuard::commit_named_temp_file() now submit an
IORING_OP_RENAMEAT SQE instead of a synchronous rename(2) syscall.

On Linux 5.15+ with io_uring available, hardlink creation in
HardlinkApplyTracker, create_hard_link(), and the --link-dest path
now submit an IORING_OP_LINKAT SQE instead of a synchronous link(2).

Both paths fall back transparently to std::fs::rename / std::fs::hard_link
on non-Linux platforms, older kernels, or when io_uring is disabled.

Two new convenience functions in fast_io expose the try-or-fallback
pattern: try_rename_via_io_uring() and try_hard_link_via_io_uring(),
returning Option<io::Result<()>> so callers can fall through to the
portable implementation when None is returned.

Closes #1924, closes #1925.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant