Skip to content

Commit

Permalink
Expose the allocated information for the block device
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Aug 20, 2021
1 parent 9a676e9 commit 88f30b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/engine/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/engine/sim_engine/blockdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions src/engine/strat_engine/backstore/blockdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<BaseBlockDevSave> for StratBlockDev {
Expand Down

0 comments on commit 88f30b5

Please sign in to comment.