mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-29 16:37:07 +00:00
dda841d8de
refactor(ecstore): retire the set_disk lint blankets by making the prelude explicit
backlog#1823 step 1 / backlog#2029 road 2. Removes the last two module-level lint blankets in ecstore: set_disk/mod.rs #![allow(unused_imports)] and #![allow(unused_variables)], restoring both lints for the whole 40K-line subtree, and deletes the register line for the unused_variables blanket in the same diff (the guard from #6155 is a bidirectional exact match).
The unused_imports blanket existed because 14 submodules consumed mod.rs as a glob prelude (use super::* / use super::super::*), and rustc does not track consumption through glob re-exports. Each glob is now an explicit use super::{...} list, keeping mod.rs as the single import hub while making every import lint-checkable. Names consumed only by test or test-util units carry #[cfg(test)] / #[cfg(all(test, feature = "test-util"))] / #[cfg(any(test, feature = "test-util"))] gates matching their consumers; storage-api traits are routed through the storage_api_contracts facade per the architecture guard.
The sweep then deleted the genuinely dead imports the blanket was hiding (chrono::Utc, glob::Pattern, futures::task::AtomicWaker, rustfs_lock LocalLock, AsyncBatchProcessor, rand::Rng, std::future::Future among others in mod.rs, plus stale scoped imports and one empty test module shell across the subtree). One unused_variables finding surfaced: flush_read_version_coalescer_pending's lane_key is read only by the #[cfg(test)] counter block, handled with the cfg(not(test)) let _ pattern established in #6158.
Verification: cargo check zero warnings versus the 9cf276ed2 baseline on five lanes (default lib / --tests / rio-v2 --tests / test-util --tests / test-util,rio-v2 --tests; the --tests lane keeps the same three pre-existing core/pools.rs and store/object.rs dead-code warnings main already has); clippy --lib --tests -D warnings clean with test-util,rio-v2; cargo nextest run 4567 passed; make pre-commit exit 0.
129 lines
4.1 KiB
Rust
129 lines
4.1 KiB
Rust
// Copyright 2024 RustFS Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//! Borrow context for the `SetDisks` split (tracking #815, phase P0 #816).
|
|
//!
|
|
//! `SetDisks` stays the single owner of the shared set state — topology/config
|
|
//! (immutable after construction), `disks`, the locker trio, and the moka
|
|
//! caches. Operation-family service units introduced in later phases borrow
|
|
//! that state through [`SetDisksCtx`] instead of copying it, so no state is
|
|
//! duplicated as trait impls move out.
|
|
//!
|
|
//! This module only establishes the borrow handle. It moves no trait impl and
|
|
//! changes no runtime behavior.
|
|
|
|
use super::{Arc, DiskStore, Endpoint, FormatV3, LockClient, RwLock, SetDisks};
|
|
|
|
/// Lightweight, `Copy` handle borrowing the shared [`SetDisks`] core state.
|
|
///
|
|
/// Accessors return references tied to the borrowed core's lifetime, so an
|
|
/// operation-family unit can read topology, disks, and lockers without holding
|
|
/// its own copy. Anything not yet exposed through a typed accessor is reachable
|
|
/// via [`SetDisksCtx::core`].
|
|
#[derive(Clone, Copy)]
|
|
pub(crate) struct SetDisksCtx<'a> {
|
|
core: &'a SetDisks,
|
|
}
|
|
|
|
impl<'a> SetDisksCtx<'a> {
|
|
pub(crate) fn new(core: &'a SetDisks) -> Self {
|
|
Self { core }
|
|
}
|
|
|
|
/// The borrowed core, for state not yet fronted by a typed accessor.
|
|
#[allow(
|
|
dead_code,
|
|
reason = "SetDisks split seam (backlog#815) with no caller in this port (backlog#1823)"
|
|
)]
|
|
pub(crate) fn core(&self) -> &'a SetDisks {
|
|
self.core
|
|
}
|
|
|
|
// --- Immutable topology / config (fixed after construction) ---
|
|
|
|
#[allow(
|
|
dead_code,
|
|
reason = "SetDisks split seam (backlog#815) with no caller in this port (backlog#1823)"
|
|
)]
|
|
pub(crate) fn set_index(&self) -> usize {
|
|
self.core.set_index
|
|
}
|
|
|
|
pub(crate) fn pool_index(&self) -> usize {
|
|
self.core.pool_index
|
|
}
|
|
|
|
#[allow(
|
|
dead_code,
|
|
reason = "SetDisks split seam (backlog#815) with no caller in this port (backlog#1823)"
|
|
)]
|
|
pub(crate) fn set_drive_count(&self) -> usize {
|
|
self.core.set_drive_count
|
|
}
|
|
|
|
#[allow(
|
|
dead_code,
|
|
reason = "SetDisks split seam (backlog#815) with no caller in this port (backlog#1823)"
|
|
)]
|
|
pub(crate) fn default_parity_count(&self) -> usize {
|
|
self.core.default_parity_count
|
|
}
|
|
|
|
#[allow(
|
|
dead_code,
|
|
reason = "SetDisks split seam (backlog#815) with no caller in this port (backlog#1823)"
|
|
)]
|
|
pub(crate) fn set_endpoints(&self) -> &'a [Endpoint] {
|
|
&self.core.set_endpoints
|
|
}
|
|
|
|
pub(crate) fn format(&self) -> &'a FormatV3 {
|
|
&self.core.format
|
|
}
|
|
|
|
#[allow(
|
|
dead_code,
|
|
reason = "SetDisks split seam (backlog#815) with no caller in this port (backlog#1823)"
|
|
)]
|
|
pub(crate) fn locker_owner(&self) -> &'a str {
|
|
&self.core.locker_owner
|
|
}
|
|
|
|
// --- Shared mutable state (behind their own synchronization) ---
|
|
|
|
pub(crate) fn disks(&self) -> &'a Arc<RwLock<Vec<Option<DiskStore>>>> {
|
|
&self.core.disks
|
|
}
|
|
|
|
// --- Locker trio ---
|
|
|
|
#[allow(
|
|
dead_code,
|
|
reason = "SetDisks split seam (backlog#815) with no caller in this port (backlog#1823)"
|
|
)]
|
|
pub(crate) fn lockers(&self) -> &'a [Arc<dyn LockClient>] {
|
|
&self.core.lockers
|
|
}
|
|
}
|
|
|
|
impl SetDisks {
|
|
/// Borrow this set's shared core state through a lightweight handle.
|
|
///
|
|
/// Foundation for the operation-family split (#815 / #816): service units
|
|
/// take a [`SetDisksCtx`] rather than owning duplicated state.
|
|
pub(crate) fn ctx(&self) -> SetDisksCtx<'_> {
|
|
SetDisksCtx::new(self)
|
|
}
|
|
}
|