Merge pull request #1863 from Woellchen/fix-ec-shards-count

Fix EC shard count logic
This commit is contained in:
Chris Lu 2021-03-05 09:35:56 -08:00 committed by GitHub
commit ecfe0ec253
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,7 +25,7 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
existingEcShards := dn.GetEcShards() existingEcShards := dn.GetEcShards()
// found out the newShards and deletedShards // find out the newShards and deletedShards
var newShardCount, deletedShardCount int var newShardCount, deletedShardCount int
for _, ecShards := range existingEcShards { for _, ecShards := range existingEcShards {
@ -56,20 +56,19 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
disk.UpAdjustDiskUsageDelta(deltaDiskUsages) disk.UpAdjustDiskUsageDelta(deltaDiskUsages)
} }
for _, ecShards := range actualShards { for _, ecShards := range actualShards {
if dn.hasEcShards(ecShards.VolumeId) {
continue
}
newShards = append(newShards, ecShards)
disk := dn.getOrCreateDisk(ecShards.DiskType) disk := dn.getOrCreateDisk(ecShards.DiskType)
deltaDiskUsages := newDiskUsages() deltaDiskUsages := newDiskUsages()
deltaDiskUsage := deltaDiskUsages.getOrCreateDisk(types.ToDiskType(ecShards.DiskType)) deltaDiskUsage := deltaDiskUsages.getOrCreateDisk(types.ToDiskType(ecShards.DiskType))
deltaDiskUsage.ecShardCount = int64(ecShards.ShardIdCount())
if !dn.hasEcShards(ecShards.VolumeId) {
newShards = append(newShards, ecShards)
newShardCount += ecShards.ShardIdCount()
}
deltaDiskUsage.ecShardCount = int64(newShardCount)
disk.UpAdjustDiskUsageDelta(deltaDiskUsages) disk.UpAdjustDiskUsageDelta(deltaDiskUsages)
} }
if len(newShards) > 0 || len(deletedShards) > 0 { if len(newShards) > 0 || len(deletedShards) > 0 {