This commit is contained in:
chrislu
2024-11-19 08:32:31 -08:00
parent 98f03862aa
commit e28f55eb08

View File

@@ -226,29 +226,29 @@ func (c *commandFsMergeVolumes) createMergePlan(collection string, toVolumeId ne
continue continue
} }
for j := 0; j < i; j++ { for j := 0; j < i; j++ {
condidate := volumeIds[j] candidate := volumeIds[j]
if toVolumeId != 0 && condidate != toVolumeId { if toVolumeId != 0 && candidate != toVolumeId {
continue continue
} }
if _, moving := plan[condidate]; moving { if _, moving := plan[candidate]; moving {
continue continue
} }
compatible, err := c.volumesAreCompatible(src, condidate) compatible, err := c.volumesAreCompatible(src, candidate)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !compatible { if !compatible {
fmt.Printf("volume %d is not compatible with volume %d\n", src, condidate) fmt.Printf("volume %d is not compatible with volume %d\n", src, candidate)
continue continue
} }
if c.getVolumeSizeBasedOnPlan(plan, condidate)+c.getVolumeSizeById(src) > c.volumeSizeLimit { if c.getVolumeSizeBasedOnPlan(plan, candidate)+c.getVolumeSizeById(src) > c.volumeSizeLimit {
fmt.Printf("volume %d (%d MB) merge into volume %d (%d MB) exceeds volume size limit (%d MB)\n", fmt.Printf("volume %d (%d MB) merge into volume %d (%d MB) exceeds volume size limit (%d MB)\n",
src, c.getVolumeSizeById(src)/1024/1024, src, c.getVolumeSizeById(src)/1024/1024,
condidate, c.getVolumeSizeById(condidate)/1024/1024, candidate, c.getVolumeSizeById(candidate)/1024/1024,
c.volumeSizeLimit/1024/1024) c.volumeSizeLimit/1024/1024)
continue continue
} }
plan[src] = condidate plan[src] = candidate
break break
} }
} }