[thin_explore] Explore devices tree, including path support.

This commit is contained in:
Joe Thornber
2020-10-15 11:53:09 +01:00
parent c42b623e39
commit f60ae770c2
4 changed files with 206 additions and 46 deletions

View File

@@ -467,7 +467,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
// 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(), opts.ignore_non_fatal, 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)?;
@@ -477,7 +477,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
&mut path,
engine.clone(),
metadata_sm.clone(),
false,
opts.ignore_non_fatal,
sb.details_root,
)?;
@@ -493,7 +493,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
&mut path,
engine.clone(),
metadata_sm.clone(),
false,
opts.ignore_non_fatal,
sb.mapping_root,
)?;
@@ -514,7 +514,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
&mut path,
engine.clone(),
metadata_sm.clone(),
false,
opts.ignore_non_fatal,
root.bitmap_root,
)?;
let entries: Vec<IndexEntry> = entries.values().cloned().collect();
@@ -556,7 +556,7 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
&mut path,
engine.clone(),
metadata_sm.clone(),
false,
opts.ignore_non_fatal,
root.ref_count_root,
)?;

View File

@@ -1,3 +1,5 @@
use std::fmt;
use crate::pdata::unpack::*;
use nom::{number::complete::*, IResult};
@@ -11,6 +13,17 @@ pub struct DeviceDetail {
pub snapshotted_time: u32,
}
impl fmt::Display for DeviceDetail {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "mapped = {}, trans = {}, create = {}, snap = {}",
self.mapped_blocks,
self.transaction_id,
self.creation_time,
self.snapshotted_time);
Ok(())
}
}
impl Unpack for DeviceDetail {
fn disk_size() -> u32 {
24