From 88f30b511b1a804e713b2b573694fe5af224f277 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 7 Jun 2021 18:15:41 -0400 Subject: [PATCH] Expose the allocated information for the block device Signed-off-by: mulhern --- src/engine/engine.rs | 3 +++ src/engine/sim_engine/blockdev.rs | 4 ++++ src/engine/strat_engine/backstore/blockdev.rs | 9 ++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/engine/engine.rs b/src/engine/engine.rs index f318278274..cff7c6fb01 100644 --- a/src/engine/engine.rs +++ b/src/engine/engine.rs @@ -103,6 +103,9 @@ pub trait BlockDev: Debug { /// Get the status of whether a block device is encrypted or not. fn is_encrypted(&self) -> bool; + + /// The total number of sectors allocated from this block device + fn allocated(&self) -> Sectors; } pub trait Pool: Debug { diff --git a/src/engine/sim_engine/blockdev.rs b/src/engine/sim_engine/blockdev.rs index 067a7e5b18..485d348a5d 100644 --- a/src/engine/sim_engine/blockdev.rs +++ b/src/engine/sim_engine/blockdev.rs @@ -59,6 +59,10 @@ impl BlockDev for SimDev { fn is_encrypted(&self) -> bool { self.encryption_info.is_some() } + + fn allocated(&self) -> Sectors { + Bytes::from(IEC::Mi).sectors() + } } impl SimDev { diff --git a/src/engine/strat_engine/backstore/blockdev.rs b/src/engine/strat_engine/backstore/blockdev.rs index 2c4c61bb25..0c2e26ab06 100644 --- a/src/engine/strat_engine/backstore/blockdev.rs +++ b/src/engine/strat_engine/backstore/blockdev.rs @@ -199,11 +199,6 @@ impl StratBlockDev { self.used.available() } - /// The number of Sectors on this device which have been allocated. - pub fn used(&self) -> Sectors { - self.used.used() - } - /// The total size of the Stratis block device. pub fn total_size(&self) -> BlockdevSize { let size = self.used.size(); @@ -345,6 +340,10 @@ impl BlockDev for StratBlockDev { fn is_encrypted(&self) -> bool { self.encryption_info().is_some() } + + fn allocated(&self) -> Sectors { + self.used.used() + } } impl Recordable for StratBlockDev {