volume: fix ec shard reading

fix https://github.com/chrislusf/seaweedfs/issues/1106
This commit is contained in:
Chris Lu 2019-11-08 22:40:28 -08:00
parent 926abf9115
commit 6cc9e0d788

View file

@ -252,9 +252,14 @@ func (vs *VolumeServer) VolumeEcShardRead(req *volume_server_pb.VolumeEcShardRea
startOffset, bytesToRead := req.Offset, req.Size startOffset, bytesToRead := req.Offset, req.Size
for bytesToRead > 0 { for bytesToRead > 0 {
bytesread, err := ecShard.ReadAt(buffer, startOffset) // min of bytesToRead and bufSize
bufferSize := bufSize
if bufferSize > bytesToRead {
bufferSize = bytesToRead
}
bytesread, err := ecShard.ReadAt(buffer[0:bufferSize], startOffset)
// println(fileName, "read", bytesread, "bytes, with target", bytesToRead) // println("read", ecShard.FileName(), "startOffset", startOffset, bytesread, "bytes, with target", bufferSize)
if bytesread > 0 { if bytesread > 0 {
if int64(bytesread) > bytesToRead { if int64(bytesread) > bytesToRead {
@ -268,6 +273,7 @@ func (vs *VolumeServer) VolumeEcShardRead(req *volume_server_pb.VolumeEcShardRea
return err return err
} }
startOffset += int64(bytesread)
bytesToRead -= int64(bytesread) bytesToRead -= int64(bytesread)
} }