diff --git a/crates/ecstore/src/runtime/sources.rs b/crates/ecstore/src/runtime/sources.rs index ed64ac7fe..0e0c2d20c 100644 --- a/crates/ecstore/src/runtime/sources.rs +++ b/crates/ecstore/src/runtime/sources.rs @@ -50,7 +50,7 @@ use rustfs_kms::{ObjectEncryptionService, get_global_encryption_service}; use rustfs_lock::client::LockClient; use s3s::dto::BucketLifecycleConfiguration; use s3s::region::Region; -use tokio::sync::{RwLock, RwLockReadGuard}; +use tokio::sync::{OwnedRwLockReadGuard, RwLock}; use tokio_util::sync::CancellationToken; use tonic::transport::Channel; use uuid::Uuid; @@ -362,8 +362,16 @@ pub fn bucket_monitor() -> Option> { get_global_bucket_monitor() } -pub async fn local_disk_map_read() -> RwLockReadGuard<'static, HashMap>> { - GLOBAL_LOCAL_DISK_MAP.read().await +/// Acquire a read guard over the local disk map as an **owned** guard. +/// +/// Returns an [`OwnedRwLockReadGuard`] (holding an `Arc` clone of the lock) +/// rather than a `'static` borrow of the process global. This decouples callers +/// (notably the heal crate, which holds the guard across `.await`) from the +/// global's `'static` lifetime, so the map can later move into the per-instance +/// `InstanceContext` (Phase 5 disk-registry migration, backlog#939) without a +/// cross-crate signature change. Single-instance behavior is unchanged. +pub async fn local_disk_map_read() -> OwnedRwLockReadGuard>> { + GLOBAL_LOCAL_DISK_MAP.clone().read_owned().await } pub(crate) fn init_bucket_monitor_for_current_endpoints() { diff --git a/crates/heal/src/heal/mod.rs b/crates/heal/src/heal/mod.rs index 39c3d2f3f..7fc50323a 100644 --- a/crates/heal/src/heal/mod.rs +++ b/crates/heal/src/heal/mod.rs @@ -137,7 +137,13 @@ pub(crate) type Endpoint = EcstoreEndpoint; pub(crate) type StorageError = EcstoreStorageError; pub(crate) type LocalDiskMap = std::collections::HashMap>; -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 { ecstore_local_disk_map_read().await }