[thin_check (rust)] Pass ctx to check_space_map
This commit is contained in:
parent
4beb2db337
commit
04f3ba5a33
@ -156,16 +156,17 @@ impl<'a> NodeVisitor<u32> for OverflowChecker<'a> {
|
|||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|
||||||
fn check_space_map(
|
fn check_space_map(
|
||||||
|
ctx: &Context,
|
||||||
kind: &str,
|
kind: &str,
|
||||||
engine: Arc<dyn IoEngine + Send + Sync>,
|
|
||||||
report: &Arc<Report>,
|
|
||||||
entries: Vec<IndexEntry>,
|
entries: Vec<IndexEntry>,
|
||||||
metadata_sm: Option<Arc<Mutex<dyn SpaceMap + Send + Sync>>>,
|
metadata_sm: Option<Arc<Mutex<dyn SpaceMap + Send + Sync>>>,
|
||||||
sm: Arc<Mutex<dyn SpaceMap + Send + Sync>>,
|
sm: Arc<Mutex<dyn SpaceMap + Send + Sync>>,
|
||||||
root: SMRoot,
|
root: SMRoot,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let sm = sm.lock().unwrap();
|
let report = ctx.report.clone();
|
||||||
|
let engine = ctx.engine.clone();
|
||||||
|
|
||||||
|
let sm = sm.lock().unwrap();
|
||||||
// overflow btree
|
// overflow btree
|
||||||
{
|
{
|
||||||
let mut v = OverflowChecker::new(&*sm);
|
let mut v = OverflowChecker::new(&*sm);
|
||||||
@ -187,7 +188,6 @@ fn check_space_map(
|
|||||||
engine.read_many(&mut blocks)?;
|
engine.read_many(&mut blocks)?;
|
||||||
|
|
||||||
let mut leaks = 0;
|
let mut leaks = 0;
|
||||||
let mut fail = false;
|
|
||||||
let mut blocknr = 0;
|
let mut blocknr = 0;
|
||||||
for n in 0..entries.len() {
|
for n in 0..entries.len() {
|
||||||
let b = &blocks[n];
|
let b = &blocks[n];
|
||||||
@ -212,7 +212,6 @@ fn check_space_map(
|
|||||||
} else if actual != expected as u8 {
|
} else if actual != expected as u8 {
|
||||||
report.fatal(&format!("Bad reference count for {} block {}. Expected {}, but space map contains {}.",
|
report.fatal(&format!("Bad reference count for {} block {}. Expected {}, but space map contains {}.",
|
||||||
kind, blocknr, expected, actual));
|
kind, blocknr, expected, actual));
|
||||||
fail = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BitmapEntry::Overflow => {
|
BitmapEntry::Overflow => {
|
||||||
@ -220,7 +219,6 @@ fn check_space_map(
|
|||||||
if expected < 3 {
|
if expected < 3 {
|
||||||
report.fatal(&format!("Bad reference count for {} block {}. Expected {}, but space map says it's >= 3.",
|
report.fatal(&format!("Bad reference count for {} block {}. Expected {}, but space map says it's >= 3.",
|
||||||
kind, blocknr, expected));
|
kind, blocknr, expected));
|
||||||
fail = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +257,7 @@ pub struct ThinCheckOptions<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_progress_thread(
|
fn spawn_progress_thread(
|
||||||
sm: Arc<Mutex<SpaceMap + Send>>,
|
sm: Arc<Mutex<dyn SpaceMap + Send + Sync>>,
|
||||||
nr_allocated_metadata: u64,
|
nr_allocated_metadata: u64,
|
||||||
report: Arc<Report>,
|
report: Arc<Report>,
|
||||||
) -> Result<(JoinHandle<()>, Arc<Mutex<bool>>)> {
|
) -> Result<(JoinHandle<()>, Arc<Mutex<bool>>)> {
|
||||||
@ -329,7 +327,7 @@ fn check_mapping_bottom_level(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
ctx.pool.join();
|
ctx.pool.join();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,10 +357,9 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
|
|||||||
// FIXME: temporarily get these out
|
// FIXME: temporarily get these out
|
||||||
let report = &ctx.report;
|
let report = &ctx.report;
|
||||||
let engine = &ctx.engine;
|
let engine = &ctx.engine;
|
||||||
let pool = &ctx.pool;
|
|
||||||
|
|
||||||
report.set_title("Checking thin metadata");
|
report.set_title("Checking thin metadata");
|
||||||
|
|
||||||
// superblock
|
// superblock
|
||||||
let sb = read_superblock(engine.as_ref(), SUPERBLOCK_LOCATION)?;
|
let sb = read_superblock(engine.as_ref(), SUPERBLOCK_LOCATION)?;
|
||||||
|
|
||||||
@ -419,9 +416,8 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
|
|||||||
inc_entries(&metadata_sm, &entries[0..])?;
|
inc_entries(&metadata_sm, &entries[0..])?;
|
||||||
|
|
||||||
check_space_map(
|
check_space_map(
|
||||||
|
&ctx,
|
||||||
"data",
|
"data",
|
||||||
engine.clone(),
|
|
||||||
&report,
|
|
||||||
entries,
|
entries,
|
||||||
Some(metadata_sm.clone()),
|
Some(metadata_sm.clone()),
|
||||||
data_sm.clone(),
|
data_sm.clone(),
|
||||||
@ -453,15 +449,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Now the counts should be correct and we can check it.
|
// Now the counts should be correct and we can check it.
|
||||||
check_space_map(
|
check_space_map(&ctx, "metadata", entries, None, metadata_sm.clone(), root)?;
|
||||||
"metadata",
|
|
||||||
engine.clone(),
|
|
||||||
&report,
|
|
||||||
entries,
|
|
||||||
None,
|
|
||||||
metadata_sm.clone(),
|
|
||||||
root,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Completing consumes the report.
|
// Completing consumes the report.
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user