Skip to content

Commit

Permalink
Merge pull request #3681 from mulkieran/remove-unnecessary-mut-modifiers
Browse files Browse the repository at this point in the history
Remove unnecessary mut modifiers and assignments
  • Loading branch information
mulkieran authored Aug 29, 2024
2 parents 26e647b + 7c47cf5 commit de10442
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
36 changes: 20 additions & 16 deletions src/engine/strat_engine/backstore/cache_tier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
}
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down
22 changes: 12 additions & 10 deletions src/engine/strat_engine/backstore/data_tier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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]));
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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]));
Expand Down

0 comments on commit de10442

Please sign in to comment.