From 819b95bc37b485a7bebfdb1136980f16c1fc018e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 17 Mar 2026 16:12:00 -0700 Subject: [PATCH] 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. --- seaweed-volume/src/storage/disk_location.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/seaweed-volume/src/storage/disk_location.rs b/seaweed-volume/src/storage/disk_location.rs index e619bb82a..f7c02f500 100644 --- a/seaweed-volume/src/storage/disk_location.rs +++ b/seaweed-volume/src/storage/disk_location.rs @@ -447,9 +447,11 @@ impl DiskLocation { } /// 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 { 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 { max - used } else {