diff --git a/src/engine/strat_engine/thinpool/filesystem.rs b/src/engine/strat_engine/thinpool/filesystem.rs index 8d516c4f882..2687167242b 100644 --- a/src/engine/strat_engine/thinpool/filesystem.rs +++ b/src/engine/strat_engine/thinpool/filesystem.rs @@ -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 { + 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, } } @@ -382,6 +390,10 @@ impl StratFilesystem { Ok(ret_vec) } + pub fn size_limit(&self) -> Option { + self.size_limit + } + pub fn thindev_size(&self) -> Sectors { self.thin_dev.size() } diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index 5a2a701aff1..e274a37492a 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -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