mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 23:47:28 +00:00
refactor(ecstore,heal): return the local disk map as an owned read guard (Phase 5 disk-registry prep) (#4501)
refactor(ecstore,heal): return the local disk map as an owned read guard (Phase 5 prep) Prerequisite for the Phase 5 disk-registry migration (backlog#939): the disk map cannot move from the process global into the per-instance InstanceContext while callers depend on a `'static` read guard borrowed from the global. Change `local_disk_map_read` to return an owned guard (`OwnedRwLockReadGuard`) via `Arc::read_owned` instead of `RwLockReadGuard<'static, _>`: - ecstore `runtime::sources::local_disk_map_read` now returns `OwnedRwLockReadGuard<..>` (holds an Arc clone of the lock), not a `'static` borrow of `GLOBAL_LOCAL_DISK_MAP`. - heal's forwarding accessor and its callers (which hold the guard across `.await` while clearing/writing per-disk markers) keep identical behavior — the owned guard derefs to the same map, so iteration is unchanged. This decouples the heal crate from the global's `'static` lifetime so a later PR can source the map from the current instance's context. Single-instance behavior is byte-for-byte unchanged; the same read lock is held across the same awaits. Verification: cargo test -p rustfs-heal (201 tests green), cargo clippy -p rustfs-ecstore -p rustfs-heal --all-targets (clean), make pre-commit (pass). Refs: backlog#939 (Phase 5, disk-registry prerequisite)
This commit is contained in:
@@ -137,7 +137,13 @@ pub(crate) type Endpoint = EcstoreEndpoint;
|
||||
pub(crate) type StorageError = EcstoreStorageError;
|
||||
pub(crate) type LocalDiskMap = std::collections::HashMap<String, Option<DiskStore>>;
|
||||
|
||||
pub(crate) async fn local_disk_map_read() -> tokio::sync::RwLockReadGuard<'static, LocalDiskMap> {
|
||||
/// Read the local disk map as an owned guard.
|
||||
///
|
||||
/// Returns an owned guard (see the ecstore boundary), so the heal manager can
|
||||
/// hold it across `.await` without depending on a `'static` process global —
|
||||
/// the prerequisite for moving the disk map into the per-instance
|
||||
/// `InstanceContext` (backlog#939). Usage is otherwise unchanged.
|
||||
pub(crate) async fn local_disk_map_read() -> tokio::sync::OwnedRwLockReadGuard<LocalDiskMap> {
|
||||
ecstore_local_disk_map_read().await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user