Implement VFS RAID-Z (software RAID)
- Add VfsRaidLevel enum: - Single (no RAID) - RaidZ1 (single parity, similar to RAID 5) - RaidZ2 (double parity, similar to RAID 6) - RaidZ3 (triple parity) - Add VfsRaidBackend with: - Stripe-based data distribution across disks - Galois Field arithmetic for parity (P/Q/R) - gf_exp, gf_mul for Reed-Solomon coding - rebuild_disk() for disk recovery - Add VfsRaidConfig: - level (RAID level) - stripe_size (default 64KB) - disk_paths (storage devices) - All VfsBackend methods propagate to all disks - Foundation for ZFS-style software RAID All 229 tests pass.
This commit is contained in:
@@ -2,6 +2,7 @@ pub mod compression;
|
||||
pub mod dedup;
|
||||
pub mod local_fs;
|
||||
pub mod open_flags;
|
||||
pub mod raid;
|
||||
pub mod s3_fs;
|
||||
pub mod smb_fs;
|
||||
#[cfg(feature = "smb-server")]
|
||||
@@ -452,3 +453,48 @@ impl Default for VfsDedupConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// RAID级别(ZFS RAID-Z)
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum VfsRaidLevel {
|
||||
/// 单磁盘(无RAID)
|
||||
Single,
|
||||
/// RAID-Z1(单奇偶校验,类似RAID 5)
|
||||
RaidZ1,
|
||||
/// RAID-Z2(双奇偶校验,类似RAID 6)
|
||||
RaidZ2,
|
||||
/// RAID-Z3(三奇偶校验)
|
||||
RaidZ3,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for VfsRaidLevel {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
VfsRaidLevel::Single => write!(f, "Single"),
|
||||
VfsRaidLevel::RaidZ1 => write!(f, "RAID-Z1"),
|
||||
VfsRaidLevel::RaidZ2 => write!(f, "RAID-Z2"),
|
||||
VfsRaidLevel::RaidZ3 => write!(f, "RAID-Z3"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// RAID配置
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VfsRaidConfig {
|
||||
/// RAID级别
|
||||
pub level: VfsRaidLevel,
|
||||
/// 条带大小(字节),默认64KB
|
||||
pub stripe_size: usize,
|
||||
/// 磁盘列表路径
|
||||
pub disk_paths: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl Default for VfsRaidConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
level: VfsRaidLevel::Single,
|
||||
stripe_size: 65536,
|
||||
disk_paths: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user