diff --git a/src/dbus_api/blockdev/fetch_properties_2_5/methods.rs b/src/dbus_api/blockdev/fetch_properties_2_5/methods.rs index 58e90981348..d6a16374caf 100644 --- a/src/dbus_api/blockdev/fetch_properties_2_5/methods.rs +++ b/src/dbus_api/blockdev/fetch_properties_2_5/methods.rs @@ -15,9 +15,10 @@ use crate::dbus_api::{ blockdev::shared::blockdev_operation, consts, types::TData, util::result_to_tuple, }; -const ALL_PROPERTIES: [&str; 2] = [ +const ALL_PROPERTIES: [&str; 3] = [ consts::BLOCKDEV_TOTAL_SIZE_PROP, consts::BLOCKDEV_TOTAL_SIZE_ALLOCATED_PROP, + consts::BLOCKDEV_TOTAL_REAL_SIZE_PROP, ]; #[allow(unknown_lints)] @@ -50,6 +51,14 @@ fn get_properties_shared( |_, bd| Ok((*bd.allocated().bytes()).to_string()), )), )), + consts::BLOCKDEV_TOTAL_REAL_SIZE_PROP => Some(( + prop, + result_to_tuple(blockdev_operation( + m.tree, + object_path.get_name(), + |_, bd| Ok((*bd.real_size().bytes()).to_string()), + )), + )), _ => None, }) .collect(); diff --git a/src/dbus_api/consts.rs b/src/dbus_api/consts.rs index 90b617b4dc8..aa49d31e7bd 100644 --- a/src/dbus_api/consts.rs +++ b/src/dbus_api/consts.rs @@ -69,6 +69,7 @@ pub const BLOCKDEV_PHYSICAL_PATH_PROP: &str = "PhysicalPath"; pub const BLOCKDEV_TOTAL_SIZE_PROP: &str = "TotalPhysicalSize"; pub const BLOCKDEV_TOTAL_SIZE_ALLOCATED_PROP: &str = "TotalPhysicalSizeAllocated"; +pub const BLOCKDEV_TOTAL_REAL_SIZE_PROP: &str = "TotalPhysicalRealSize"; /// Get a list of all the FetchProperties interfaces pub fn fetch_properties_interfaces() -> Vec { diff --git a/src/engine/engine.rs b/src/engine/engine.rs index 991eb6e5cfe..6324efb1a11 100644 --- a/src/engine/engine.rs +++ b/src/engine/engine.rs @@ -109,6 +109,10 @@ pub trait BlockDev: Debug { /// The total number of sectors allocated from this block device fn allocated(&self) -> Sectors; + + /// The real size of this block device in sectors. Greater than or equal + /// to the value of size. + fn real_size(&self) -> Sectors; } pub trait Pool: Debug { diff --git a/src/engine/sim_engine/blockdev.rs b/src/engine/sim_engine/blockdev.rs index d700672ffc2..bf8dc47392e 100644 --- a/src/engine/sim_engine/blockdev.rs +++ b/src/engine/sim_engine/blockdev.rs @@ -73,6 +73,10 @@ impl BlockDev for SimDev { fn allocated(&self) -> Sectors { Bytes::from(IEC::Mi).sectors() } + + fn real_size(&self) -> Sectors { + 2usize * Bytes::from(IEC::Gi).sectors() + } } impl SimDev { diff --git a/src/engine/strat_engine/backstore/blockdev.rs b/src/engine/strat_engine/backstore/blockdev.rs index a446e23f0a9..fee1971c3a9 100644 --- a/src/engine/strat_engine/backstore/blockdev.rs +++ b/src/engine/strat_engine/backstore/blockdev.rs @@ -309,6 +309,10 @@ impl BlockDev for StratBlockDev { fn allocated(&self) -> Sectors { self.used.used() } + + fn real_size(&self) -> Sectors { + self.real_size.sectors() + } } impl Recordable for StratBlockDev {