From 7c47cf5b02f43c170329a5fa0c95b1b038ebd84c Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 29 Aug 2024 09:53:16 -0400 Subject: [PATCH] Remove unnecessary mut modifiers and assignments Signed-off-by: mulhern --- .../strat_engine/backstore/cache_tier.rs | 36 ++++++++++--------- .../strat_engine/backstore/data_tier.rs | 22 ++++++------ 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/engine/strat_engine/backstore/cache_tier.rs b/src/engine/strat_engine/backstore/cache_tier.rs index d25b333546..c520ebc030 100644 --- a/src/engine/strat_engine/backstore/cache_tier.rs +++ b/src/engine/strat_engine/backstore/cache_tier.rs @@ -410,12 +410,14 @@ mod tests { // the tier. let cache_metadata_size = cache_tier.meta_segments.size(); - let mut metadata_size = cache_tier.block_mgr.metadata_size(); - let mut size = cache_tier.block_mgr.size(); - let mut allocated = cache_tier.cache_segments.size(); + let metadata_size = cache_tier.block_mgr.metadata_size(); + let size = cache_tier.block_mgr.size(); assert_eq!(cache_tier.block_mgr.avail_space(), Sectors(0)); - assert_eq!(size - metadata_size, allocated + cache_metadata_size); + assert_eq!( + size - metadata_size, + cache_tier.cache_segments.size() + cache_metadata_size + ); let (_, (cache, meta)) = cache_tier .add(pool_name, pool_uuid, devices2, None) @@ -429,10 +431,10 @@ mod tests { assert!(cache_tier.block_mgr.size() > size); assert!(cache_tier.block_mgr.metadata_size() > metadata_size); - metadata_size = cache_tier.block_mgr.metadata_size(); - size = cache_tier.block_mgr.size(); - allocated = cache_tier.cache_segments.size(); - assert_eq!(size - metadata_size, allocated + cache_metadata_size); + assert_eq!( + cache_tier.block_mgr.size() - cache_tier.block_mgr.metadata_size(), + cache_tier.cache_segments.size() + cache_metadata_size + ); cache_tier.destroy().unwrap(); } @@ -481,12 +483,14 @@ mod tests { // the tier. let cache_metadata_size = cache_tier.meta_segments.size(); - let mut metadata_size = cache_tier.block_mgr.metadata_size(); - let mut size = cache_tier.block_mgr.size(); - let mut allocated = cache_tier.cache_segments.size(); + let metadata_size = cache_tier.block_mgr.metadata_size(); + let size = cache_tier.block_mgr.size(); assert_eq!(cache_tier.block_mgr.avail_space(), Sectors(0)); - assert_eq!(size - metadata_size, allocated + cache_metadata_size); + assert_eq!( + size - metadata_size, + cache_tier.cache_segments.size() + cache_metadata_size + ); let (_, (cache, meta)) = cache_tier.add(pool_uuid, devices2).unwrap(); cache_tier.invariant(); @@ -498,10 +502,10 @@ mod tests { assert!(cache_tier.block_mgr.size() > size); assert!(cache_tier.block_mgr.metadata_size() > metadata_size); - metadata_size = cache_tier.block_mgr.metadata_size(); - size = cache_tier.block_mgr.size(); - allocated = cache_tier.cache_segments.size(); - assert_eq!(size - metadata_size, allocated + cache_metadata_size); + assert_eq!( + cache_tier.block_mgr.size() - cache_tier.block_mgr.metadata_size(), + cache_tier.cache_segments.size() + cache_metadata_size + ); cache_tier.destroy().unwrap(); } diff --git a/src/engine/strat_engine/backstore/data_tier.rs b/src/engine/strat_engine/backstore/data_tier.rs index ec0cce5fc9..2fb17c414f 100644 --- a/src/engine/strat_engine/backstore/data_tier.rs +++ b/src/engine/strat_engine/backstore/data_tier.rs @@ -363,9 +363,8 @@ mod tests { data_tier.invariant(); // A data_tier w/ some devices but nothing allocated - let mut size = data_tier.size(); - let mut allocated = data_tier.allocated(); - assert_eq!(allocated, Sectors(0)); + let size = data_tier.size(); + assert_eq!(data_tier.allocated(), Sectors(0)); assert!(size != Sectors(0)); let last_request_amount = size; @@ -379,7 +378,8 @@ mod tests { // A data tier w/ some amount allocated assert!(data_tier.allocated() >= request_amount); assert_eq!(data_tier.size(), size); - allocated = data_tier.allocated(); + + let allocated = data_tier.allocated(); data_tier.add(pool_name, pool_uuid, devices2, None).unwrap(); data_tier.invariant(); @@ -388,7 +388,8 @@ mod tests { assert!(data_tier.size() > size); assert_eq!(data_tier.allocated(), allocated); assert_eq!(paths.len(), data_tier.blockdevs().len()); - size = data_tier.size(); + + let size = data_tier.size(); // Allocate enough to get into the newly added block devices assert!(data_tier.alloc(&[last_request_amount])); @@ -444,9 +445,8 @@ mod tests { data_tier.invariant(); // A data_tier w/ some devices but nothing allocated - let mut size = data_tier.size(); - let mut allocated = data_tier.allocated(); - assert_eq!(allocated, Sectors(0)); + let size = data_tier.size(); + assert_eq!(data_tier.allocated(), Sectors(0)); assert!(size != Sectors(0)); let last_request_amount = size; @@ -460,7 +460,8 @@ mod tests { // A data tier w/ some amount allocated assert!(data_tier.allocated() >= request_amount); assert_eq!(data_tier.size(), size); - allocated = data_tier.allocated(); + + let allocated = data_tier.allocated(); data_tier.add(pool_uuid, devices2).unwrap(); data_tier.invariant(); @@ -469,7 +470,8 @@ mod tests { assert!(data_tier.size() > size); assert_eq!(data_tier.allocated(), allocated); assert_eq!(paths.len(), data_tier.blockdevs().len()); - size = data_tier.size(); + + let size = data_tier.size(); // Allocate enough to get into the newly added block devices assert!(data_tier.alloc(&[last_request_amount]));