mirror of
https://github.com/minio/minio.git
synced 2025-11-25 20:16:10 -05:00
xl: Change fileMetadata to xlMetadata. (#1404)
Finalized backend format
```
{
"version": "1.0.0",
"stat": {
"size": 24256,
"modTime": "2016-04-28T00:11:37.843Z"
},
"erasure": {
"data": 5,
"parity": 5,
"blockSize": 4194304
],
"minio": {
"release": "RELEASE.2016-04-28T00-09-47Z"
}
}
```
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
41b35cff7b
commit
a1a667ae5d
@@ -17,16 +17,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
slashpath "path"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
fastSha512 "github.com/minio/minio/pkg/crypto/sha512"
|
||||
)
|
||||
|
||||
// Erasure block size.
|
||||
@@ -92,9 +88,8 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
higherVersion++
|
||||
|
||||
writers := make([]io.WriteCloser, len(xl.storageDisks))
|
||||
sha512Writers := make([]hash.Hash, len(xl.storageDisks))
|
||||
|
||||
metadataFilePath := slashpath.Join(path, metadataFile)
|
||||
xlMetaV1FilePath := slashpath.Join(path, xlMetaV1File)
|
||||
metadataWriters := make([]io.WriteCloser, len(xl.storageDisks))
|
||||
|
||||
// Save additional erasureMetadata.
|
||||
@@ -102,7 +97,7 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
|
||||
createFileError := 0
|
||||
for index, disk := range xl.storageDisks {
|
||||
erasurePart := slashpath.Join(path, fmt.Sprintf("part.%d", index))
|
||||
erasurePart := slashpath.Join(path, fmt.Sprintf("file.%d", index))
|
||||
var writer io.WriteCloser
|
||||
writer, err = disk.CreateFile(volume, erasurePart)
|
||||
if err != nil {
|
||||
@@ -126,7 +121,7 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
|
||||
// create meta data file
|
||||
var metadataWriter io.WriteCloser
|
||||
metadataWriter, err = disk.CreateFile(volume, metadataFilePath)
|
||||
metadataWriter, err = disk.CreateFile(volume, xlMetaV1FilePath)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": volume,
|
||||
@@ -148,7 +143,6 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
|
||||
writers[index] = writer
|
||||
metadataWriters[index] = metadataWriter
|
||||
sha512Writers[index] = fastSha512.New()
|
||||
}
|
||||
|
||||
// Allocate 4MiB block size buffer for reading.
|
||||
@@ -221,9 +215,6 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
reader.CloseWithError(err)
|
||||
return
|
||||
}
|
||||
if sha512Writers[index] != nil {
|
||||
sha512Writers[index].Write(encodedData)
|
||||
}
|
||||
}
|
||||
|
||||
// Update total written.
|
||||
@@ -232,21 +223,19 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
}
|
||||
|
||||
// Initialize metadata map, save all erasure related metadata.
|
||||
metadata := make(fileMetadata)
|
||||
metadata.Set("version", minioVersion)
|
||||
metadata.Set("format.major", "1")
|
||||
metadata.Set("format.minor", "0")
|
||||
metadata.Set("format.patch", "0")
|
||||
metadata.Set("file.size", strconv.FormatInt(totalSize, 10))
|
||||
metadata := xlMetaV1{}
|
||||
metadata.Version = "1"
|
||||
metadata.Stat.Size = totalSize
|
||||
metadata.Stat.ModTime = modTime
|
||||
metadata.Minio.Release = minioReleaseTag
|
||||
if len(xl.storageDisks) > len(writers) {
|
||||
// Save file.version only if we wrote to less disks than all
|
||||
// storage disks.
|
||||
metadata.Set("file.version", strconv.FormatInt(higherVersion, 10))
|
||||
metadata.Stat.Version = higherVersion
|
||||
}
|
||||
metadata.Set("file.modTime", modTime.Format(timeFormatAMZ))
|
||||
metadata.Set("file.xl.blockSize", strconv.Itoa(erasureBlockSize))
|
||||
metadata.Set("file.xl.dataBlocks", strconv.Itoa(xl.DataBlocks))
|
||||
metadata.Set("file.xl.parityBlocks", strconv.Itoa(xl.ParityBlocks))
|
||||
metadata.Erasure.DataBlocks = xl.DataBlocks
|
||||
metadata.Erasure.ParityBlocks = xl.ParityBlocks
|
||||
metadata.Erasure.BlockSize = erasureBlockSize
|
||||
|
||||
// Write all the metadata.
|
||||
// below case is not handled here
|
||||
@@ -257,10 +246,6 @@ func (xl XL) writeErasure(volume, path string, reader *io.PipeReader, wcloser *w
|
||||
if metadataWriter == nil {
|
||||
continue
|
||||
}
|
||||
if sha512Writers[index] != nil {
|
||||
// Save sha512 checksum of each encoded blocks.
|
||||
metadata.Set("file.xl.block512Sum", hex.EncodeToString(sha512Writers[index].Sum(nil)))
|
||||
}
|
||||
|
||||
// Write metadata.
|
||||
err = metadata.Write(metadataWriter)
|
||||
|
||||
Reference in New Issue
Block a user