diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-06-05 23:20:26 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-06-05 23:20:26 -0700 |
| commit | d344e0a035985ce7a28a6f7a4499199ef27aeda3 (patch) | |
| tree | 77f094232aab9c2e767adb05f81c4e7a9453c2e2 /weed/shell | |
| parent | 450f4733cec38ec31c66b296749e2d0b14e91218 (diff) | |
| download | seaweedfs-d344e0a035985ce7a28a6f7a4499199ef27aeda3.tar.xz seaweedfs-d344e0a035985ce7a28a6f7a4499199ef27aeda3.zip | |
fix ec related bugs
Diffstat (limited to 'weed/shell')
| -rw-r--r-- | weed/shell/command_ec_balance.go | 25 | ||||
| -rw-r--r-- | weed/shell/command_ec_common.go | 9 | ||||
| -rw-r--r-- | weed/shell/command_ec_rebuild.go | 2 |
3 files changed, 35 insertions, 1 deletions
diff --git a/weed/shell/command_ec_balance.go b/weed/shell/command_ec_balance.go index 424b63d9d..4edf94711 100644 --- a/weed/shell/command_ec_balance.go +++ b/weed/shell/command_ec_balance.go @@ -199,6 +199,7 @@ func doDeduplicateEcShards(ctx context.Context, commandEnv *CommandEnv, collecti if err := sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, ecNode.info.Id, duplicatedShardIds); err != nil { return err } + deleteEcVolumeShards(ecNode, vid, duplicatedShardIds) ecNode.freeEcSlot++ } } @@ -273,3 +274,27 @@ func findEcVolumeShards(ecNode *EcNode, vid needle.VolumeId) erasure_coding.Shar return 0 } + +func addEcVolumeShards(ecNode *EcNode, vid needle.VolumeId, shardIds []uint32){ + + for _, shardInfo := range ecNode.info.EcShardInfos { + if needle.VolumeId(shardInfo.Id) == vid { + for _, shardId := range shardIds{ + shardInfo.EcIndexBits = uint32(erasure_coding.ShardBits(shardInfo.EcIndexBits).AddShardId(erasure_coding.ShardId(shardId))) + } + } + } + +} + +func deleteEcVolumeShards(ecNode *EcNode, vid needle.VolumeId, shardIds []uint32){ + + for _, shardInfo := range ecNode.info.EcShardInfos { + if needle.VolumeId(shardInfo.Id) == vid { + for _, shardId := range shardIds{ + shardInfo.EcIndexBits = uint32(erasure_coding.ShardBits(shardInfo.EcIndexBits).RemoveShardId(erasure_coding.ShardId(shardId))) + } + } + } + +} diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go index 4c53ba43b..041715908 100644 --- a/weed/shell/command_ec_common.go +++ b/weed/shell/command_ec_common.go @@ -35,7 +35,14 @@ func moveMountedShardToEcNode(ctx context.Context, commandEnv *CommandEnv, exist } // ask source node to delete the shard, and maybe the ecx file - return sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, existingLocation.info.Id, copiedShardIds) + err = sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, existingLocation.info.Id, copiedShardIds) + if err != nil { + return err + } + + deleteEcVolumeShards(existingLocation, vid, copiedShardIds) + + return nil } diff --git a/weed/shell/command_ec_rebuild.go b/weed/shell/command_ec_rebuild.go index 9a5ea3ca9..20929d76c 100644 --- a/weed/shell/command_ec_rebuild.go +++ b/weed/shell/command_ec_rebuild.go @@ -163,6 +163,8 @@ func rebuildOneEcVolume(ctx context.Context, commandEnv *CommandEnv, rebuilder * return err } + addEcVolumeShards(rebuilder, volumeId, generatedShardIds) + return nil } |
