mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume: fix ec shard reading
fix https://github.com/chrislusf/seaweedfs/issues/1106
This commit is contained in:
parent
926abf9115
commit
6cc9e0d788
|
@ -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)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue