[thin_check (rust)] squash a lot of warnings

This commit is contained in:
Joe Thornber 2020-07-30 10:12:51 +01:00
parent f7623e6264
commit de172147d3
4 changed files with 13 additions and 37 deletions

View File

@ -1,12 +1,10 @@
use anyhow::{anyhow, Result}; use anyhow::Result;
use io_uring::opcode::{self, types}; use io_uring::opcode::{self, types};
use io_uring::IoUring; use io_uring::IoUring;
use std::alloc::{alloc, dealloc, Layout}; use std::alloc::{alloc, dealloc, Layout};
use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io; use std::io;
use std::io::{Read, Seek};
use std::os::unix::fs::OpenOptionsExt; use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::path::Path; use std::path::Path;

View File

@ -4,6 +4,7 @@ use crc32c::crc32c;
use std::io::Cursor; use std::io::Cursor;
const BLOCK_SIZE: u64 = 4096; const BLOCK_SIZE: u64 = 4096;
#[allow(dead_code)]
const MAGIC: u64 = 0xa537a0aa6309ef77; const MAGIC: u64 = 0xa537a0aa6309ef77;
const SUPERBLOCK_CSUM_XOR: u32 = 160774; const SUPERBLOCK_CSUM_XOR: u32 = 160774;
const BITMAP_CSUM_XOR: u32 = 240779; const BITMAP_CSUM_XOR: u32 = 240779;

View File

@ -1,16 +1,12 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use fixedbitset::FixedBitSet; use fixedbitset::FixedBitSet;
use futures::executor; use nom::{number::complete::*, IResult};
use nom::{bytes::complete::*, number::complete::*, IResult};
use std::collections::HashSet;
use std::error::Error;
use std::path::Path; use std::path::Path;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread::{self, spawn}; use std::time::Instant;
use std::time::{Duration, Instant};
use threadpool::ThreadPool; use threadpool::ThreadPool;
use crate::block_manager::{AsyncIoEngine, Block, IoEngine, BLOCK_SIZE}; use crate::block_manager::{AsyncIoEngine, Block, IoEngine};
use crate::checksum; use crate::checksum;
use crate::thin::superblock::*; use crate::thin::superblock::*;
@ -21,6 +17,7 @@ trait ValueType {
fn unpack(data: &[u8]) -> IResult<&[u8], Self::Value>; fn unpack(data: &[u8]) -> IResult<&[u8], Self::Value>;
} }
#[allow(dead_code)]
struct NodeHeader { struct NodeHeader {
is_leaf: bool, is_leaf: bool,
block: u64, block: u64,
@ -29,6 +26,7 @@ struct NodeHeader {
value_size: u32, value_size: u32,
} }
#[allow(dead_code)]
const INTERNAL_NODE: u32 = 1; const INTERNAL_NODE: u32 = 1;
const LEAF_NODE: u32 = 2; const LEAF_NODE: u32 = 2;
@ -66,27 +64,6 @@ enum Node<V: ValueType> {
}, },
} }
impl<V: ValueType> Node<V> {
fn get_header(&self) -> &NodeHeader {
match self {
Node::Internal {
header,
keys: _k,
values: _v,
} => &header,
Node::Leaf {
header,
keys: _k,
values: _v,
} => &header,
}
}
fn is_leaf(&self) -> bool {
self.get_header().is_leaf
}
}
fn unpack_node_<V: ValueType>(data: &[u8]) -> IResult<&[u8], Node<V>> { fn unpack_node_<V: ValueType>(data: &[u8]) -> IResult<&[u8], Node<V>> {
use nom::multi::count; use nom::multi::count;
@ -215,6 +192,7 @@ impl BTreeWalker {
//------------------------------------------ //------------------------------------------
#[allow(dead_code)]
struct BlockTime { struct BlockTime {
block: u64, block: u64,
time: u32, time: u32,
@ -275,7 +253,7 @@ impl NodeVisitor<ValueU64> for TopLevelVisitor {
let mut w = w.clone(); let mut w = w.clone();
pool.execute(move || { pool.execute(move || {
let mut v = BottomLevelVisitor {}; let mut v = BottomLevelVisitor {};
w.walk_node(&mut v, &b); w.walk_node(&mut v, &b).expect("walk failed"); // FIXME: return error
eprintln!("checked thin_dev {}", thin_id); eprintln!("checked thin_dev {}", thin_id);
}); });
} }
@ -308,10 +286,9 @@ pub fn check(dev: &Path) -> Result<()> {
let mut root = Block::new(sb.mapping_root); let mut root = Block::new(sb.mapping_root);
engine.read(&mut root)?; engine.read(&mut root)?;
let mut seen = FixedBitSet::with_capacity(engine.get_nr_blocks() as usize);
let mut w = BTreeWalker::new(engine); let mut w = BTreeWalker::new(engine);
let mut visitor = TopLevelVisitor {}; let mut visitor = TopLevelVisitor {};
let result = w.walk_node(&mut visitor, &root)?; let _result = w.walk_node(&mut visitor, &root)?;
println!("read mapping tree in {} ms", now.elapsed().as_millis()); println!("read mapping tree in {} ms", now.elapsed().as_millis());
Ok(()) Ok(())

View File

@ -1,11 +1,9 @@
use crate::block_manager::*; use crate::block_manager::*;
use crate::block_manager::*;
use crate::checksum::*;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use nom::{bytes::complete::*, number::complete::*, IResult}; use nom::{bytes::complete::*, number::complete::*, IResult};
pub const SUPERBLOCK_LOCATION: u64 = 0; pub const SUPERBLOCK_LOCATION: u64 = 0;
const UUID_SIZE: usize = 16; //const UUID_SIZE: usize = 16;
const SPACE_MAP_ROOT_SIZE: usize = 128; const SPACE_MAP_ROOT_SIZE: usize = 128;
#[derive(Debug)] #[derive(Debug)]
@ -23,6 +21,7 @@ pub struct Superblock {
pub data_block_size: u32, pub data_block_size: u32,
} }
/*
pub enum CheckSeverity { pub enum CheckSeverity {
Fatal, Fatal,
NonFatal, NonFatal,
@ -48,6 +47,7 @@ struct SuperblockError {
severity: CheckSeverity, severity: CheckSeverity,
kind: ErrorType, kind: ErrorType,
} }
*/
fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> { fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> {
let (i, _csum) = le_u32(data)?; let (i, _csum) = le_u32(data)?;