fix ec.rebuild bugs

This commit is contained in:
Chris Lu 2019-06-03 11:50:54 -07:00
parent d85b41b904
commit 11cffb3168
2 changed files with 3 additions and 4 deletions

View file

@ -68,6 +68,7 @@ func (vs *VolumeServer) VolumeEcShardsRebuild(ctx context.Context, req *volume_s
for _, location := range vs.store.Locations {
if util.FileExists(path.Join(location.Directory, baseFileName+".ecx")) {
// write .ec01 ~ .ec14 files
baseFileName = path.Join(location.Directory, baseFileName)
if generatedShardIds, err := erasure_coding.RebuildEcFiles(baseFileName); err != nil {
return nil, fmt.Errorf("RebuildEcFiles %s: %v", baseFileName, err)
} else {

View file

@ -249,19 +249,17 @@ func rebuildEcFiles(shardHasData []bool, inputFiles []*os.File, outputFiles []*o
if n == 0 {
return nil
}
if inputBufferDataSize != 0 {
if inputBufferDataSize == 0 {
inputBufferDataSize = n
}
if inputBufferDataSize != n {
return fmt.Errorf("ec shard size need to be the same")
return fmt.Errorf("ec shard size expected %d actual %d", inputBufferDataSize, n)
}
} else {
buffers[i] = nil
}
}
fmt.Printf("reconstructing [%d,%d)\n", startOffset, startOffset+int64(inputBufferDataSize))
// encode the data
err = enc.Reconstruct(buffers)
if err != nil {