Browse Source

Match Go FindFreeLocation: account for EC shards in free slot calculation

Go's free volume count subtracts both regular volumes and EC volumes
from max_volume_count. Rust was only counting regular volumes, which
could over-report available slots when EC shards are mounted.
rust-volume-server
Chris Lu 3 days ago
parent
commit
819b95bc37
  1. 4
      seaweed-volume/src/storage/disk_location.rs

4
seaweed-volume/src/storage/disk_location.rs

@ -447,9 +447,11 @@ impl DiskLocation {
} }
/// Number of free volume slots. /// Number of free volume slots.
/// Matches Go's FindFreeLocation: accounts for both regular volumes
/// and EC shards when computing available slots.
pub fn free_volume_count(&self) -> i32 { pub fn free_volume_count(&self) -> i32 {
let max = self.max_volume_count.load(Ordering::Relaxed); let max = self.max_volume_count.load(Ordering::Relaxed);
let used = self.volumes.len() as i32;
let used = self.volumes.len() as i32 + self.ec_volumes.len() as i32;
if max > used { if max > used {
max - used max - used
} else { } else {

Loading…
Cancel
Save