feat(ecstore): LocalIoBackend trait and O_DIRECT read with fallback (#4365)

* refactor(ecstore): extract LocalIoBackend trait behind LocalDisk

Model the LocalDisk per-file I/O hot path as a LocalIoBackend trait
(pread_bytes / open_read_stream / open_full_read / open_write) and move
the existing method bodies verbatim into a default StdBackend. LocalDisk
holds Arc<dyn LocalIoBackend> and the DiskAPI methods forward to it.

This is a behavior-preserving refactor: no logic, error-mapping, metrics,
or cfg-branch changes. It creates the seam for an alternative
runtime-probed io_uring backend (rustfs/backlog#894) without touching
DiskAPI callers. Commit-point durability (fdatasync -> rename ->
fsync-dir in rename_data) deliberately stays outside the trait.

Add a differential test asserting all four read shapes return identical
bytes across page-boundary and file-tail ranges.

Tracking: rustfs/backlog#891 (parent rustfs/backlog#897)

Co-Authored-By: heihutu <heihutu@gmail.com>

* feat(ecstore): true O_DIRECT read path with per-disk graceful fallback (#4366)

* feat(ecstore): true O_DIRECT read path with per-disk graceful fallback

Implement a real O_DIRECT positioned read inside StdBackend::pread_bytes
(Linux only) and wire up the previously dead RUSTFS_OBJECT_DIRECT_IO_READ_*
knobs, which had zero call sites.

Open with rustix OFlags::DIRECT, probe the DIO alignment once per disk via
statx STATX_DIOALIGN (4096 fallback), read the aligned superset into an
alignment-allocated bounce buffer with a short-read loop, and slice out the
exact logical range so padding never reaches BitrotReader.

Any O_DIRECT failure falls back to the buffered read methods; EINVAL or
EOPNOTSUPP (tmpfs, overlayfs, 9p) latches the path off per disk with one
warning. O_DIRECT errors never surface: EINVAL maps to FileNotFound in
to_file_error and would trigger spurious EC rebuilds.

Default behavior is unchanged (knob off). macOS keeps F_NOCACHE.

Tracking: rustfs/backlog#892 (parent rustfs/backlog#897)

Co-Authored-By: heihutu <heihutu@gmail.com>

* test(ecstore): add P1.5 benchmark gate harness for O_DIRECT reads (#4369)

* test(ecstore): add P1.5 benchmark gate harness for O_DIRECT reads

Add an ignored, Linux-only release-mode test (direct_read_bench_gate)
that measures DiskAPI::read_file_mmap_copy through a real LocalDisk with
cold-cache enforcement (fadvise DONTNEED between rounds), reporting
p50/p95/p99/mean latency, wall time, process CPU time, and throughput as
one JSON line for A/B diffing between the buffered baseline and the
O_DIRECT candidate selected by the production env knobs.

Content is verified byte-for-byte before any timing starts.

Tracking: rustfs/backlog#893 (parent rustfs/backlog#897)

Co-Authored-By: heihutu <heihutu@gmail.com>

* test(ecstore): add concurrency dimension to P1.5 bench harness

Model the EC GET shape (FuturesUnordered over concurrent shard reads)
via RUSTFS_BENCH_CONCURRENCY (default 1, sequential as before). Needed
to evaluate blocking-pool pressure for the io_uring gate decision.

Tracking: rustfs/backlog#893

Co-Authored-By: heihutu <heihutu@gmail.com>

---------

Co-authored-by: heihutu <heihutu@gmail.com>

---------

Co-authored-by: heihutu <heihutu@gmail.com>

* ci: retrigger after cancelled required check

Co-Authored-By: heihutu <heihutu@gmail.com>

* fix(ecstore): use is_multiple_of in O_DIRECT bench cache-drop check

clippy's manual_is_multiple_of (rust 1.96) fails -D warnings on the benchmark helper's `done % file_count == 0`.

Verification:
- cargo clippy -p rustfs-ecstore --all-targets

Co-Authored-By: heihutu <heihutu@gmail.com>

---------

Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
houseme
2026-07-07 23:01:54 +08:00
committed by GitHub
parent 8f4349793e
commit 5533e080b0
File diff suppressed because it is too large Load Diff