Browse Source

factor in existing ec volume count when estimating max volume count

related to https://github.com/seaweedfs/seaweedfs/issues/5191
pull/5198/head
chrislu 12 months ago
parent
commit
050efe6c08
  1. 8
      weed/storage/disk_location_ec.go
  2. 2
      weed/storage/store.go

8
weed/storage/disk_location_ec.go

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

2
weed/storage/store.go

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

Loading…
Cancel
Save