[thin_check (rust)] squash a lot of warnings
This commit is contained in:
parent
f7623e6264
commit
de172147d3
@ -1,12 +1,10 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::Result;
|
||||
use io_uring::opcode::{self, types};
|
||||
use io_uring::IoUring;
|
||||
use std::alloc::{alloc, dealloc, Layout};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io;
|
||||
use std::io::{Read, Seek};
|
||||
use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::{AsRawFd, RawFd};
|
||||
use std::path::Path;
|
||||
|
@ -4,6 +4,7 @@ use crc32c::crc32c;
|
||||
use std::io::Cursor;
|
||||
|
||||
const BLOCK_SIZE: u64 = 4096;
|
||||
#[allow(dead_code)]
|
||||
const MAGIC: u64 = 0xa537a0aa6309ef77;
|
||||
const SUPERBLOCK_CSUM_XOR: u32 = 160774;
|
||||
const BITMAP_CSUM_XOR: u32 = 240779;
|
||||
|
@ -1,16 +1,12 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use fixedbitset::FixedBitSet;
|
||||
use futures::executor;
|
||||
use nom::{bytes::complete::*, number::complete::*, IResult};
|
||||
use std::collections::HashSet;
|
||||
use std::error::Error;
|
||||
use nom::{number::complete::*, IResult};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::{self, spawn};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::Instant;
|
||||
use threadpool::ThreadPool;
|
||||
|
||||
use crate::block_manager::{AsyncIoEngine, Block, IoEngine, BLOCK_SIZE};
|
||||
use crate::block_manager::{AsyncIoEngine, Block, IoEngine};
|
||||
use crate::checksum;
|
||||
use crate::thin::superblock::*;
|
||||
|
||||
@ -21,6 +17,7 @@ trait ValueType {
|
||||
fn unpack(data: &[u8]) -> IResult<&[u8], Self::Value>;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct NodeHeader {
|
||||
is_leaf: bool,
|
||||
block: u64,
|
||||
@ -29,6 +26,7 @@ struct NodeHeader {
|
||||
value_size: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
const INTERNAL_NODE: u32 = 1;
|
||||
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>> {
|
||||
use nom::multi::count;
|
||||
|
||||
@ -215,6 +192,7 @@ impl BTreeWalker {
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct BlockTime {
|
||||
block: u64,
|
||||
time: u32,
|
||||
@ -275,7 +253,7 @@ impl NodeVisitor<ValueU64> for TopLevelVisitor {
|
||||
let mut w = w.clone();
|
||||
pool.execute(move || {
|
||||
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);
|
||||
});
|
||||
}
|
||||
@ -308,10 +286,9 @@ pub fn check(dev: &Path) -> Result<()> {
|
||||
let mut root = Block::new(sb.mapping_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 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());
|
||||
|
||||
Ok(())
|
||||
|
@ -1,11 +1,9 @@
|
||||
use crate::block_manager::*;
|
||||
use crate::block_manager::*;
|
||||
use crate::checksum::*;
|
||||
use anyhow::{anyhow, Result};
|
||||
use nom::{bytes::complete::*, number::complete::*, IResult};
|
||||
|
||||
pub const SUPERBLOCK_LOCATION: u64 = 0;
|
||||
const UUID_SIZE: usize = 16;
|
||||
//const UUID_SIZE: usize = 16;
|
||||
const SPACE_MAP_ROOT_SIZE: usize = 128;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -23,6 +21,7 @@ pub struct Superblock {
|
||||
pub data_block_size: u32,
|
||||
}
|
||||
|
||||
/*
|
||||
pub enum CheckSeverity {
|
||||
Fatal,
|
||||
NonFatal,
|
||||
@ -48,6 +47,7 @@ struct SuperblockError {
|
||||
severity: CheckSeverity,
|
||||
kind: ErrorType,
|
||||
}
|
||||
*/
|
||||
|
||||
fn unpack(data: &[u8]) -> IResult<&[u8], Superblock> {
|
||||
let (i, _csum) = le_u32(data)?;
|
||||
|
Loading…
Reference in New Issue
Block a user