[thin_check (Rust)] work in progress

This commit is contained in:
Joe Thornber
2020-07-27 15:53:42 +01:00
parent 3cf6307762
commit 1398cf31d1
5 changed files with 187 additions and 64 deletions

View File

@@ -1,13 +1,23 @@
use std::error::Error;
use std::path::Path;
use std::time::{Duration, Instant};
use std::thread;
use std::sync::{Arc, Mutex};
use crate::block_manager::BlockManager;
use crate::block_manager::{Block, IoEngine, SyncIoEngine, BLOCK_SIZE};
pub fn check(dev: &str) -> Result<(), Box<dyn Error>> {
let mut bm = BlockManager::new(dev, 1024)?;
pub fn check(dev: &Path) -> Result<(), Box<dyn Error>> {
let mut engine = SyncIoEngine::new(dev)?;
let count = 4096;
for b in 0..100 {
let _block = bm.get(b)?;
let mut blocks = Vec::new();
for n in 0..count {
blocks.push(Block::new(n));
}
let now = Instant::now();
engine.read(&mut blocks)?;
println!("read {} blocks in {} ms", count, now.elapsed().as_millis());
Ok(())
}

View File

@@ -1,4 +1,3 @@
use anyhow::Result;
use crate::block_manager::*;
use crate::checksum::*;
@@ -12,7 +11,7 @@ pub struct Superblock {
transaction_id: u64,
metadata_snap: u64,
data_sm_root: [u8; SPACE_MAP_ROOT_SIZE],
metadata_sn_root: [u8; SPACE_MAP_ROOT_SIZE],
metadata_sm_root: [u8; SPACE_MAP_ROOT_SIZE],
mapping_root: u64,
details_root: u64,
data_block_size: u32,
@@ -44,6 +43,7 @@ struct SuperblockError {
kind: ErrorType,
}
/*
use SuperblockDamage::*;
//------------------------------
@@ -57,5 +57,5 @@ pub fn check_type(b: &Block) -> Result<()> {
UNKNOWN => Err(Box::new(BadChecksum)),
}
}
*/
//------------------------------