factor in existing ec volume count when estimating max volume count

related to https://github.com/seaweedfs/seaweedfs/issues/5191
This commit is contained in:
chrislu 2024-01-11 08:19:09 -08:00
parent a7fc723ae0
commit 050efe6c08
2 changed files with 7 additions and 3 deletions

View file

@ -218,9 +218,13 @@ func (l *DiskLocation) unmountEcVolumeByCollection(collectionName string) map[ne
return deltaVols
}
func (l *DiskLocation) EcVolumesLen() int {
func (l *DiskLocation) EcShardCount() int {
l.ecVolumesLock.RLock()
defer l.ecVolumesLock.RUnlock()
return len(l.ecVolumes)
shardCount := 0
for _, ecVolume := range l.ecVolumes {
shardCount += len(ecVolume.Shards)
}
return shardCount
}

View file

@ -149,7 +149,7 @@ func (s *Store) FindFreeLocation(diskType DiskType) (ret *DiskLocation) {
}
currentFreeCount := location.MaxVolumeCount - int32(location.VolumesLen())
currentFreeCount *= erasure_coding.DataShardsCount
currentFreeCount -= int32(location.EcVolumesLen())
currentFreeCount -= int32(location.EcShardCount())
currentFreeCount /= erasure_coding.DataShardsCount
if currentFreeCount > max {
max = currentFreeCount