#1301

fix(storage): reject invalid device and engine configs

Openmjcwants to merge intofrom

Move default-capacity discovery and storage-engine validation out of panic paths and into fallible, type-driven APIs.

What changed:

  • FileDeviceBuilder now probes block-device capacity or parent-directory free space through fallible helpers instead of unwrap/expect.
  • FsDeviceBuilder now computes default capacity lazily and returns Error if filesystem probing fails.
  • BlockEngineConfig and UringIoEngineConfig now use NonZeroUsize for counts and depths, so zero values are rejected at compile time for normal callers.
  • CPU pinning now uses nonempty CPU sets to set thread count, leaves pinning off when the CPU set is empty, and rejects mismatched with_cpus(...) / with_threads(...) combinations up front.

Tests added:

  • test_file_device_builder_rejects_path_without_parent
  • test_fs_device_builder_propagates_dir_creation_errors
  • test_uring_empty_cpu_sets_disable_pinning
  • test_uring_rejects_mismatched_cpu_count

Activity

5
mjc4mo ago

Tightened the io_uring CPU affinity path a bit more: a nonempty CPU list still sets the thread count, but we now reject mismatched with_cpus(...) / with_threads(...) combinations up front instead of letting them reach an index panic in build(). Added tests for both the mismatch and the empty-list “disable pinning” case.

codecov[bot]4mo ago

Codecov Report

:x: Patch coverage is 87.58621% with 18 lines in your changes missing coverage. Please review.

Files with missing linesCoverage Δ
foyer-bench/src/main.rs70.02% <50.00%> (+0.22%):arrow_up:
foyer-storage/src/engine/block/engine.rs93.46% <96.66%> (-0.08%):arrow_down:
foyer-storage/src/io/device/fs.rs92.30% <88.88%> (+0.47%):arrow_up:
foyer-storage/src/io/engine/mod.rs94.66% <85.71%> (-1.05%):arrow_down:
foyer-storage/src/store.rs86.33% <83.33%> (-0.10%):arrow_down:
foyer-storage/src/io/device/file.rs70.17% <77.27%> (+7.31%):arrow_up:
foyer-storage/src/io/engine/uring.rs87.81% <88.40%> (+0.85%):arrow_up:

... and 2 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
mjc4mo ago

I'll be back at this in a couple days to add more tests if y'all need, I try not to leave drive-by PRs. just ran out of time.

--

我过几天会再回来继续补测试,如果你们需要的话。我尽量不留那种丢完就跑的 PR,只是这次实在没时间了。