mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-12 08:06:54 +00:00
refactor(scanner): narrow cache storage bounds (#3348)
This commit is contained in:
@@ -29,12 +29,11 @@ pub use rustfs_data_usage::{
|
||||
BucketTargetUsageInfo, BucketUsageInfo, DataUsageEntry, DataUsageHash, DataUsageHashMap, DataUsageInfo, hash_path,
|
||||
};
|
||||
use rustfs_ecstore::{
|
||||
StorageAPI,
|
||||
bucket::{lifecycle::lifecycle::TRANSITION_COMPLETE, replication::ReplicationConfig},
|
||||
config::{com::save_config, storageclass},
|
||||
disk::{BUCKET_META_PREFIX, RUSTFS_META_BUCKET},
|
||||
error::{Error, Result as StorageResult, StorageError},
|
||||
store_api::{ObjectInfo, ObjectOptions},
|
||||
store_api::{ObjectIO, ObjectInfo, ObjectOptions},
|
||||
};
|
||||
use rustfs_utils::path::{SLASH_SEPARATOR, path_join_buf};
|
||||
use tokio::time::{Duration, Instant, sleep, timeout};
|
||||
@@ -613,7 +612,7 @@ impl DataUsageCache {
|
||||
/// Only backend errors are returned as errors.
|
||||
/// The loader is optimistic and has no locking, but tries 5 times before giving up.
|
||||
/// If the object is not found, a nil error with empty data usage cache is returned.
|
||||
pub async fn load<S: StorageAPI>(&mut self, store: Arc<S>, name: &str) -> StorageResult<()> {
|
||||
pub async fn load<S: ObjectIO>(&mut self, store: Arc<S>, name: &str) -> StorageResult<()> {
|
||||
// By default, empty data usage cache
|
||||
*self = DataUsageCache::default();
|
||||
|
||||
@@ -659,7 +658,7 @@ impl DataUsageCache {
|
||||
}
|
||||
// Inner load function that attempts to load from a specific path
|
||||
// Returns (should_retry, cache_option, error_option)
|
||||
async fn try_load_inner<S: StorageAPI>(
|
||||
async fn try_load_inner<S: ObjectIO>(
|
||||
store: Arc<S>,
|
||||
load_name: &str,
|
||||
timeout_duration: Duration,
|
||||
@@ -854,7 +853,7 @@ impl DataUsageCache {
|
||||
Err(last_err.unwrap_or_else(|| StorageError::other("Failed to save data usage cache".to_string())))
|
||||
}
|
||||
|
||||
async fn save_path_with_retry<S: StorageAPI>(
|
||||
async fn save_path_with_retry<S: ObjectIO>(
|
||||
store: Arc<S>,
|
||||
path: &str,
|
||||
buf: &[u8],
|
||||
@@ -877,7 +876,7 @@ impl DataUsageCache {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn save<S: StorageAPI>(&self, store: Arc<S>, name: &str) -> StorageResult<()> {
|
||||
pub async fn save<S: ObjectIO>(&self, store: Arc<S>, name: &str) -> StorageResult<()> {
|
||||
let mut buf = Vec::new();
|
||||
self.serialize(&mut rmp_serde::Serializer::new(&mut buf))?;
|
||||
let timeout_duration = Self::cache_save_timeout();
|
||||
|
||||
@@ -41,8 +41,8 @@ use rustfs_ecstore::error::{Error, StorageError};
|
||||
use rustfs_ecstore::global::GLOBAL_TierConfigMgr;
|
||||
use rustfs_ecstore::new_object_layer_fn;
|
||||
use rustfs_ecstore::set_disk::SetDisks;
|
||||
use rustfs_ecstore::store_api::{BucketInfo, BucketOperations, BucketOptions, ObjectInfo};
|
||||
use rustfs_ecstore::{StorageAPI, error::Result, store::ECStore};
|
||||
use rustfs_ecstore::store_api::{BucketInfo, BucketOperations, BucketOptions, ObjectIO, ObjectInfo};
|
||||
use rustfs_ecstore::{error::Result, store::ECStore};
|
||||
use rustfs_filemeta::FileMeta;
|
||||
use rustfs_storage_api::{DiskSetSelector, StorageAdminApi};
|
||||
use rustfs_utils::path::path_join_buf;
|
||||
@@ -296,7 +296,7 @@ async fn send_cache_root_entry_info(
|
||||
bucket_result_tx.lock().await.send(cache_root_entry_info(cache)).await
|
||||
}
|
||||
|
||||
async fn persist_and_publish_cache_snapshot<S: StorageAPI>(
|
||||
async fn persist_and_publish_cache_snapshot<S: ObjectIO>(
|
||||
store: Arc<S>,
|
||||
updates: &mpsc::Sender<DataUsageCache>,
|
||||
cache_snapshot: DataUsageCache,
|
||||
|
||||
Reference in New Issue
Block a user