mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 13:16:28 +00:00
fix: #23 need test reduce_read_quorum_errs
This commit is contained in:
+10
-10
@@ -113,9 +113,9 @@ impl LocalDisk {
|
|||||||
Ok(disk)
|
Ok(disk)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_path_length(path_name: &str) -> Result<()> {
|
// fn check_path_length(_path_name: &str) -> Result<()> {
|
||||||
unimplemented!()
|
// unimplemented!()
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn is_valid_volname(volname: &str) -> bool {
|
fn is_valid_volname(volname: &str) -> bool {
|
||||||
if volname.len() < 3 {
|
if volname.len() < 3 {
|
||||||
@@ -1000,10 +1000,10 @@ impl DiskAPI for LocalDisk {
|
|||||||
created: modtime,
|
created: modtime,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
async fn delete_paths(&self, volume: &str, paths: &[&str]) -> Result<()> {
|
async fn delete_paths(&self, _volume: &str, _paths: &[&str]) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
async fn update_metadata(&self, volume: &str, path: &str, fi: FileInfo, opts: UpdateMetadataOpts) {
|
async fn update_metadata(&self, _volume: &str, _path: &str, _fi: FileInfo, _opts: UpdateMetadataOpts) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
async fn write_metadata(&self, _org_volume: &str, volume: &str, path: &str, fi: FileInfo) -> Result<()> {
|
async fn write_metadata(&self, _org_volume: &str, volume: &str, path: &str, fi: FileInfo) -> Result<()> {
|
||||||
@@ -1062,11 +1062,11 @@ impl DiskAPI for LocalDisk {
|
|||||||
}
|
}
|
||||||
async fn delete_version(
|
async fn delete_version(
|
||||||
&self,
|
&self,
|
||||||
volume: &str,
|
_volume: &str,
|
||||||
path: &str,
|
_path: &str,
|
||||||
fi: FileInfo,
|
_fi: FileInfo,
|
||||||
force_del_marker: bool,
|
_force_del_marker: bool,
|
||||||
opts: DeleteOptions,
|
_opts: DeleteOptions,
|
||||||
) -> Result<RawFileInfo> {
|
) -> Result<RawFileInfo> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -482,11 +482,11 @@ impl DiskAPI for RemoteDisk {
|
|||||||
}
|
}
|
||||||
async fn delete_version(
|
async fn delete_version(
|
||||||
&self,
|
&self,
|
||||||
volume: &str,
|
_volume: &str,
|
||||||
path: &str,
|
_path: &str,
|
||||||
fi: FileInfo,
|
_fi: FileInfo,
|
||||||
force_del_marker: bool,
|
_force_del_marker: bool,
|
||||||
opts: DeleteOptions,
|
_opts: DeleteOptions,
|
||||||
) -> Result<RawFileInfo> {
|
) -> Result<RawFileInfo> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{disk::error::DiskError, error::Error};
|
||||||
disk::error::DiskError,
|
|
||||||
error::{Error, Result},
|
|
||||||
};
|
|
||||||
use std::{collections::HashMap, fmt::Debug};
|
use std::{collections::HashMap, fmt::Debug};
|
||||||
|
|
||||||
// pub type CheckErrorFn = fn(e: &Error) -> bool;
|
// pub type CheckErrorFn = fn(e: &Error) -> bool;
|
||||||
@@ -11,7 +8,7 @@ pub trait CheckErrorFn: Debug + Send + Sync + 'static {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
enum QuorumError {
|
pub enum QuorumError {
|
||||||
#[error("Read quorum not met")]
|
#[error("Read quorum not met")]
|
||||||
Read,
|
Read,
|
||||||
#[error("disk not found")]
|
#[error("disk not found")]
|
||||||
@@ -112,7 +109,7 @@ fn reduce_quorum_errs(
|
|||||||
// 根据读quorum验证错误数量
|
// 根据读quorum验证错误数量
|
||||||
// 返回最大错误数量的下标,或QuorumError
|
// 返回最大错误数量的下标,或QuorumError
|
||||||
pub fn reduce_read_quorum_errs(
|
pub fn reduce_read_quorum_errs(
|
||||||
errs: &mut Vec<Option<Error>>,
|
errs: &Vec<Option<Error>>,
|
||||||
ignored_errs: &Vec<Box<dyn CheckErrorFn>>,
|
ignored_errs: &Vec<Box<dyn CheckErrorFn>>,
|
||||||
read_quorum: usize,
|
read_quorum: usize,
|
||||||
) -> Option<Error> {
|
) -> Option<Error> {
|
||||||
|
|||||||
+2
-2
@@ -98,7 +98,7 @@ impl Sets {
|
|||||||
let set_disks = SetDisks {
|
let set_disks = SetDisks {
|
||||||
disks: RwLock::new(set_drive),
|
disks: RwLock::new(set_drive),
|
||||||
set_drive_count,
|
set_drive_count,
|
||||||
parity_count: partiy_count,
|
default_parity_count: partiy_count,
|
||||||
set_index: i,
|
set_index: i,
|
||||||
pool_index: pool_idx,
|
pool_index: pool_idx,
|
||||||
set_endpoints,
|
set_endpoints,
|
||||||
@@ -343,7 +343,7 @@ impl StorageAPI for Sets {
|
|||||||
.get_object_reader(bucket, object, range, h, opts)
|
.get_object_reader(bucket, object, range, h, opts)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
|
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<ObjectInfo> {
|
||||||
self.get_disks_by_key(object).put_object(bucket, object, data, opts).await
|
self.get_disks_by_key(object).put_object(bucket, object, data, opts).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ impl ECStore {
|
|||||||
if entry.is_object() {
|
if entry.is_object() {
|
||||||
let fi = entry.to_fileinfo(&opts.bucket)?;
|
let fi = entry.to_fileinfo(&opts.bucket)?;
|
||||||
if fi.is_some() {
|
if fi.is_some() {
|
||||||
ress.push(fi.unwrap().into_object_info(&opts.bucket, &entry.name, false));
|
ress.push(fi.unwrap().to_object_info(&opts.bucket, &entry.name, false));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -738,7 +738,7 @@ impl StorageAPI for ECStore {
|
|||||||
|
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
|
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<ObjectInfo> {
|
||||||
// checkPutObjectArgs
|
// checkPutObjectArgs
|
||||||
|
|
||||||
let object = utils::path::encode_dir_object(object);
|
let object = utils::path::encode_dir_object(object);
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ pub struct FileInfo {
|
|||||||
pub is_latest: bool,
|
pub is_latest: bool,
|
||||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||||
pub tags: Option<HashMap<String, String>>,
|
pub tags: Option<HashMap<String, String>>,
|
||||||
|
pub metadata: Option<HashMap<String, String>>,
|
||||||
|
pub num_versions: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl Default for FileInfo {
|
// impl Default for FileInfo {
|
||||||
@@ -96,6 +98,14 @@ impl FileInfo {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_etag(&self) -> Option<String> {
|
||||||
|
if let Some(meta) = &self.metadata {
|
||||||
|
meta.get("etag").cloned()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn write_quorum(&self, quorum: usize) -> usize {
|
pub fn write_quorum(&self, quorum: usize) -> usize {
|
||||||
if self.deleted {
|
if self.deleted {
|
||||||
return quorum;
|
return quorum;
|
||||||
@@ -141,7 +151,7 @@ impl FileInfo {
|
|||||||
self.parts.sort_by(|a, b| a.number.cmp(&b.number));
|
self.parts.sort_by(|a, b| a.number.cmp(&b.number));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_object_info(&self, bucket: &str, object: &str, _versioned: bool) -> ObjectInfo {
|
pub fn to_object_info(&self, bucket: &str, object: &str, _versioned: bool) -> ObjectInfo {
|
||||||
ObjectInfo {
|
ObjectInfo {
|
||||||
bucket: bucket.to_string(),
|
bucket: bucket.to_string(),
|
||||||
name: object.to_string(),
|
name: object.to_string(),
|
||||||
@@ -533,7 +543,7 @@ pub trait StorageAPI {
|
|||||||
h: HeaderMap,
|
h: HeaderMap,
|
||||||
opts: &ObjectOptions,
|
opts: &ObjectOptions,
|
||||||
) -> Result<GetObjectReader>;
|
) -> Result<GetObjectReader>;
|
||||||
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()>;
|
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<ObjectInfo>;
|
||||||
async fn put_object_part(
|
async fn put_object_part(
|
||||||
&self,
|
&self,
|
||||||
bucket: &str,
|
bucket: &str,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::{fs::Metadata, path::Path};
|
|||||||
|
|
||||||
use tokio::{fs, io};
|
use tokio::{fs, io};
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(windows))]
|
||||||
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(windows)]
|
||||||
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
|
||||||
if f1.permissions() != f2.permissions() {
|
if f1.permissions() != f2.permissions() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user