⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

RaidArray

Struct RaidArray 

Source
pub struct RaidArray {
    pub name: String,
    pub uuid: [u8; 16],
    pub level: RaidLevel,
    pub chunk_size: u64,
    pub disks: Vec<RaidDisk>,
    pub spares: Vec<RaidDisk>,
    pub state: ArrayState,
    pub superblock: Superblock,
    pub rebuild_progress: u8,
}
Expand description

A RAID array composed of multiple disks.

Fields§

§name: String

Array name.

§uuid: [u8; 16]

Array UUID.

§level: RaidLevel

RAID level.

§chunk_size: u64

Chunk size in blocks.

§disks: Vec<RaidDisk>

Member disks.

§spares: Vec<RaidDisk>

Hot spare disks.

§state: ArrayState

Array state.

§superblock: Superblock

Superblock.

§rebuild_progress: u8

Rebuild progress (0-100).

Implementations§

Source§

impl RaidArray

Source

pub fn new( name: &str, level: RaidLevel, disks: Vec<RaidDisk>, ) -> Result<Self, RaidError>

Create a new RAID array.

Source

pub fn stripe_map(&self, logical_block: u64) -> Result<StripeMap, RaidError>

Map a logical block to a physical stripe location (RAID0).

Source

pub fn raid5_map(&self, logical_block: u64) -> Result<StripeMap, RaidError>

Map a logical block for RAID5 (left-symmetric parity rotation).

Source

pub fn read_stripe(&self, logical_block: u64) -> Result<StripeMap, RaidError>

Read a stripe (dispatch by RAID level).

Source

pub fn write_stripe( &self, logical_block: u64, ) -> Result<Vec<StripeMap>, RaidError>

Write a stripe (dispatch by RAID level, returns all disks to write).

Source

pub fn compute_parity(blocks: &[&[u8]]) -> Vec<u8>

Compute XOR parity across data blocks.

Source

pub fn rebuild(&mut self, failed_disk_idx: usize) -> Result<(), RaidError>

Rebuild a failed disk from parity and remaining data.

Source

pub fn check_health(&mut self) -> ArrayState

Check array health and update state.

Source

pub fn replace_disk(&mut self, failed_disk_idx: usize) -> Result<(), RaidError>

Replace a failed disk with a spare.

Source

pub fn add_spare(&mut self, disk: RaidDisk)

Add a hot spare disk.

Source

pub fn active_disk_count(&self) -> usize

Get the number of active disks.

Source

pub fn failed_disk_count(&self) -> usize

Get the number of failed disks.

Source

pub fn capacity_blocks(&self) -> u64

Get usable capacity in blocks.

Trait Implementations§

Source§

impl Debug for RaidArray

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RaidArray

Source§

fn eq(&self, other: &RaidArray) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RaidArray

Auto Trait Implementations§

§

impl Freeze for RaidArray

§

impl RefUnwindSafe for RaidArray

§

impl Send for RaidArray

§

impl Sync for RaidArray

§

impl Unpin for RaidArray

§

impl UnwindSafe for RaidArray

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.