rustfs_uring/lib.rs
1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Cancel-safe async io_uring read backend for RustFS
16//! (rustfs/backlog#894, hardened per the #1048/#1051 audit).
17//!
18//! This crate proves and enforces the ownership model any production io_uring
19//! integration in RustFS must follow:
20//!
21//! - The read buffer and the file handle are owned by the driver's pending
22//! (orphan) table from SQE submission until the CQE arrives. The kernel may
23//! write into the buffer at any point in that window, so nothing else is
24//! allowed to free or move its heap allocation.
25//! - Dropping the caller-side future only abandons the *result*. It never
26//! touches the buffer. Optionally it submits `IORING_OP_ASYNC_CANCEL` to
27//! accelerate the CQE; reclamation still happens only at the CQE.
28//! - Driver shutdown cancels all in-flight ops and drains the ring to
29//! `in_flight == 0` (with a bounded escape hatch) before the ring is
30//! unmapped.
31//!
32//! Status: read path only, Linux only. The driver supports positioned buffered
33//! reads, `O_DIRECT` reads with internal alignment, sharded rings, async
34//! backpressure, eventfd-driven reaping, graceful restricted-environment
35//! detection, and bounded shutdown drain. The write path is intentionally out
36//! of scope for `0.1.0`; see the
37//! [design notes](https://github.com/rustfs/uring/blob/v0.1.0/docs/DESIGN.md)
38//! for the invariant details.
39
40#[cfg(target_os = "linux")]
41mod driver;
42
43#[cfg(target_os = "linux")]
44pub use driver::{ProbeFailure, StatsSnapshot, UringDriver};