Browse Source

refactor: rename MaxShardId to MaxShardCount for clarity

- Change from MaxShardId=31 to MaxShardCount=32
- Eliminates confusing +1 arithmetic (MaxShardId+1)
- More intuitive: MaxShardCount directly represents the limit

fix: support custom EC ratios beyond 14 shards in VolumeEcShardsToVolume

- Add MaxShardId constant (31, since ShardBits is uint32)
- Use MaxShardId+1 (32) instead of TotalShardsCount (14) for tempShards buffer
- Prevents panic when slicing for volumes with >14 total shards
- Critical fix for custom EC configurations like 20+10
pull/7396/head
chrislu 1 month ago
parent
commit
57556041c8
  1. 3
      weed/server/volume_grpc_erasure_coding.go
  2. 4
      weed/storage/erasure_coding/ec_volume_info.go

3
weed/server/volume_grpc_erasure_coding.go

@ -454,7 +454,8 @@ func (vs *VolumeServer) VolumeEcShardsToVolume(ctx context.Context, req *volume_
glog.V(0).Infof("VolumeEcShardsToVolume: %v", req)
// Collect all EC shards (NewEcVolume will load EC config from .vif into v.ECContext)
tempShards := make([]string, erasure_coding.TotalShardsCount)
// Use MaxShardCount (32) to support custom EC ratios up to 32 total shards
tempShards := make([]string, erasure_coding.MaxShardCount)
v, found := vs.store.CollectEcShards(needle.VolumeId(req.VolumeId), tempShards)
if !found {
return nil, fmt.Errorf("ec volume %d not found", req.VolumeId)

4
weed/storage/erasure_coding/ec_volume_info.go

@ -118,6 +118,10 @@ func (ecInfo *EcVolumeInfo) ToVolumeEcShardInformationMessage() (ret *master_pb.
type ShardBits uint32 // use bits to indicate the shard id, use 32 bits just for possible future extension
const (
MaxShardCount = 32 // Maximum number of shards since ShardBits is uint32 (bits 0-31)
)
func (b ShardBits) AddShardId(id ShardId) ShardBits {
return b | (1 << id)
}

Loading…
Cancel
Save