refactor(storage): route maintenance inventory reads (#3337)

This commit is contained in:
安正超
2026-06-11 10:32:48 +08:00
committed by GitHub
parent f325b9f714
commit 87968275a7
7 changed files with 69 additions and 51 deletions
Generated
+2
View File
@@ -9405,6 +9405,7 @@ dependencies = [
"rustfs-config", "rustfs-config",
"rustfs-ecstore", "rustfs-ecstore",
"rustfs-madmin", "rustfs-madmin",
"rustfs-storage-api",
"rustfs-utils", "rustfs-utils",
"serde", "serde",
"serde_json", "serde_json",
@@ -9951,6 +9952,7 @@ dependencies = [
"rustfs-data-usage", "rustfs-data-usage",
"rustfs-ecstore", "rustfs-ecstore",
"rustfs-filemeta", "rustfs-filemeta",
"rustfs-storage-api",
"rustfs-utils", "rustfs-utils",
"s3s", "s3s",
"serde", "serde",
+2 -1
View File
@@ -28,6 +28,7 @@ use crate::store_api::{GetObjectReader, HTTPRangeSpec, ObjectIO, ObjectInfo, Obj
use http::HeaderMap; use http::HeaderMap;
use rand::RngExt as _; use rand::RngExt as _;
use rustfs_filemeta::{FileInfo, MetaCacheEntries, MetaCacheEntry, MetadataResolutionParams}; use rustfs_filemeta::{FileInfo, MetaCacheEntries, MetaCacheEntry, MetadataResolutionParams};
use rustfs_storage_api::StorageAdminApi;
use rustfs_utils::path::encode_dir_object; use rustfs_utils::path::encode_dir_object;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashSet; use std::collections::HashSet;
@@ -732,7 +733,7 @@ impl ECStore {
#[tracing::instrument(skip(self))] #[tracing::instrument(skip(self))]
pub async fn init_rebalance_meta(&self, bucktes: Vec<String>) -> Result<String> { pub async fn init_rebalance_meta(&self, bucktes: Vec<String>) -> Result<String> {
info!("init_rebalance_meta: start rebalance"); info!("init_rebalance_meta: start rebalance");
let si = self.storage_info().await; let si = StorageAdminApi::storage_info(self).await;
let mut disk_stats = vec![DiskStat::default(); self.pools.len()]; let mut disk_stats = vec![DiskStat::default(); self.pools.len()];
+1
View File
@@ -29,6 +29,7 @@ categories = ["web-programming", "development-tools", "filesystem"]
[dependencies] [dependencies]
rustfs-config = { workspace = true } rustfs-config = { workspace = true }
rustfs-ecstore = { workspace = true } rustfs-ecstore = { workspace = true }
rustfs-storage-api = { workspace = true }
rustfs-common = { workspace = true } rustfs-common = { workspace = true }
rustfs-madmin = { workspace = true } rustfs-madmin = { workspace = true }
rustfs-utils = { workspace = true } rustfs-utils = { workspace = true }
+3 -6
View File
@@ -19,11 +19,10 @@ use rustfs_ecstore::{
disk::{DiskStore, endpoint::Endpoint}, disk::{DiskStore, endpoint::Endpoint},
error::StorageError, error::StorageError,
store::ECStore, store::ECStore,
store_api::{ store_api::{BucketInfo, BucketOperations, HealOperations, ListOperations, ObjectIO, ObjectOperations, ObjectOptions},
BucketInfo, BucketOperations, HealOperations, ListOperations, ObjectIO, ObjectOperations, ObjectOptions, StorageAPI,
},
}; };
use rustfs_madmin::heal_commands::HealResultItem; use rustfs_madmin::heal_commands::HealResultItem;
use rustfs_storage_api::{DiskSetSelector, StorageAdminApi};
use std::sync::Arc; use std::sync::Arc;
use tracing::{debug, error, info, warn}; use tracing::{debug, error, info, warn};
@@ -619,9 +618,7 @@ impl HealStorageAPI for ECStoreHealStorage {
let (pool_idx, set_idx) = crate::heal::utils::parse_set_disk_id(set_disk_id)?; let (pool_idx, set_idx) = crate::heal::utils::parse_set_disk_id(set_disk_id)?;
// Get the first available disk from the set // Get the first available disk from the set
let disks = self let disks = StorageAdminApi::disk_set_inventory(self.ecstore.as_ref(), DiskSetSelector::new(pool_idx, set_idx))
.ecstore
.get_disks(pool_idx, set_idx)
.await .await
.map_err(|e| Error::TaskExecutionFailed { .map_err(|e| Error::TaskExecutionFailed {
message: format!("Failed to get disks for pool {pool_idx} set {set_idx}: {e}"), message: format!("Failed to get disks for pool {pool_idx} set {set_idx}: {e}"),
+1
View File
@@ -46,6 +46,7 @@ rmp-serde = { workspace = true }
rustfs-filemeta = { workspace = true } rustfs-filemeta = { workspace = true }
tokio-util = { workspace = true } tokio-util = { workspace = true }
rustfs-ecstore = { workspace = true } rustfs-ecstore = { workspace = true }
rustfs-storage-api = { workspace = true }
http = { workspace = true } http = { workspace = true }
rand = { workspace = true } rand = { workspace = true }
s3s = { workspace = true } s3s = { workspace = true }
+2 -1
View File
@@ -44,6 +44,7 @@ use rustfs_ecstore::set_disk::SetDisks;
use rustfs_ecstore::store_api::{BucketInfo, BucketOperations, BucketOptions, ObjectInfo}; use rustfs_ecstore::store_api::{BucketInfo, BucketOperations, BucketOptions, ObjectInfo};
use rustfs_ecstore::{StorageAPI, error::Result, store::ECStore}; use rustfs_ecstore::{StorageAPI, error::Result, store::ECStore};
use rustfs_filemeta::FileMeta; use rustfs_filemeta::FileMeta;
use rustfs_storage_api::{DiskSetSelector, StorageAdminApi};
use rustfs_utils::path::path_join_buf; use rustfs_utils::path::path_join_buf;
use s3s::dto::{BucketLifecycleConfiguration, ReplicationConfiguration}; use s3s::dto::{BucketLifecycleConfiguration, ReplicationConfiguration};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
@@ -1082,7 +1083,7 @@ impl ScannerIODisk for Disk {
return Err(StorageError::other("Disk location not available".to_string())); return Err(StorageError::other("Disk location not available".to_string()));
}; };
let disks_result = ecstore.get_disks(pool_idx, set_idx).await?; let disks_result = StorageAdminApi::disk_set_inventory(ecstore.as_ref(), DiskSetSelector::new(pool_idx, set_idx)).await?;
let Some(disk_idx) = disk_location.disk_idx else { let Some(disk_idx) = disk_location.disk_idx else {
error!("Disk index not available"); error!("Disk index not available");
+58 -43
View File
@@ -5,17 +5,16 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
## Current Context ## Current Context
- Issue: [`rustfs/backlog#660`](https://github.com/rustfs/backlog/issues/660) - Issue: [`rustfs/backlog#660`](https://github.com/rustfs/backlog/issues/660)
- Branch: `overtrue/arch-storage-admin-read-cleanup` - Branch: `overtrue/arch-storage-admin-remaining-readers`
- Baseline: `origin/main` at `94c53af264b8d011b19b0b35eed5990a21592d70` - Baseline: `origin/main` at `f325b9f71ce4807488829e6f558383242bbcb6a2`
- PR type for this branch: `consumer-migration` - PR type for this branch: `consumer-migration`
- Runtime behavior changes: none. - Runtime behavior changes: none.
- Rust code changes: route ECStore internal admin-read aggregation through - Rust code changes: route maintenance/background read-side storage inventory
crate-internal `Sets`/`SetDisks` snapshot helpers and the inventory-facing consumers through the inventory-facing `StorageAdminApi` contract while
`StorageAdminApi` contract while preserving the old `StorageAPI` compatibility preserving the old `StorageAPI` compatibility surface.
surface.
- CI/script changes: none. - CI/script changes: none.
- Docs changes: record API-007 internal admin-read cleanup context, verification - Docs changes: record API-007 maintenance/background inventory-reader context,
evidence, and expert review outcomes. verification evidence, and expert review outcomes.
## Phase 0 Tasks ## Phase 0 Tasks
@@ -208,24 +207,38 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
- Completed fifth slice: `rustfs/rustfs#3335` migrated grouped observability, - Completed fifth slice: `rustfs/rustfs#3335` migrated grouped observability,
RPC health, server-info, realtime metrics, and notification read-side RPC health, server-info, realtime metrics, and notification read-side
consumers. consumers.
- Current branch slice: add crate-internal admin snapshot helpers for - Completed sixth slice: `rustfs/rustfs#3336` migrated ECStore internal
`Sets`/`SetDisks`, then migrate ECStore internal decommission space, decommission space, local-storage-info, backend-info, drive-count, and
local-storage-info, backend-info, drive-count, and disk-inventory admin disk-inventory admin handlers away from old `StorageAPI` method calls.
handlers away from old `StorageAPI` method calls. - Current branch slice: migrate maintenance/background read-side storage
- Acceptance: ECStore internal admin-read aggregation no longer relies on old inventory consumers in rebalance metadata initialization, heal resume disk
`StorageAPI` method calls where crate-internal helpers or lookup, and scanner local disk scan lookup.
`StorageAdminApi` already represent the same read-only contract. - Acceptance: these maintenance/background consumers no longer use old
`StorageAPI` calls for storage-info or disk-set inventory when the
inventory-facing `StorageAdminApi` contract already represents the same
read-only operation.
- Must preserve: old `StorageAPI` trait shape, `StorageAPI::get_disks` - Must preserve: old `StorageAPI` trait shape, `StorageAPI::get_disks`
behavior, storage-info disk aggregation, local-only disk filtering, behavior, rebalance metadata serialization/save/load, heal resume disk
decommission pool space calculation, storage-info deduplication, backend selection, scanner local disk selection, object/rebalance object selection
info construction, object/rebalance selection paths, scanner/heal paths, scanner data-cache persistence, heal object repair, object paths,
consumers, object paths, replication/config persistence, and storage hot replication/config/tier persistence, and storage hot paths.
paths. - Risk defense: change only trait call entry points to existing ECStore
- Risk defense: keep the old trait implementation as a delegating `StorageAdminApi` handlers; do not migrate object APIs, config or
compatibility surface, avoid implementing the full admin contract for replication persistence, scanner cache writes, heal object repair, or
partial internal types, and do not migrate object APIs, scanner, heal, storage implementation hot paths in this PR.
replication, config persistence, or storage implementation hot paths in - Verification:
this PR. - `cargo fmt --all && cargo fmt --all --check`.
- `cargo check -p rustfs-ecstore -p rustfs-heal -p rustfs-scanner`.
- `cargo test -p rustfs-ecstore rebalance --lib`.
- `cargo test -p rustfs-heal storage --lib`.
- `cargo test -p rustfs-scanner scanner_io --lib`.
- `./scripts/check_architecture_migration_rules.sh`.
- `./scripts/check_layer_dependencies.sh`.
- `./scripts/check_metrics_migration_refs.sh`.
- `./scripts/check_unsafe_code_allowances.sh`.
- `git diff --check`.
- Pre-push review: pending required quality/architecture,
migration-preservation, and testing/verification review.
## Phase 8 Background Controller Tasks ## Phase 8 Background Controller Tasks
@@ -269,19 +282,18 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
| Expert | Status | Notes | | Expert | Status | Notes |
|---|---|---| |---|---|---|
| Quality/architecture | pass | Confirmed the diff stays limited to ECStore internal admin-read cleanup plus migration notes; helper visibility and naming are scoped, and the Handoff Notes correctly exclude object/hot-path `get_disks` consumers. | | Quality/architecture | pass | Confirmed the diff is limited to maintenance/background inventory-reader entry-point migration plus accurate progress notes; dependency direction, naming, and scope are clean. |
| Migration preservation | pass | Confirmed old `StorageAPI` shape remains, `Sets`/`SetDisks` helpers preserve previous aggregation/filtering/get-disks logic, and decommission/local-info/admin inventory call sites only change entry point. | | Migration preservation | pass | Confirmed old `StorageAPI` shape remains, ECStore old/new trait paths still delegate to the same storage-info and disk-inventory handlers, and rebalance/heal/scanner call sites only change the read-side entry point. |
| Testing/verification | pass | Confirmed focused ECStore checks, migration guards, diff hygiene, and added-line Rust quality scan are sufficient for this equivalent internal call-path cleanup while skipping full pre-commit under the current instruction. | | Testing/verification | pass | Confirmed the focused ECStore/heal/scanner checks, migration guards, diff hygiene, and added-line Rust quality scan are sufficient for this equivalent read-side call-path migration while skipping full pre-commit under the current instruction. |
## Verification Notes ## Verification Notes
Passed: Passed:
- `cargo fmt --all`. - `cargo fmt --all && cargo fmt --all --check`.
- `cargo fmt --all --check`. - `cargo check -p rustfs-ecstore -p rustfs-heal -p rustfs-scanner`.
- `cargo check -p rustfs-ecstore`. - `cargo test -p rustfs-ecstore rebalance --lib`; 198 passed.
- `cargo test -p rustfs-ecstore store::rebalance --lib`; 19 passed. - `cargo test -p rustfs-heal storage --lib`; 3 passed.
- `cargo test -p rustfs-ecstore pools --lib`; 141 passed. - `cargo test -p rustfs-scanner scanner_io --lib`; 18 passed.
- `cargo test -p rustfs-ecstore set_disk --lib`; 86 passed.
- `./scripts/check_architecture_migration_rules.sh`. - `./scripts/check_architecture_migration_rules.sh`.
- `./scripts/check_layer_dependencies.sh`. - `./scripts/check_layer_dependencies.sh`.
- `./scripts/check_metrics_migration_refs.sh`. - `./scripts/check_metrics_migration_refs.sh`.
@@ -297,21 +309,24 @@ Notes:
- The broad changed-file quality scan reports pre-existing test unwrap/expect - The broad changed-file quality scan reports pre-existing test unwrap/expect
plus pre-existing casts and relaxed atomics in touched ECStore files; the plus pre-existing casts and relaxed atomics in touched ECStore files; the
added-line scan found no new risky code patterns. added-line scan found no new risky code patterns.
- Old `StorageAPI` trait shape and implementations remain in place; `Sets` and - Old `StorageAPI` trait shape and implementations remain in place; ECStore old
`SetDisks` delegate the admin-read subset to crate-internal helpers. and new trait paths delegate to the same storage-info and disk-inventory
- Object/rebalance selection paths, scanner/heal consumers, object APIs, handlers.
replication/config persistence paths, and storage hot paths are unchanged. - Object/rebalance object selection paths, scanner cache persistence, heal
object repair, object APIs, replication/config/tier persistence paths, and
storage hot paths are unchanged.
- No temporary compatibility shim was added. - No temporary compatibility shim was added.
## Handoff Notes ## Handoff Notes
- Keep this API-007 slice as an ECStore-internal admin-read cleanup - Keep this API-007 slice as a maintenance/background inventory-reader
`consumer-migration` PR. `consumer-migration` PR.
- Do not migrate object APIs, scanner, heal, replication, config persistence, or - The only scanner/heal scope in this PR is read-side disk lookup for scanner
storage hot-path consumers in this PR. local disk scan and heal resume; do not migrate scanner cache writes, heal
object repair, object APIs, replication, config/tier persistence, or storage
hot-path consumers in this PR.
- Do not remove `StorageAPI::get_disks` or route object/hot-path consumers - Do not remove `StorageAPI::get_disks` or route object/hot-path consumers
around it in this PR; only the ECStore internal admin disk-inventory handler around it in this PR.
is in scope.
- Do not make the old `StorageAPI` trait inherit `StorageAdminApi` in this PR. - Do not make the old `StorageAPI` trait inherit `StorageAdminApi` in this PR.
- Do not add temporary compatibility code unless a matching - Do not add temporary compatibility code unless a matching
`RUSTFS_COMPAT_TODO(<task-id>)` marker and cleanup-register entry are added. `RUSTFS_COMPAT_TODO(<task-id>)` marker and cleanup-register entry are added.