Skip to content

feat: typed SqpollUnavailable error on CAP_SYS_NICE missing (SQP-LAND.5) - #5558

Merged
oferchen merged 1 commit into
masterfrom
feat/sqp-land-5-typed-sqpoll-error
Jun 10, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/sqp-land-5-typed-sqpoll-error

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Per SQP-LAND.1 audit (PR docs: audit SQPOLL rootless-container detection landing status (SQP-LAND.1) #5548), IoUringConfig::build_ring() previously discarded the SQPOLL setup errno and set SQPOLL_FALLBACK without a log. Users debugging "why is my daemon slow?" could not tell that SQPOLL was disabled or why.
  • Add a typed IoUringRestriction::SqpollUnavailable { hint } variant plus a OnceLock-latched hint accessor so the cause survives the build path and is readable by --io-uring-status, daemon log, and structured callers.
  • Capture err.raw_os_error() when IORING_SETUP_SQPOLL is rejected and compose a hint distinguishing EPERM (rootless container / missing CAP_SYS_NICE), ENOSYS (kernel predates SQPOLL), and generic kernel rejection. The hint is emitted via debug_log!(Io, 1, ...).

This PR is independent of SQP-LAND.4 - it introduces the typed variant and log only. SQP-LAND.4 will wire detect_io_uring_restriction() to consume the latched hint.

Variant definition

/// `io_uring` itself is available, but `IORING_SETUP_SQPOLL` was rejected
/// by the kernel and the ring was rebuilt without the SQPOLL kthread.
SqpollUnavailable {
    /// Human-readable cause + remediation, suitable for log output.
    hint: String,
},

Log message (EPERM case)

io_uring SQPOLL setup failed with EPERM (missing CAP_SYS_NICE); add the capability, run as root, or set OC_RSYNC_DISABLE_IOURING=1 to bypass io_uring entirely

Test plan

  • Unit tests cover all four hint branches (EPERM / ENOSYS / generic errno / missing errno)
  • Unit test asserts SqpollUnavailable variant constructs and renders verbatim through Display
  • Unit test asserts the variant is distinct from IoUringRestriction::None
  • Unit test asserts sqpoll_unavailability_hint() is queryable without panic before any failure is observed
  • Non-Linux stub mirrors the API surface (sqpoll_fallback_hint, sqpoll_unavailability_hint) so cross-platform callers do not need conditional compilation
  • CI: fmt+clippy, nextest (stable), Windows, macOS, Linux musl

Per SQP-LAND.1 audit (PR #5548), `build_ring()` previously discarded
the SQPOLL setup errno and set `SQPOLL_FALLBACK` without a log, leaving
operators unable to tell whether a slow daemon was running with a
downgraded ring.

Add a typed `IoUringRestriction::SqpollUnavailable { hint }` variant and
capture the errno when `IORING_SETUP_SQPOLL` is rejected so the cause
can be distinguished:

- `EPERM`: rootless container or missing `CAP_SYS_NICE`
- `ENOSYS`: kernel predates `IORING_SETUP_SQPOLL`
- other: generic kernel rejection (errno surfaced numerically)

The hint is logged via `debug_log!(Io, 1, ...)` and latched in a
`OnceLock` so callers (`--io-uring-status`, daemon log, structured
error reporting) can read the same wording without parsing logs. A
stub for non-Linux platforms mirrors the API surface.

SQP-LAND.4 will wire `detect_io_uring_restriction()` to surface
`SqpollUnavailable` when the latched hint is present; this PR keeps
the detection function unchanged and only introduces the variant and
log so the wire-up can land independently.
@oferchen
oferchen merged commit 89bcb40 into master Jun 10, 2026
9 of 11 checks passed
@oferchen
oferchen deleted the feat/sqp-land-5-typed-sqpoll-error branch June 10, 2026 09:25
@github-actions github-actions Bot added the enhancement New feature or request label Jun 10, 2026
oferchen added a commit that referenced this pull request Aug 24, 2026
….5) (#5558)

Per SQP-LAND.1 audit (PR #5548), `build_ring()` previously discarded
the SQPOLL setup errno and set `SQPOLL_FALLBACK` without a log, leaving
operators unable to tell whether a slow daemon was running with a
downgraded ring.

Add a typed `IoUringRestriction::SqpollUnavailable { hint }` variant and
capture the errno when `IORING_SETUP_SQPOLL` is rejected so the cause
can be distinguished:

- `EPERM`: rootless container or missing `CAP_SYS_NICE`
- `ENOSYS`: kernel predates `IORING_SETUP_SQPOLL`
- other: generic kernel rejection (errno surfaced numerically)

The hint is logged via `debug_log!(Io, 1, ...)` and latched in a
`OnceLock` so callers (`--io-uring-status`, daemon log, structured
error reporting) can read the same wording without parsing logs. A
stub for non-Linux platforms mirrors the API surface.

SQP-LAND.4 will wire `detect_io_uring_restriction()` to surface
`SqpollUnavailable` when the latched hint is present; this PR keeps
the detection function unchanged and only introduces the variant and
log so the wire-up can land independently.
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