[thin_check (rust)] BTree values must now implement Copy

This commit is contained in:
Joe Thornber 2020-09-18 10:06:33 +01:00
parent bcfb9a73a1
commit bc058f8baf
4 changed files with 31 additions and 33 deletions

View File

@ -634,7 +634,9 @@ fn explore(path: &Path) -> Result<()> {
panels.push(Box::new(BottomLevelPanel::new(thin_id, node)));
}
Some(Action::PopPanel) => {
panels.pop();
if panels.len() > 2 {
panels.pop();
}
}
_ => {}
},

View File

@ -313,7 +313,7 @@ pub type Result<T> = std::result::Result<T, BTreeError>;
//------------------------------------------
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub struct NodeHeader {
pub block: u64,
pub is_leaf: bool,
@ -824,7 +824,8 @@ impl<V> ValueCollector<V> {
}
}
impl<V: Unpack + Clone> NodeVisitor<V> for ValueCollector<V> {
// FIXME: should we be using Copy rather than clone? (Yes)
impl<V: Unpack + Copy> NodeVisitor<V> for ValueCollector<V> {
fn visit(&self, _kr: &KeyRange, _h: &NodeHeader, keys: &[u64], values: &[V]) -> Result<()> {
let mut vals = self.values.lock().unwrap();
for n in 0..keys.len() {
@ -835,7 +836,7 @@ impl<V: Unpack + Clone> NodeVisitor<V> for ValueCollector<V> {
}
}
pub fn btree_to_map<V: Unpack + Clone>(
pub fn btree_to_map<V: Unpack + Copy>(
engine: Arc<dyn IoEngine + Send + Sync>,
ignore_non_fatal: bool,
root: u64,
@ -846,7 +847,7 @@ pub fn btree_to_map<V: Unpack + Clone>(
Ok(visitor.values.into_inner().unwrap())
}
pub fn btree_to_map_with_sm<V: Unpack + Clone>(
pub fn btree_to_map_with_sm<V: Unpack + Copy>(
engine: Arc<dyn IoEngine + Send + Sync>,
sm: Arc<Mutex<dyn SpaceMap + Send + Sync>>,
ignore_non_fatal: bool,
@ -860,3 +861,23 @@ pub fn btree_to_map_with_sm<V: Unpack + Clone>(
}
//------------------------------------------
/*
struct ValuePathCollector<V> {
values: Mutex<BTreeMap<u64, (Vec<u64>, V)>>
}
impl<V> ValuePathCollector<V> {
fn new() -> ValuePathCollector<V> {
ValuePathCollector {
values: Mutex::new(BTreeMap::new()),
}
}
}
impl<V: Unpack + Clone> NodeVisitor<V> for ValueCollector<V> {
}
*/
//------------------------------------------

View File

@ -49,7 +49,7 @@ impl Unpack for SMRoot {
//------------------------------------------
#[derive(Clone, Debug)]
#[derive(Clone, Copy, Debug)]
pub struct IndexEntry {
pub blocknr: u64,
pub nr_free: u32,

View File

@ -14,35 +14,10 @@ use crate::pdata::space_map::*;
use crate::pdata::unpack::*;
use crate::report::*;
use crate::thin::superblock::*;
use crate::thin::block_time::*;
//------------------------------------------
#[allow(dead_code)]
struct BlockTime {
block: u64,
time: u32,
}
impl Unpack for BlockTime {
fn disk_size() -> u32 {
8
}
fn unpack(i: &[u8]) -> IResult<&[u8], BlockTime> {
let (i, n) = le_u64(i)?;
let block = n >> 24;
let time = n & ((1 << 24) - 1);
Ok((
i,
BlockTime {
block,
time: time as u32,
},
))
}
}
struct BottomLevelVisitor {
data_sm: ASpaceMap,
}
@ -80,7 +55,7 @@ impl NodeVisitor<BlockTime> for BottomLevelVisitor {
//------------------------------------------
#[derive(Clone)]
#[derive(Clone, Copy)]
struct DeviceDetail {
mapped_blocks: u64,
transaction_id: u64,