From a18f62bbe7e5e477fd891849b44ec5a25d8988d2 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 23 Dec 2019 18:06:13 -0800 Subject: [PATCH] only copy required shards --- weed/shell/command_ec_decode.go | 2 +- weed/storage/erasure_coding/ec_volume_info.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/weed/shell/command_ec_decode.go b/weed/shell/command_ec_decode.go index 5ea359b2b..4ec1a7e8f 100644 --- a/weed/shell/command_ec_decode.go +++ b/weed/shell/command_ec_decode.go @@ -164,7 +164,7 @@ func collectEcShards(ctx context.Context, commandEnv *CommandEnv, nodeToEcIndexB continue } - needToCopyEcIndexBits := ecIndexBits.Minus(exisitngEcIndexBits) + needToCopyEcIndexBits := ecIndexBits.Minus(exisitngEcIndexBits).MinusParityShards() if needToCopyEcIndexBits.ShardIdCount() == 0 { continue } diff --git a/weed/storage/erasure_coding/ec_volume_info.go b/weed/storage/erasure_coding/ec_volume_info.go index bb1fd0bf8..8ff65bb0f 100644 --- a/weed/storage/erasure_coding/ec_volume_info.go +++ b/weed/storage/erasure_coding/ec_volume_info.go @@ -104,3 +104,10 @@ func (b ShardBits) Minus(other ShardBits) ShardBits { func (b ShardBits) Plus(other ShardBits) ShardBits { return b | other } + +func (b ShardBits) MinusParityShards() ShardBits { + for i := DataShardsCount; i < TotalShardsCount; i++ { + b = b.RemoveShardId(ShardId(i)) + } + return b +}