mirror of
https://github.com/minio/minio.git
synced 2025-11-10 22:10:12 -05:00
xl: ReedSolomon code fix small file erasure bug. (#1431)
For files less than 'dataBlocks', erasure encoding would fail with short data due to a bug in the implementation itself. Relax the error return, even a single byte can be properly erasure coded without issues. Fixes #1413
This commit is contained in:
11
vendor/github.com/klauspost/reedsolomon/reedsolomon.go
generated
vendored
11
vendor/github.com/klauspost/reedsolomon/reedsolomon.go
generated
vendored
@@ -57,8 +57,8 @@ type Encoder interface {
|
||||
// If the data size isn't dividable by the number of shards,
|
||||
// the last shard will contain extra zeros.
|
||||
//
|
||||
// There must be at least the same number of bytes as there are data shards,
|
||||
// otherwise ErrShortData will be returned.
|
||||
// There must be at least 1 byte otherwise ErrShortData will be
|
||||
// returned.
|
||||
//
|
||||
// The data will not be copied, except for the last shard, so you
|
||||
// should not modify the data of the input slice afterwards.
|
||||
@@ -457,16 +457,15 @@ var ErrShortData = errors.New("not enough data to fill the number of requested s
|
||||
// If the data size isn't divisible by the number of shards,
|
||||
// the last shard will contain extra zeros.
|
||||
//
|
||||
// There must be at least the same number of bytes as there are data shards,
|
||||
// otherwise ErrShortData will be returned.
|
||||
// There must be at least 1 byte otherwise ErrShortData will be
|
||||
// returned.
|
||||
//
|
||||
// The data will not be copied, except for the last shard, so you
|
||||
// should not modify the data of the input slice afterwards.
|
||||
func (r reedSolomon) Split(data []byte) ([][]byte, error) {
|
||||
if len(data) < r.DataShards {
|
||||
if len(data) == 0 {
|
||||
return nil, ErrShortData
|
||||
}
|
||||
|
||||
// Calculate number of bytes per shard.
|
||||
perShard := (len(data) + r.DataShards - 1) / r.DataShards
|
||||
|
||||
|
||||
Reference in New Issue
Block a user