mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-20 11:32:19 +00:00
fix: bug crash when disk drop
This commit is contained in:
@@ -265,6 +265,10 @@ pub fn os_err_to_file_err(e: io::Error) -> Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_unformatted_disk(err: &Error) -> bool {
|
||||||
|
matches!(err.downcast_ref::<DiskError>(), Some(DiskError::UnformattedDisk))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_err_file_not_found(err: &Error) -> bool {
|
pub fn is_err_file_not_found(err: &Error) -> bool {
|
||||||
matches!(err.downcast_ref::<DiskError>(), Some(DiskError::FileNotFound))
|
matches!(err.downcast_ref::<DiskError>(), Some(DiskError::FileNotFound))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ impl LocalDisk {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(level = "debug", skip(self))]
|
||||||
async fn check_format_json(&self) -> Result<Metadata> {
|
async fn check_format_json(&self) -> Result<Metadata> {
|
||||||
let md = fs::metadata(&self.format_path).await.map_err(|e| match e.kind() {
|
let md = fs::metadata(&self.format_path).await.map_err(|e| match e.kind() {
|
||||||
ErrorKind::NotFound => DiskError::DiskNotFound,
|
ErrorKind::NotFound => DiskError::DiskNotFound,
|
||||||
@@ -1051,6 +1052,7 @@ impl DiskAPI for LocalDisk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(level = "debug", skip(self))]
|
||||||
async fn get_disk_id(&self) -> Result<Option<Uuid>> {
|
async fn get_disk_id(&self) -> Result<Option<Uuid>> {
|
||||||
let mut format_info = self.format_info.write().await;
|
let mut format_info = self.format_info.write().await;
|
||||||
|
|
||||||
|
|||||||
@@ -1605,7 +1605,7 @@ impl SetDisks {
|
|||||||
// TODO: 优化并发 可用数量中断
|
// TODO: 优化并发 可用数量中断
|
||||||
let (parts_metadata, errs) = Self::read_all_fileinfo(&disks, "", bucket, object, vid.as_str(), read_data, false).await;
|
let (parts_metadata, errs) = Self::read_all_fileinfo(&disks, "", bucket, object, vid.as_str(), read_data, false).await;
|
||||||
// warn!("get_object_fileinfo parts_metadata {:?}", &parts_metadata);
|
// warn!("get_object_fileinfo parts_metadata {:?}", &parts_metadata);
|
||||||
warn!("get_object_fileinfo {}/{} errs {:?}", bucket, object, &errs);
|
// warn!("get_object_fileinfo {}/{} errs {:?}", bucket, object, &errs);
|
||||||
|
|
||||||
let _min_disks = self.set_drive_count - self.default_parity_count;
|
let _min_disks = self.set_drive_count - self.default_parity_count;
|
||||||
|
|
||||||
|
|||||||
+17
-3
@@ -11,7 +11,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
disk::{
|
disk::{
|
||||||
error::DiskError,
|
error::{is_unformatted_disk, DiskError},
|
||||||
format::{DistributionAlgoVersion, FormatV3},
|
format::{DistributionAlgoVersion, FormatV3},
|
||||||
new_disk, DiskAPI, DiskInfo, DiskOption, DiskStore,
|
new_disk, DiskAPI, DiskInfo, DiskOption, DiskStore,
|
||||||
},
|
},
|
||||||
@@ -34,8 +34,8 @@ use crate::{
|
|||||||
use crate::heal::heal_ops::HealSequence;
|
use crate::heal::heal_ops::HealSequence;
|
||||||
use tokio::time::Duration;
|
use tokio::time::Duration;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tracing::info;
|
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
use tracing::{error, info};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Sets {
|
pub struct Sets {
|
||||||
@@ -56,6 +56,7 @@ pub struct Sets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Sets {
|
impl Sets {
|
||||||
|
#[tracing::instrument(level = "debug", skip(disks, endpoints, fm, pool_idx, partiy_count))]
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
disks: Vec<Option<DiskStore>>,
|
disks: Vec<Option<DiskStore>>,
|
||||||
endpoints: &PoolEndpoints,
|
endpoints: &PoolEndpoints,
|
||||||
@@ -120,7 +121,20 @@ impl Sets {
|
|||||||
disk = local_disk;
|
disk = local_disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(_disk_id) = disk.as_ref().unwrap().get_disk_id().await? {
|
let has_disk_id = match disk.as_ref().unwrap().get_disk_id().await {
|
||||||
|
Ok(res) => res,
|
||||||
|
Err(err) => {
|
||||||
|
if is_unformatted_disk(&err) {
|
||||||
|
error!("get_disk_id err {:?}", err);
|
||||||
|
} else {
|
||||||
|
warn!("get_disk_id err {:?}", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(_disk_id) = has_disk_id {
|
||||||
set_drive.push(disk);
|
set_drive.push(disk);
|
||||||
} else {
|
} else {
|
||||||
warn!("sets new set_drive {}-{} get_disk_id is none", i, j);
|
warn!("sets new set_drive {}-{} get_disk_id is none", i, j);
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ pub struct ECStore {
|
|||||||
|
|
||||||
impl ECStore {
|
impl ECStore {
|
||||||
#[allow(clippy::new_ret_no_self)]
|
#[allow(clippy::new_ret_no_self)]
|
||||||
|
#[tracing::instrument(level = "debug", skip(endpoint_pools))]
|
||||||
pub async fn new(_address: String, endpoint_pools: EndpointServerPools) -> Result<Arc<Self>> {
|
pub async fn new(_address: String, endpoint_pools: EndpointServerPools) -> Result<Arc<Self>> {
|
||||||
// let layouts = DisksLayout::from_volumes(endpoints.as_slice())?;
|
// let layouts = DisksLayout::from_volumes(endpoints.as_slice())?;
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -209,10 +209,14 @@ async fn run(opt: config::Opt) -> Result<()> {
|
|||||||
// init store
|
// init store
|
||||||
let store = ECStore::new(server_address.clone(), endpoint_pools.clone())
|
let store = ECStore::new(server_address.clone(), endpoint_pools.clone())
|
||||||
.await
|
.await
|
||||||
.map_err(|err| Error::from_string(err.to_string()))?;
|
.map_err(|err| {
|
||||||
|
error!("ECStore::new {:?}", &err);
|
||||||
|
panic!("{}", err);
|
||||||
|
Error::from_string(err.to_string())
|
||||||
|
})?;
|
||||||
|
|
||||||
ECStore::init(store.clone()).await.map_err(|err| {
|
ECStore::init(store.clone()).await.map_err(|err| {
|
||||||
error!("init faild {:?}", &err);
|
error!("ECStore init faild {:?}", &err);
|
||||||
Error::from_string(err.to_string())
|
Error::from_string(err.to_string())
|
||||||
})?;
|
})?;
|
||||||
warn!(" init store success!");
|
warn!(" init store success!");
|
||||||
|
|||||||
Reference in New Issue
Block a user