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()*
master
Klaus Post 5 years ago committed by Harshavardhana
parent b849fd7a75
commit 8cb6184f1d
  1. 2
      cmd/xl-v1-multipart.go
  2. 2
      cmd/xl-v1-object.go

@ -353,7 +353,7 @@ func (xl xlObjects) PutObjectPart(ctx context.Context, bucket, object, uploadID
defer xl.bp.Put(buffer) defer xl.bp.Put(buffer)
case size < blockSizeV1: case size < blockSizeV1:
// No need to allocate fully blockSizeV1 buffer if the incoming data is smaller. // 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) { if len(buffer) > int(xlMeta.Erasure.BlockSize) {

@ -559,7 +559,7 @@ func (xl xlObjects) putObject(ctx context.Context, bucket string, object string,
defer xl.bp.Put(buffer) defer xl.bp.Put(buffer)
case size < blockSizeV1: case size < blockSizeV1:
// No need to allocate fully blockSizeV1 buffer if the incoming data is smaller. // 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) { if len(buffer) > int(xlMeta.Erasure.BlockSize) {

Loading…
Cancel
Save