mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 04:00:25 +03:00
Storage erasure encoding info at StorageEntry and also store CRC at blockheader
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"path"
|
||||
"strconv"
|
||||
|
||||
"github.com/minio-io/minio/pkgs/checksum/crc32c"
|
||||
"github.com/minio-io/minio/pkgs/storage"
|
||||
)
|
||||
|
||||
@@ -96,6 +97,10 @@ func (aStorage *appendStorage) Put(objectPath string, object io.Reader) error {
|
||||
}
|
||||
header.Offset = offset
|
||||
header.Length = len(objectBytes)
|
||||
header.Crc, err = crc32c.Crc32c(objectBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aStorage.objects[objectPath] = header
|
||||
var mapBuffer bytes.Buffer
|
||||
encoder := gob.NewEncoder(&mapBuffer)
|
||||
|
||||
@@ -28,9 +28,8 @@ type encodedStorage struct {
|
||||
type StorageEntry struct {
|
||||
Path string
|
||||
Md5sum string
|
||||
Crc uint32
|
||||
Blocks []StorageBlockEntry
|
||||
Encoderparams *erasure.EncoderParams
|
||||
Encoderparams erasure.EncoderParams
|
||||
}
|
||||
|
||||
type StorageBlockEntry struct {
|
||||
@@ -109,11 +108,14 @@ func (eStorage *encodedStorage) Put(objectPath string, object io.Reader) error {
|
||||
}
|
||||
encoder := erasure.NewEncoder(encoderParameters)
|
||||
entry := StorageEntry{
|
||||
Path: objectPath,
|
||||
Md5sum: "md5sum",
|
||||
Crc: 0,
|
||||
Blocks: make([]StorageBlockEntry, 0),
|
||||
Encoderparams: encoderParameters,
|
||||
Path: objectPath,
|
||||
Md5sum: "md5sum",
|
||||
Blocks: make([]StorageBlockEntry, 0),
|
||||
Encoderparams: erasure.EncoderParams{
|
||||
K: eStorage.K,
|
||||
M: eStorage.M,
|
||||
Technique: erasure.CAUCHY,
|
||||
},
|
||||
}
|
||||
i := 0
|
||||
// encode
|
||||
@@ -163,7 +165,12 @@ func (eStorage *encodedStorage) storeBlocks(path string, blocks [][]byte) []erro
|
||||
}
|
||||
|
||||
func (eStorage *encodedStorage) readObject(objectPath string, entry StorageEntry, writer *io.PipeWriter) {
|
||||
encoder := erasure.NewEncoder(entry.Encoderparams)
|
||||
ep, err := erasure.ParseEncoderParams(entry.Encoderparams.K, entry.Encoderparams.M, entry.Encoderparams.Technique)
|
||||
if err != nil {
|
||||
writer.CloseWithError(err)
|
||||
return
|
||||
}
|
||||
encoder := erasure.NewEncoder(ep)
|
||||
for i, chunk := range entry.Blocks {
|
||||
blockSlices := eStorage.getBlockSlices(objectPath + "$" + strconv.Itoa(i))
|
||||
var blocks [][]byte
|
||||
|
||||
Reference in New Issue
Block a user