aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2021-03-05 09:35:56 -0800
committerGitHub <noreply@github.com>2021-03-05 09:35:56 -0800
commitecfe0ec253ce45623906ea348179506ec07d7844 (patch)
treecb657fa21b6a5f3968205ec37574fb35472c71fa
parent400de380f48c44c7700fdf7e8f247bf856662c10 (diff)
parent7413d59750686bc3fdc50ff7a687adfd002e1b63 (diff)
downloadseaweedfs-ecfe0ec253ce45623906ea348179506ec07d7844.tar.xz
seaweedfs-ecfe0ec253ce45623906ea348179506ec07d7844.zip
Merge pull request #1863 from Woellchen/fix-ec-shards-count
Fix EC shard count logic
-rw-r--r--weed/topology/data_node_ec.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/weed/topology/data_node_ec.go b/weed/topology/data_node_ec.go
index df1b6d658..330b16b24 100644
--- a/weed/topology/data_node_ec.go
+++ b/weed/topology/data_node_ec.go
@@ -25,7 +25,7 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
existingEcShards := dn.GetEcShards()
- // found out the newShards and deletedShards
+ // find out the newShards and deletedShards
var newShardCount, deletedShardCount int
for _, ecShards := range existingEcShards {
@@ -56,20 +56,19 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
disk.UpAdjustDiskUsageDelta(deltaDiskUsages)
}
+
for _, ecShards := range actualShards {
+ if dn.hasEcShards(ecShards.VolumeId) {
+ continue
+ }
+
+ newShards = append(newShards, ecShards)
disk := dn.getOrCreateDisk(ecShards.DiskType)
deltaDiskUsages := newDiskUsages()
deltaDiskUsage := deltaDiskUsages.getOrCreateDisk(types.ToDiskType(ecShards.DiskType))
-
- if !dn.hasEcShards(ecShards.VolumeId) {
- newShards = append(newShards, ecShards)
- newShardCount += ecShards.ShardIdCount()
- }
-
- deltaDiskUsage.ecShardCount = int64(newShardCount)
+ deltaDiskUsage.ecShardCount = int64(ecShards.ShardIdCount())
disk.UpAdjustDiskUsageDelta(deltaDiskUsages)
-
}
if len(newShards) > 0 || len(deletedShards) > 0 {