pub struct MirroredBlockDevice<B: BlockDevice> {
backend: B,
mirrored: bool,
usable_sectors: usize,
read_failures: u64,
read_count: u64,
}Expand description
データの二重化 (ミラーリング) & 自動自己修復 (Self-Healing) を提供する上位ブロックデバイス層 SDカード等の外部不揮発性ストレージでは二重化を行い、 RAMディスク等の揮発性メモリでは多重化を行わずに全RAM容量を有効活用する。
Fields§
§backend: B§mirrored: bool§usable_sectors: usize§read_failures: u64読めなかった回数(両系とも駄目だった読み出し)。読んだ結果を覚えておく側が、途中で失敗が無かったかを確かめる。
read_count: u64読み出しの回数(診断用。覚えた結果を使い回せているかを確かめる)。
Implementations§
Source§impl<B: BlockDevice> MirroredBlockDevice<B>
impl<B: BlockDevice> MirroredBlockDevice<B>
pub fn new(backend: B) -> Self
pub fn new_mirrored(backend: B) -> Self
pub fn new_single(backend: B) -> Self
Sourcepub fn backend_mut(&mut self) -> &mut B
pub fn backend_mut(&mut self) -> &mut B
下の記憶装置(単体試験で電源断を模擬するため)。
pub fn is_mirrored(&self) -> bool
pub fn total_usable_sectors(&self) -> usize
Sourcepub fn write_sector(
&mut self,
sector: usize,
data: &[u8],
) -> Result<(), &'static str>
pub fn write_sector( &mut self, sector: usize, data: &[u8], ) -> Result<(), &'static str>
チェックサム (CRC32) 付きでデータをセクタに書き込みします
Sourcepub fn read_count(&self) -> u64
pub fn read_count(&self) -> u64
読み出しの回数(起動からの累計。診断用)。
Sourcepub fn read_failures(&self) -> u64
pub fn read_failures(&self) -> u64
読めなかった読み出しの回数(起動からの累計)。
Sourcepub fn read_sector(
&mut self,
sector: usize,
data: &mut [u8],
) -> Result<(), &'static str>
pub fn read_sector( &mut self, sector: usize, data: &mut [u8], ) -> Result<(), &'static str>
チェックサム (CRC32) 検証付きでセクタからデータを読み込みます (外部記憶ミラーリング時は破損から自動修復)
fn read_sector_checked( &mut self, sector: usize, data: &mut [u8], ) -> Result<(), &'static str>
Auto Trait Implementations§
impl<B> Freeze for MirroredBlockDevice<B>where
B: Freeze,
impl<B> RefUnwindSafe for MirroredBlockDevice<B>where
B: RefUnwindSafe,
impl<B> Send for MirroredBlockDevice<B>where
B: Send,
impl<B> Sync for MirroredBlockDevice<B>where
B: Sync,
impl<B> Unpin for MirroredBlockDevice<B>where
B: Unpin,
impl<B> UnsafeUnpin for MirroredBlockDevice<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for MirroredBlockDevice<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more