Skip to content

Commit

Permalink
Incorporate filesystem size limit into fileystem extension
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaublitz committed Sep 29, 2023
1 parent 3c83d8f commit 2092263
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/engine/strat_engine/thinpool/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,24 @@ impl StratFilesystem {
}

/// Return an extend size for the thindev under the filesystem
pub fn extend_size(current_size: Sectors, remaining_size: Option<&mut Sectors>) -> Sectors {
if let Some(rem_size) = remaining_size {
// Extend either by the remaining amount left before the data device
// overprovisioning limit is reached if it is less than the size of the
// filesystem or double the filesystem size.
let extend_size = min(*rem_size, current_size);
*rem_size -= extend_size;
extend_size
} else {
current_size
pub fn extend_size(
current_size: Sectors,
no_op_remaining_size: Option<&mut Sectors>,
fs_limit_remaining_size: Option<Sectors>,
) -> Sectors {
match (no_op_remaining_size, fs_limit_remaining_size) {
(Some(no_op_rem_size), Some(fs_lim_rem_size)) => {
let extend_size = min(min(*no_op_rem_size, current_size), fs_lim_rem_size);
*no_op_rem_size -= extend_size;
extend_size
}
(Some(no_op_rem_size), None) => {
let extend_size = min(*no_op_rem_size, current_size);
*no_op_rem_size -= extend_size;
extend_size
}
(None, Some(fs_lim_rem_size)) => min(fs_lim_rem_size, current_size),
(_, _) => current_size,
}
}

Expand Down Expand Up @@ -382,6 +390,10 @@ impl StratFilesystem {
Ok(ret_vec)
}

pub fn size_limit(&self) -> Option<Sectors> {
self.size_limit
}

pub fn thindev_size(&self) -> Sectors {
self.thin_dev.size()
}
Expand Down
1 change: 1 addition & 0 deletions src/engine/strat_engine/thinpool/thinpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ impl ThinPool {
let extend_size = StratFilesystem::extend_size(
fs.thindev_size(),
remaining_space.as_mut(),
fs.size_limit().map(|sl| sl - fs.thindev_size()),
);
if extend_size == Sectors(0) {
None
Expand Down

0 comments on commit 2092263

Please sign in to comment.