Fix EC rebuild shard detection (#8265)

Fix EC rebuild shard counting
This commit is contained in:
Chris Lu
2026-02-09 12:34:38 -08:00
committed by GitHub
parent 1a5679a5eb
commit 839028b2e0
2 changed files with 76 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import (
"math"
"os"
"path"
"strconv"
"strings"
"time"
@@ -338,13 +339,30 @@ func checkEcVolumeStatus(bName string, location *storage.DiskLocation) (hasEcxFi
hasIdxFile = true
continue
}
if strings.HasPrefix(fileInfo.Name(), bName+".ec") {
if isEcDataShardFile(fileInfo.Name(), bName) {
existingShardCount++
}
}
return hasEcxFile, hasIdxFile, existingShardCount, nil
}
func isEcDataShardFile(fileName, baseName string) bool {
const ecDataShardSuffixLen = 2 // ".ecNN"
prefix := baseName + ".ec"
if !strings.HasPrefix(fileName, prefix) {
return false
}
suffix := strings.TrimPrefix(fileName, prefix)
if len(suffix) != ecDataShardSuffixLen {
return false
}
shardId, err := strconv.Atoi(suffix)
if err != nil {
return false
}
return shardId >= 0 && shardId < erasure_coding.MaxShardCount
}
func (vs *VolumeServer) VolumeEcShardsMount(ctx context.Context, req *volume_server_pb.VolumeEcShardsMountRequest) (*volume_server_pb.VolumeEcShardsMountResponse, error) {
glog.V(0).Infof("VolumeEcShardsMount: %v", req)