Fix erasure block allocation (#8851)

Small blocks are undersized when file size isn't divisible by the 
shard could leading to allocation in *reedsolomon.Split()*
This commit is contained in:
Klaus Post 2020-01-18 23:21:58 +01:00 committed by Harshavardhana
parent b849fd7a75
commit 8cb6184f1d
2 changed files with 2 additions and 2 deletions

View File

@ -353,7 +353,7 @@ func (xl xlObjects) PutObjectPart(ctx context.Context, bucket, object, uploadID
defer xl.bp.Put(buffer)
case size < blockSizeV1:
// No need to allocate fully blockSizeV1 buffer if the incoming data is smaller.
buffer = make([]byte, size, 2*size)
buffer = make([]byte, size, 2*size+int64(erasure.parityBlocks+erasure.dataBlocks-1))
}
if len(buffer) > int(xlMeta.Erasure.BlockSize) {

View File

@ -559,7 +559,7 @@ func (xl xlObjects) putObject(ctx context.Context, bucket string, object string,
defer xl.bp.Put(buffer)
case size < blockSizeV1:
// No need to allocate fully blockSizeV1 buffer if the incoming data is smaller.
buffer = make([]byte, size, 2*size)
buffer = make([]byte, size, 2*size+int64(erasure.parityBlocks+erasure.dataBlocks-1))
}
if len(buffer) > int(xlMeta.Erasure.BlockSize) {