[thin_check (rust)] Rename ValueType trait to Unpack
This commit is contained in:
		@@ -141,7 +141,8 @@ impl Clone for AsyncIoEngine {
 | 
			
		||||
    fn clone(&self) -> AsyncIoEngine {
 | 
			
		||||
        let inner = self.inner.lock().unwrap();
 | 
			
		||||
        eprintln!("in clone, queue_len = {}", inner.queue_len);
 | 
			
		||||
        AsyncIoEngine {inner: Mutex::new(AsyncIoEngine_ {
 | 
			
		||||
        AsyncIoEngine {
 | 
			
		||||
            inner: Mutex::new(AsyncIoEngine_ {
 | 
			
		||||
                queue_len: inner.queue_len,
 | 
			
		||||
                ring: IoUring::new(inner.queue_len).expect("couldn't create uring"),
 | 
			
		||||
                nr_blocks: inner.nr_blocks,
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ use crate::checksum;
 | 
			
		||||
 | 
			
		||||
//------------------------------------------
 | 
			
		||||
 | 
			
		||||
pub trait ValueType {
 | 
			
		||||
pub trait Unpack {
 | 
			
		||||
    // The size of the value when on disk.
 | 
			
		||||
    fn disk_size() -> u32;
 | 
			
		||||
    fn unpack(data: &[u8]) -> IResult<&[u8], Self>
 | 
			
		||||
@@ -53,7 +53,7 @@ pub fn unpack_node_header(data: &[u8]) -> IResult<&[u8], NodeHeader> {
 | 
			
		||||
    ))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum Node<V: ValueType> {
 | 
			
		||||
pub enum Node<V: Unpack> {
 | 
			
		||||
    Internal {
 | 
			
		||||
        header: NodeHeader,
 | 
			
		||||
        keys: Vec<u64>,
 | 
			
		||||
@@ -79,7 +79,7 @@ pub fn to_any<'a, V>(r: IResult<&'a [u8], V>) -> Result<(&'a [u8], V)> {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn unpack_node<V: ValueType>(
 | 
			
		||||
pub fn unpack_node<V: Unpack>(
 | 
			
		||||
    data: &[u8],
 | 
			
		||||
    ignore_non_fatal: bool,
 | 
			
		||||
    is_root: bool,
 | 
			
		||||
@@ -154,7 +154,7 @@ pub fn unpack_node<V: ValueType>(
 | 
			
		||||
 | 
			
		||||
//------------------------------------------
 | 
			
		||||
 | 
			
		||||
impl ValueType for u64 {
 | 
			
		||||
impl Unpack for u64 {
 | 
			
		||||
    fn disk_size() -> u32 {
 | 
			
		||||
        8
 | 
			
		||||
    }
 | 
			
		||||
@@ -166,7 +166,7 @@ impl ValueType for u64 {
 | 
			
		||||
 | 
			
		||||
//------------------------------------------
 | 
			
		||||
 | 
			
		||||
pub trait NodeVisitor<V: ValueType> {
 | 
			
		||||
pub trait NodeVisitor<V: Unpack> {
 | 
			
		||||
    fn visit<'a>(&mut self, w: &BTreeWalker, b: &Block, node: &Node<V>) -> Result<()>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -208,7 +208,7 @@ impl BTreeWalker {
 | 
			
		||||
    fn walk_nodes<NV, V>(&mut self, visitor: &mut NV, bs: &Vec<u64>) -> Result<()>
 | 
			
		||||
    where
 | 
			
		||||
        NV: NodeVisitor<V>,
 | 
			
		||||
        V: ValueType,
 | 
			
		||||
        V: Unpack,
 | 
			
		||||
    {
 | 
			
		||||
        let mut blocks = Vec::new();
 | 
			
		||||
        let seen = self.seen.lock().unwrap();
 | 
			
		||||
@@ -231,7 +231,7 @@ impl BTreeWalker {
 | 
			
		||||
    fn walk_node<NV, V>(&mut self, visitor: &mut NV, b: &Block, is_root: bool) -> Result<()>
 | 
			
		||||
    where
 | 
			
		||||
        NV: NodeVisitor<V>,
 | 
			
		||||
        V: ValueType,
 | 
			
		||||
        V: Unpack,
 | 
			
		||||
    {
 | 
			
		||||
        let mut seen = self.seen.lock().unwrap();
 | 
			
		||||
        seen.insert(b.loc as usize);
 | 
			
		||||
@@ -260,7 +260,7 @@ impl BTreeWalker {
 | 
			
		||||
    pub fn walk_b<NV, V>(&mut self, visitor: &mut NV, root: &Block) -> Result<()>
 | 
			
		||||
    where
 | 
			
		||||
        NV: NodeVisitor<V>,
 | 
			
		||||
        V: ValueType,
 | 
			
		||||
        V: Unpack,
 | 
			
		||||
    {
 | 
			
		||||
        self.walk_node(visitor, &root, true)
 | 
			
		||||
    }
 | 
			
		||||
@@ -268,7 +268,7 @@ impl BTreeWalker {
 | 
			
		||||
    pub fn walk<NV, V>(&mut self, visitor: &mut NV, root: u64) -> Result<()>
 | 
			
		||||
    where
 | 
			
		||||
        NV: NodeVisitor<V>,
 | 
			
		||||
        V: ValueType,
 | 
			
		||||
        V: Unpack,
 | 
			
		||||
    {
 | 
			
		||||
        let mut root = Block::new(root);
 | 
			
		||||
        self.engine.read(&mut root)?;
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ use std::time::Instant;
 | 
			
		||||
use threadpool::ThreadPool;
 | 
			
		||||
 | 
			
		||||
use crate::block_manager::{AsyncIoEngine, Block, IoEngine};
 | 
			
		||||
use crate::pdata::btree::{BTreeWalker, Node, NodeVisitor, ValueType};
 | 
			
		||||
use crate::pdata::btree::{BTreeWalker, Node, NodeVisitor, Unpack};
 | 
			
		||||
use crate::thin::superblock::*;
 | 
			
		||||
 | 
			
		||||
//------------------------------------------
 | 
			
		||||
@@ -18,7 +18,7 @@ struct TopLevelVisitor<'a> {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a> NodeVisitor<u64> for TopLevelVisitor<'a> {
 | 
			
		||||
    fn visit(&mut self, w: &BTreeWalker, _b: &Block, node: &Node<u64>) -> Result<()> {
 | 
			
		||||
    fn visit(&mut self, _w: &BTreeWalker, _b: &Block, node: &Node<u64>) -> Result<()> {
 | 
			
		||||
        if let Node::Leaf {
 | 
			
		||||
            header: _h,
 | 
			
		||||
            keys,
 | 
			
		||||
@@ -44,7 +44,7 @@ struct BlockTime {
 | 
			
		||||
    time: u32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl ValueType for BlockTime {
 | 
			
		||||
impl Unpack for BlockTime {
 | 
			
		||||
    fn disk_size() -> u32 {
 | 
			
		||||
        8
 | 
			
		||||
    }
 | 
			
		||||
@@ -82,7 +82,7 @@ struct DeviceDetail {
 | 
			
		||||
    snapshotted_time: u32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl ValueType for DeviceDetail {
 | 
			
		||||
impl Unpack for DeviceDetail {
 | 
			
		||||
    fn disk_size() -> u32 {
 | 
			
		||||
        24
 | 
			
		||||
    }
 | 
			
		||||
@@ -139,8 +139,7 @@ impl NodeVisitor<DeviceDetail> for DeviceVisitor {
 | 
			
		||||
//------------------------------------------
 | 
			
		||||
 | 
			
		||||
pub fn check(dev: &Path) -> Result<()> {
 | 
			
		||||
    //let mut engine = SyncIoEngine::new(dev)?;
 | 
			
		||||
    let mut engine = Arc::new(AsyncIoEngine::new(dev, 256)?);
 | 
			
		||||
    let engine = Arc::new(AsyncIoEngine::new(dev, 256)?);
 | 
			
		||||
 | 
			
		||||
    let now = Instant::now();
 | 
			
		||||
    let sb = read_superblock(engine.as_ref(), SUPERBLOCK_LOCATION)?;
 | 
			
		||||
@@ -165,7 +164,7 @@ pub fn check(dev: &Path) -> Result<()> {
 | 
			
		||||
    {
 | 
			
		||||
        let nr_workers = 4;
 | 
			
		||||
        let pool = ThreadPool::new(nr_workers);
 | 
			
		||||
        let mut seen = Arc::new(Mutex::new(FixedBitSet::with_capacity(
 | 
			
		||||
        let seen = Arc::new(Mutex::new(FixedBitSet::with_capacity(
 | 
			
		||||
            engine.get_nr_blocks() as usize,
 | 
			
		||||
        )));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user