Skip to content

Commit

Permalink
Print the integrity spec when printing the metadata
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Jan 6, 2025
1 parent ec6106b commit c9ceaa5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/engine/strat_engine/pool/inspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use std::{
use devicemapper::Sectors;

use crate::{
engine::{strat_engine::serde_structs::PoolSave, types::DevUuid},
engine::{
strat_engine::serde_structs::PoolSave,
types::{DevUuid, ValidatedIntegritySpec},
},
stratis::{StratisError, StratisResult},
};

Expand Down Expand Up @@ -535,7 +538,9 @@ impl fmt::Display for FlexDevice {
}

// Calculate map of device UUIDs to data device representation from metadata.
fn data_devices(metadata: &PoolSave) -> StratisResult<HashMap<DevUuid, DataDevice>> {
fn data_devices(
metadata: &PoolSave,
) -> StratisResult<(HashMap<DevUuid, DataDevice>, Option<ValidatedIntegritySpec>)> {
let data_tier_metadata = &metadata.backstore.data_tier;

let data_tier_devs = &data_tier_metadata.blockdev.devs;
Expand Down Expand Up @@ -570,7 +575,7 @@ fn data_devices(metadata: &PoolSave) -> StratisResult<HashMap<DevUuid, DataDevic
}
}

Ok(bds)
Ok((bds, data_tier_metadata.integrity_spec))
}

// Calculate map of device UUIDs to cache device representation from metadata.
Expand Down Expand Up @@ -669,7 +674,7 @@ pub mod inspectors {

let encrypted = metadata.features.contains(&PoolFeatures::Encryption);

let data_devices = data_devices(metadata)?;
let (data_devices, _) = data_devices(metadata)?;
for data_device in data_devices.values() {
errors.extend(data_device.check());
}
Expand Down Expand Up @@ -701,10 +706,20 @@ pub mod inspectors {

let crypt_allocs = crypt_allocs(metadata)?;
let flex_device = flex_device(metadata, encrypted)?;
let data_devices = data_devices(metadata)?;
let (data_devices, integrity_spec) = data_devices(metadata)?;
let cache_devices = cache_devices(metadata)?;
let cap_device = cap_device(metadata, encrypted)?;

println!("Integrity specification for data devices:");
println!(
"{}",
integrity_spec
.map(|s| s.to_string())
.unwrap_or_else(|| "None".into())
);

println!();

println!("Allocations from each data device:");
for (uuid, bd) in data_devices.iter() {
println!("Data device: {uuid}");
Expand Down
9 changes: 9 additions & 0 deletions src/engine/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,12 @@ impl TryFrom<IntegritySpec> for ValidatedIntegritySpec {
})
}
}

impl Display for ValidatedIntegritySpec {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Allocate Superblock: {}", self.allocate_superblock)?;
writeln!(f, "Tag Specification: {}", self.tag_spec.as_ref())?;
writeln!(f, "Journal Size: {}", self.journal_size)?;
writeln!(f, "Block Size: {}", self.block_size)
}
}

0 comments on commit c9ceaa5

Please sign in to comment.