From 8cb6184f1d96f697f12ae9ede51d3b75c6eaf860 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Sat, 18 Jan 2020 23:21:58 +0100 Subject: [PATCH] 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()* --- cmd/xl-v1-multipart.go | 2 +- cmd/xl-v1-object.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/xl-v1-multipart.go b/cmd/xl-v1-multipart.go index 7de8b8d56..0db7e3567 100644 --- a/cmd/xl-v1-multipart.go +++ b/cmd/xl-v1-multipart.go @@ -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) { diff --git a/cmd/xl-v1-object.go b/cmd/xl-v1-object.go index 13dd50a2c..6daa6923a 100644 --- a/cmd/xl-v1-object.go +++ b/cmd/xl-v1-object.go @@ -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) {