[all] Apply cargo fmt, and fix clippy warnings
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
use anyhow::{anyhow, Result};
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::{self, JoinHandle};
|
||||
use threadpool::ThreadPool;
|
||||
|
||||
use crate::io_engine::{AsyncIoEngine, IoEngine, SyncIoEngine};
|
||||
use crate::io_engine::IoEngine;
|
||||
use crate::pdata::btree::{self, *};
|
||||
use crate::pdata::btree_walker::*;
|
||||
use crate::pdata::space_map::*;
|
||||
@@ -236,8 +235,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
|
||||
}
|
||||
|
||||
let metadata_root = unpack::<SMRoot>(&sb.metadata_sm_root[0..])?;
|
||||
let mut path = Vec::new();
|
||||
path.push(0);
|
||||
let mut path = vec![0];
|
||||
|
||||
// Device details. We read this once to get the number of thin devices, and hence the
|
||||
// maximum metadata ref count. Then create metadata space map, and reread to increment
|
||||
@@ -349,7 +347,10 @@ pub struct CheckMaps {
|
||||
pub data_sm: Arc<Mutex<dyn SpaceMap + Send + Sync>>,
|
||||
}
|
||||
|
||||
pub fn check_with_maps(engine: Arc<dyn IoEngine + Send + Sync>, report: Arc<Report>) -> Result<CheckMaps> {
|
||||
pub fn check_with_maps(
|
||||
engine: Arc<dyn IoEngine + Send + Sync>,
|
||||
report: Arc<Report>,
|
||||
) -> Result<CheckMaps> {
|
||||
let ctx = mk_context(engine.clone(), report.clone())?;
|
||||
report.set_title("Checking thin metadata");
|
||||
|
||||
@@ -359,18 +360,12 @@ pub fn check_with_maps(engine: Arc<dyn IoEngine + Send + Sync>, report: Arc<Repo
|
||||
report.info(&format!("TRANSACTION_ID={}", sb.transaction_id));
|
||||
|
||||
let metadata_root = unpack::<SMRoot>(&sb.metadata_sm_root[0..])?;
|
||||
let mut path = Vec::new();
|
||||
path.push(0);
|
||||
let mut path = vec![0];
|
||||
|
||||
// Device details. We read this once to get the number of thin devices, and hence the
|
||||
// maximum metadata ref count. Then create metadata space map, and reread to increment
|
||||
// the ref counts for that metadata.
|
||||
let devs = btree_to_map::<DeviceDetail>(
|
||||
&mut path,
|
||||
engine.clone(),
|
||||
false,
|
||||
sb.details_root,
|
||||
)?;
|
||||
let devs = btree_to_map::<DeviceDetail>(&mut path, engine.clone(), false, sb.details_root)?;
|
||||
let nr_devs = devs.len();
|
||||
let metadata_sm = core_sm(engine.get_nr_blocks(), nr_devs as u32);
|
||||
inc_superblock(&metadata_sm)?;
|
||||
|
||||
@@ -255,8 +255,7 @@ fn collect_leaves(
|
||||
let mut w = LeafWalker::new(ctx.engine.clone(), sm.deref_mut(), false);
|
||||
let mut v = CollectLeaves::new();
|
||||
|
||||
let mut path = Vec::new();
|
||||
path.push(0);
|
||||
let mut path = vec![0];
|
||||
|
||||
// ctx.report.set_title(&format!("collecting {}", *r));
|
||||
w.walk::<CollectLeaves, BlockTime>(&mut path, &mut v, *r)?;
|
||||
@@ -323,8 +322,7 @@ fn build_metadata(ctx: &Context, sb: &Superblock) -> Result<Metadata> {
|
||||
report.set_title("Reading superblock");
|
||||
//let metadata_root = unpack::<SMRoot>(&sb.metadata_sm_root[0..])?;
|
||||
//let data_root = unpack::<SMRoot>(&sb.data_sm_root[0..])?;
|
||||
let mut path = Vec::new();
|
||||
path.push(0);
|
||||
let mut path = vec![0];
|
||||
|
||||
report.set_title("Reading device details");
|
||||
let details = btree_to_map::<DeviceDetail>(&mut path, engine.clone(), true, sb.details_root)?;
|
||||
@@ -385,6 +383,7 @@ fn build_metadata(ctx: &Context, sb: &Superblock) -> Result<Metadata> {
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn gather_entries(g: &mut Gatherer, es: &[Entry]) {
|
||||
g.new_seq();
|
||||
for e in es {
|
||||
@@ -399,6 +398,7 @@ fn gather_entries(g: &mut Gatherer, es: &[Entry]) {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn entries_to_runs(runs: &BTreeMap<u64, Vec<u64>>, es: &[Entry]) -> Vec<Entry> {
|
||||
use Entry::*;
|
||||
|
||||
@@ -427,6 +427,7 @@ fn entries_to_runs(runs: &BTreeMap<u64, Vec<u64>>, es: &[Entry]) -> Vec<Entry> {
|
||||
|
||||
// FIXME: do we really need to track kr?
|
||||
// FIXME: I think this may be better done as part of restore.
|
||||
#[allow(dead_code)]
|
||||
fn optimise_metadata(md: Metadata) -> Result<Metadata> {
|
||||
use Entry::*;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ impl<'a> Pass1<'a> {
|
||||
if let Some((name, nodes)) = current {
|
||||
Ok((name, nodes.complete(self.w)?))
|
||||
} else {
|
||||
let msg = format!("Unbalanced </def> tag");
|
||||
let msg = "Unbalanced </def> tag".to_string();
|
||||
Err(anyhow!(msg))
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ impl<'a> MetadataVisitor for Pass1<'a> {
|
||||
}
|
||||
Ok(Visit::Continue)
|
||||
} else {
|
||||
let msg = format!("Mapping tags must appear within a <def> or <device> tag.");
|
||||
let msg = "Mapping tags must appear within a <def> or <device> tag.".to_string();
|
||||
Err(anyhow!(msg))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,14 +110,14 @@ fn pack_superblock<W: WriteBytesExt>(sb: &Superblock, w: &mut W) -> Result<()> {
|
||||
}
|
||||
|
||||
w.write_u64::<LittleEndian>(sb.block)?;
|
||||
w.write_all(&vec![0; UUID_SIZE])?;
|
||||
w.write_all(&[0; UUID_SIZE])?;
|
||||
w.write_u64::<LittleEndian>(MAGIC)?;
|
||||
w.write_u32::<LittleEndian>(sb.version)?;
|
||||
w.write_u32::<LittleEndian>(sb.time)?;
|
||||
w.write_u64::<LittleEndian>(sb.transaction_id)?;
|
||||
w.write_u64::<LittleEndian>(sb.metadata_snap)?;
|
||||
w.write_all(&vec![0; SPACE_MAP_ROOT_SIZE])?; // data sm root
|
||||
w.write_all(&vec![0; SPACE_MAP_ROOT_SIZE])?; // metadata sm root
|
||||
w.write_all(&[0; SPACE_MAP_ROOT_SIZE])?; // data sm root
|
||||
w.write_all(&[0; SPACE_MAP_ROOT_SIZE])?; // metadata sm root
|
||||
w.write_u64::<LittleEndian>(sb.mapping_root)?;
|
||||
w.write_u64::<LittleEndian>(sb.details_root)?;
|
||||
w.write_u32::<LittleEndian>(sb.data_block_size)?;
|
||||
|
||||
Reference in New Issue
Block a user