This commit is contained in:
weisd
2025-01-21 17:49:55 +08:00
parent 9535a9a7ad
commit 05af5d7ddf
4 changed files with 36 additions and 28 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ use crate::disk::{BUCKET_META_PREFIX, RUSTFS_META_BUCKET};
use crate::error::{Error, Result}; use crate::error::{Error, Result};
use crate::new_object_layer_fn; use crate::new_object_layer_fn;
use crate::set_disk::SetDisks; use crate::set_disk::SetDisks;
use crate::store_api::{BucketInfo, HTTPRangeSpec, ObjectIO, ObjectOptions}; use crate::store_api::{BucketInfo, ObjectIO, ObjectOptions};
use bytesize::ByteSize; use bytesize::ByteSize;
use http::HeaderMap; use http::HeaderMap;
use path_clean::PathClean; use path_clean::PathClean;
+28 -24
View File
@@ -2,7 +2,7 @@ use crate::disk::{BUCKET_META_PREFIX, RUSTFS_META_BUCKET};
use crate::heal::background_heal_ops::{heal_bucket, heal_object}; use crate::heal::background_heal_ops::{heal_bucket, heal_object};
use crate::heal::heal_commands::{HEAL_DEEP_SCAN, HEAL_NORMAL_SCAN}; use crate::heal::heal_commands::{HEAL_DEEP_SCAN, HEAL_NORMAL_SCAN};
use crate::utils::path::SLASH_SEPARATOR; use crate::utils::path::SLASH_SEPARATOR;
use chrono::{DateTime, TimeDelta, Utc}; use chrono::{DateTime, Utc};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use std::ops::Sub; use std::ops::Sub;
@@ -15,7 +15,7 @@ use tracing::error;
use uuid::Uuid; use uuid::Uuid;
pub const MRF_OPS_QUEUE_SIZE: u64 = 100000; pub const MRF_OPS_QUEUE_SIZE: u64 = 100000;
pub const HEAL_DIR: &'static str = ".heal"; pub const HEAL_DIR: &str = ".heal";
pub const HEAL_MRFMETA_FORMAT: u64 = 1; pub const HEAL_MRFMETA_FORMAT: u64 = 1;
pub const HEAL_MRFMETA_VERSION_V1: u64 = 1; pub const HEAL_MRFMETA_VERSION_V1: u64 = 1;
@@ -49,6 +49,12 @@ pub struct MRFState {
closing: AtomicBool, closing: AtomicBool,
} }
impl Default for MRFState {
fn default() -> Self {
Self::new()
}
}
impl MRFState { impl MRFState {
pub fn new() -> MRFState { pub fn new() -> MRFState {
let (tx, rx) = tokio::sync::mpsc::channel(MRF_OPS_QUEUE_SIZE as usize); let (tx, rx) = tokio::sync::mpsc::channel(MRF_OPS_QUEUE_SIZE as usize);
@@ -89,29 +95,27 @@ impl MRFState {
if let Err(err) = heal_bucket(&op.bucket).await { if let Err(err) = heal_bucket(&op.bucket).await {
error!("heal bucket failed, bucket: {}, err: {:?}", op.bucket, err); error!("heal bucket failed, bucket: {}, err: {:?}", op.bucket, err);
} }
} else if op.versions.is_empty() {
if let Err(err) =
heal_object(&op.bucket, &op.object, &op.version_id.clone().unwrap_or_default(), scan_mode).await
{
error!("heal object failed, bucket: {}, object: {}, err: {:?}", op.bucket, op.object, err);
}
} else { } else {
if op.versions.is_empty() { let vers = op.versions.len() / 16;
if let Err(err) = if vers > 0 {
heal_object(&op.bucket, &op.object, &op.version_id.clone().unwrap_or_default(), scan_mode).await for i in 0..vers {
{ let start = i * 16;
error!("heal object failed, bucket: {}, object: {}, err: {:?}", op.bucket, op.object, err); let end = start + 16;
} if let Err(err) = heal_object(
} else { &op.bucket,
let vers = op.versions.len() / 16; &op.object,
if vers > 0 { &Uuid::from_slice(&op.versions[start..end]).expect("").to_string(),
for i in 0..vers { scan_mode,
let start = i * 16; )
let end = start + 16; .await
if let Err(err) = heal_object( {
&op.bucket, error!("heal object failed, bucket: {}, object: {}, err: {:?}", op.bucket, op.object, err);
&op.object,
&Uuid::from_slice(&op.versions[start..end]).expect("").to_string(),
scan_mode,
)
.await
{
error!("heal object failed, bucket: {}, object: {}, err: {:?}", op.bucket, op.object, err);
}
} }
} }
} }
+3 -1
View File
@@ -1,3 +1,4 @@
#[allow(dead_code)]
pub fn is_simple_match<P, N>(pattern: P, name: N) -> bool pub fn is_simple_match<P, N>(pattern: P, name: N) -> bool
where where
P: AsRef<str>, P: AsRef<str>,
@@ -14,12 +15,13 @@ where
inner_match(pattern, name, false) inner_match(pattern, name, false)
} }
#[allow(dead_code)]
pub fn is_match_as_pattern_prefix<P, N>(pattern: P, text: N) -> bool pub fn is_match_as_pattern_prefix<P, N>(pattern: P, text: N) -> bool
where where
P: AsRef<str>, P: AsRef<str>,
N: AsRef<str>, N: AsRef<str>,
{ {
let (mut p, mut t) = (pattern.as_ref().as_bytes().into_iter(), text.as_ref().as_bytes().into_iter()); let (mut p, mut t) = (pattern.as_ref().as_bytes().iter(), text.as_ref().as_bytes().iter());
while let (Some(&x), Some(&y)) = (p.next(), t.next()) { while let (Some(&x), Some(&y)) = (p.next(), t.next()) {
if x == b'*' { if x == b'*' {
+4 -2
View File
@@ -862,10 +862,12 @@ impl Store for ObjectStore {
// sts users // sts users
if let Some(item_name_list) = listed_config_items.get(STS_LIST_KEY) { if let Some(item_name_list) = listed_config_items.get(STS_LIST_KEY) {
for item in item_name_list.iter() { for item in item_name_list.iter() {
info!("load sts user path: {}", item);
let name = ecstore::utils::path::dir(item); let name = ecstore::utils::path::dir(item);
info!("load sts user: {}", name); info!("load sts user: {}", name);
if let Err(err) = self.load_user(&name, UserType::Sts, &mut sts_items_cache).await { if let Err(err) = self.load_user(&name, UserType::Sts, &mut sts_items_cache).await {
return Err(Error::msg(std::format!("load user failed: {}", err))); info!("load sts user failed: {}", err);
}; };
} }
} }
@@ -879,7 +881,7 @@ impl Store for ObjectStore {
.load_mapped_policy(name, UserType::Sts, false, &mut sts_policies_cache) .load_mapped_policy(name, UserType::Sts, false, &mut sts_policies_cache)
.await .await
{ {
return Err(Error::msg(std::format!("load user failed: {}", err))); info!("load sts user policy failed: {}", err);
}; };
} }
} }