From 8eec84fbecd0910b283413ec861762359bd388b2 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 18 Aug 2020 11:06:15 +0100 Subject: [PATCH] [thin_check (rust)] introduce ASpaceMap type alias --- src/pdata/space_map.rs | 2 ++ src/thin/check.rs | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/pdata/space_map.rs b/src/pdata/space_map.rs index 7f36aba..8c66e1f 100644 --- a/src/pdata/space_map.rs +++ b/src/pdata/space_map.rs @@ -184,6 +184,8 @@ pub trait SpaceMap { fn inc(&mut self, begin: u64, len: u64) -> Result<()>; } +pub type ASpaceMap = Arc>; + //------------------------------------------ pub struct CoreSpaceMap { diff --git a/src/thin/check.rs b/src/thin/check.rs index 97b7364..2073502 100644 --- a/src/thin/check.rs +++ b/src/thin/check.rs @@ -43,7 +43,7 @@ impl Unpack for BlockTime { } struct BottomLevelVisitor { - data_sm: Arc>, + data_sm: ASpaceMap, } //------------------------------------------ @@ -159,14 +159,15 @@ fn check_space_map( ctx: &Context, kind: &str, entries: Vec, - metadata_sm: Option>>, - sm: Arc>, + metadata_sm: Option, + sm: ASpaceMap, root: SMRoot, ) -> Result<()> { let report = ctx.report.clone(); let engine = ctx.engine.clone(); let sm = sm.lock().unwrap(); + // overflow btree { let mut v = OverflowChecker::new(&*sm); @@ -238,7 +239,7 @@ fn check_space_map( //------------------------------------------ -fn inc_entries(sm: &Arc>, entries: &[IndexEntry]) -> Result<()> { +fn inc_entries(sm: &ASpaceMap, entries: &[IndexEntry]) -> Result<()> { let mut sm = sm.lock().unwrap(); for ie in entries { sm.inc(ie.blocknr, 1)?; @@ -246,6 +247,13 @@ fn inc_entries(sm: &Arc>, entries: &[IndexEntr Ok(()) } +fn inc_superblock(sm: &ASpaceMap) -> Result<()> +{ + let mut sm = sm.lock().unwrap(); + sm.inc(SUPERBLOCK_LOCATION, 1)?; + Ok(()) +} + //------------------------------------------ const MAX_CONCURRENT_IO: u32 = 1024; @@ -375,6 +383,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> { let devs = btree_to_map::(engine.clone(), false, sb.details_root)?; let nr_devs = devs.len(); let metadata_sm = core_sm(engine.get_nr_blocks(), nr_devs as u32); + inc_superblock(&metadata_sm)?; report.set_sub_title("device details tree"); let _devs = btree_to_map_with_sm::( @@ -387,17 +396,11 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> { let (tid, stop_progress) = spawn_progress_thread(metadata_sm.clone(), nr_allocated_metadata, report.clone())?; - // increment superblock - { - let mut sm = metadata_sm.lock().unwrap(); - sm.inc(SUPERBLOCK_LOCATION, 1)?; - } - // mapping top level let roots = btree_to_map_with_sm::(engine.clone(), metadata_sm.clone(), false, sb.mapping_root)?; - // Check the mappings filling in the data_sm as we go. + // mapping bottom level report.set_sub_title("mapping tree"); let root = unpack::(&sb.data_sm_root[0..])?; let data_sm = core_sm(root.nr_blocks, nr_devs as u32);