From 55ee4bfad83f42b86f4f788c2466a1c1e49fbc56 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Mon, 10 Aug 2020 14:56:39 +0100 Subject: [PATCH] [thin_check (rust)] replace IndexVisitor with a call to btree_to_map --- src/thin/check.rs | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/src/thin/check.rs b/src/thin/check.rs index 9502270..73094c9 100644 --- a/src/thin/check.rs +++ b/src/thin/check.rs @@ -141,31 +141,6 @@ impl Unpack for DeviceDetail { //------------------------------------------ -struct IndexVisitor { - entries: Vec, -} - -impl NodeVisitor for IndexVisitor { - fn visit(&mut self, _w: &BTreeWalker, _b: &Block, node: &Node) -> Result<()> { - if let Node::Leaf { - header: _h, - keys: _k, - values, - } = node - { - for v in values { - // FIXME: check keys are in incremental order - let v = v.clone(); - self.entries.push(v); - } - } - - Ok(()) - } -} - -//------------------------------------------ - struct OverflowChecker<'a> { data_sm: &'a dyn SpaceMap, } @@ -282,15 +257,11 @@ pub fn check(opts: &ThinCheckOptions) -> Result<()> { } // Bitmaps - let mut v = IndexVisitor { - entries: Vec::new(), - }; - let mut w = BTreeWalker::new(engine.clone(), false); - let _result = w.walk(&mut v, root.bitmap_root); - eprintln!("{} index entries", v.entries.len()); + let entries = btree_to_map::(engine.clone(), false, root.bitmap_root)?; + eprintln!("{} index entries", entries.len()); let mut blocks = Vec::new(); - for i in &v.entries { + for (_k, i) in &entries { blocks.push(Block::new(i.blocknr)); } @@ -299,7 +270,7 @@ pub fn check(opts: &ThinCheckOptions) -> Result<()> { let mut leaks = 0; let mut fail = false; let mut blocknr = 0; - for (n, _i) in v.entries.iter().enumerate() { + for n in 0..entries.len() { let b = &blocks[n]; if checksum::metadata_block_type(&b.get_data()) != checksum::BT::BITMAP { return Err(anyhow!(