From b7aa9921c5b60b1da159c16c38f62da59ed41eb3 Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 9 Jul 2024 21:15:06 -0400 Subject: [PATCH 1/2] Return true from extend_thin_meta_device less Return true only if the method returned without error AND the amount to extend is non-zero. This is the same condition already used in extend_thin_data_device. Signed-off-by: mulhern --- src/engine/strat_engine/thinpool/thinpool.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index 93bf3312af..29ea5e05cd 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -1117,7 +1117,10 @@ impl ThinPool { meta_growth, ); - (ext.is_ok(), ext) + match ext { + Ok(Sectors(0)) | Err(_) => (false, ext), + Ok(_) => (true, ext), + } } else { (false, Ok(Sectors(0))) } From d7c94f808be13823391773692bb723bd139f41d3 Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 10 Jul 2024 22:22:03 -0400 Subject: [PATCH 2/2] Eliminate pre-check for not enough space on do_extend alloc() return None if there is not enough space to satisfy the request. Signed-off-by: mulhern --- src/engine/strat_engine/thinpool/thinpool.rs | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index 29ea5e05cd..7d51c0d5cc 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -1098,16 +1098,7 @@ impl ThinPool { } } - if 2u64 * meta_growth > backstore.available_in_backstore() { - self.out_of_meta_space = true; - ( - self.set_error_mode(), - Err(StratisError::Msg( - "Not enough unallocated space available on the pool to extend metadata device" - .to_string(), - )), - ) - } else if meta_growth > Sectors(0) { + if meta_growth > Sectors(0) { let ext = do_extend( &mut self.thin_pool, backstore, @@ -1118,8 +1109,17 @@ impl ThinPool { ); match ext { - Ok(Sectors(0)) | Err(_) => (false, ext), + Ok(Sectors(0)) => { + self.out_of_meta_space = true; + ( + self.set_error_mode(), + Err(StratisError::Msg( + "Not enough unallocated space available on the pool to extend metadata device".to_string(), + )), + ) + } Ok(_) => (true, ext), + Err(_) => (false, ext), } } else { (false, Ok(Sectors(0)))