You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
964 lines
30 KiB
964 lines
30 KiB
9 years ago
|
/*
|
||
6 years ago
|
* MinIO Cloud Storage, (C) 2016, 2017, 2018 MinIO, Inc.
|
||
9 years ago
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
8 years ago
|
package cmd
|
||
9 years ago
|
|
||
9 years ago
|
import (
|
||
5 years ago
|
"bytes"
|
||
7 years ago
|
"context"
|
||
5 years ago
|
"encoding/hex"
|
||
9 years ago
|
"encoding/json"
|
||
|
"fmt"
|
||
7 years ago
|
"io/ioutil"
|
||
6 years ago
|
"reflect"
|
||
5 years ago
|
"sync"
|
||
7 years ago
|
|
||
7 years ago
|
humanize "github.com/dustin/go-humanize"
|
||
5 years ago
|
"github.com/minio/minio/cmd/config"
|
||
5 years ago
|
"github.com/minio/minio/cmd/config/storageclass"
|
||
6 years ago
|
"github.com/minio/minio/cmd/logger"
|
||
5 years ago
|
"github.com/minio/minio/pkg/color"
|
||
5 years ago
|
"github.com/minio/minio/pkg/sync/errgroup"
|
||
7 years ago
|
sha256 "github.com/minio/sha256-simd"
|
||
8 years ago
|
)
|
||
|
|
||
|
const (
|
||
5 years ago
|
// Represents Erasure backend.
|
||
|
formatBackendErasure = "xl"
|
||
8 years ago
|
|
||
5 years ago
|
// formatErasureV1.Erasure.Version - version '1'.
|
||
|
formatErasureVersionV1 = "1"
|
||
7 years ago
|
|
||
5 years ago
|
// formatErasureV2.Erasure.Version - version '2'.
|
||
|
formatErasureVersionV2 = "2"
|
||
7 years ago
|
|
||
5 years ago
|
// formatErasureV3.Erasure.Version - version '3'.
|
||
|
formatErasureVersionV3 = "3"
|
||
7 years ago
|
|
||
5 years ago
|
// Distribution algorithm used, legacy
|
||
|
formatErasureVersionV2DistributionAlgoLegacy = "CRCMOD"
|
||
|
|
||
|
// Distributed algorithm used, current
|
||
|
formatErasureVersionV3DistributionAlgo = "SIPMOD"
|
||
7 years ago
|
)
|
||
8 years ago
|
|
||
7 years ago
|
// Offline disk UUID represents an offline disk.
|
||
|
const offlineDiskUUID = "ffffffff-ffff-ffff-ffff-ffffffffffff"
|
||
|
|
||
|
// Healing is only supported for the list of errors mentioned here.
|
||
|
var formatHealErrors = map[error]struct{}{
|
||
|
errUnformattedDisk: {},
|
||
|
errDiskNotFound: {},
|
||
|
}
|
||
|
|
||
|
// List of errors considered critical for disk formatting.
|
||
|
var formatCriticalErrors = map[error]struct{}{
|
||
|
errCorruptedFormat: {},
|
||
|
errFaultyDisk: {},
|
||
|
}
|
||
|
|
||
|
// Used to detect the version of "xl" format.
|
||
5 years ago
|
type formatErasureVersionDetect struct {
|
||
|
Erasure struct {
|
||
7 years ago
|
Version string `json:"version"`
|
||
|
} `json:"xl"`
|
||
|
}
|
||
|
|
||
|
// Represents the V1 backend disk structure version
|
||
|
// under `.minio.sys` and actual data namespace.
|
||
5 years ago
|
// formatErasureV1 - structure holds format config version '1'.
|
||
|
type formatErasureV1 struct {
|
||
7 years ago
|
formatMetaV1
|
||
5 years ago
|
Erasure struct {
|
||
7 years ago
|
Version string `json:"version"` // Version of 'xl' format.
|
||
|
Disk string `json:"disk"` // Disk field carries assigned disk uuid.
|
||
|
// JBOD field carries the input disk order generated the first
|
||
|
// time when fresh disks were supplied.
|
||
|
JBOD []string `json:"jbod"`
|
||
5 years ago
|
} `json:"xl"` // Erasure field holds xl format.
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
// Represents the V2 backend disk structure version
|
||
|
// under `.minio.sys` and actual data namespace.
|
||
5 years ago
|
// formatErasureV2 - structure holds format config version '2'.
|
||
6 years ago
|
// The V2 format to support "large bucket" support where a bucket
|
||
|
// can span multiple erasure sets.
|
||
5 years ago
|
type formatErasureV2 struct {
|
||
6 years ago
|
formatMetaV1
|
||
5 years ago
|
Erasure struct {
|
||
7 years ago
|
Version string `json:"version"` // Version of 'xl' format.
|
||
|
This string `json:"this"` // This field carries assigned disk uuid.
|
||
|
// Sets field carries the input disk order generated the first
|
||
|
// time when fresh disks were supplied, it is a two dimensional
|
||
|
// array second dimension represents list of disks used per set.
|
||
|
Sets [][]string `json:"sets"`
|
||
|
// Distribution algorithm represents the hashing algorithm
|
||
|
// to pick the right set index for an object.
|
||
|
DistributionAlgo string `json:"distributionAlgo"`
|
||
|
} `json:"xl"`
|
||
|
}
|
||
|
|
||
5 years ago
|
// formatErasureV3 struct is same as formatErasureV2 struct except that formatErasureV3.Erasure.Version is "3" indicating
|
||
7 years ago
|
// the simplified multipart backend which is a flat hierarchy now.
|
||
|
// In .minio.sys/multipart we have:
|
||
5 years ago
|
// sha256(bucket/object)/uploadID/[xl.meta, part.1, part.2 ....]
|
||
|
type formatErasureV3 struct {
|
||
6 years ago
|
formatMetaV1
|
||
5 years ago
|
Erasure struct {
|
||
7 years ago
|
Version string `json:"version"` // Version of 'xl' format.
|
||
|
This string `json:"this"` // This field carries assigned disk uuid.
|
||
|
// Sets field carries the input disk order generated the first
|
||
|
// time when fresh disks were supplied, it is a two dimensional
|
||
|
// array second dimension represents list of disks used per set.
|
||
|
Sets [][]string `json:"sets"`
|
||
|
// Distribution algorithm represents the hashing algorithm
|
||
|
// to pick the right set index for an object.
|
||
|
DistributionAlgo string `json:"distributionAlgo"`
|
||
|
} `json:"xl"`
|
||
|
}
|
||
|
|
||
5 years ago
|
func (f *formatErasureV3) Clone() *formatErasureV3 {
|
||
5 years ago
|
b, err := json.Marshal(f)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
5 years ago
|
var dst formatErasureV3
|
||
5 years ago
|
if err = json.Unmarshal(b, &dst); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
return &dst
|
||
|
}
|
||
|
|
||
5 years ago
|
// Returns formatErasure.Erasure.Version
|
||
|
func newFormatErasureV3(numSets int, setLen int) *formatErasureV3 {
|
||
|
format := &formatErasureV3{}
|
||
7 years ago
|
format.Version = formatMetaVersionV1
|
||
5 years ago
|
format.Format = formatBackendErasure
|
||
6 years ago
|
format.ID = mustGetUUID()
|
||
5 years ago
|
format.Erasure.Version = formatErasureVersionV3
|
||
|
format.Erasure.DistributionAlgo = formatErasureVersionV3DistributionAlgo
|
||
|
format.Erasure.Sets = make([][]string, numSets)
|
||
7 years ago
|
|
||
|
for i := 0; i < numSets; i++ {
|
||
5 years ago
|
format.Erasure.Sets[i] = make([]string, setLen)
|
||
7 years ago
|
for j := 0; j < setLen; j++ {
|
||
5 years ago
|
format.Erasure.Sets[i][j] = mustGetUUID()
|
||
7 years ago
|
}
|
||
|
}
|
||
|
return format
|
||
|
}
|
||
|
|
||
5 years ago
|
// Returns format Erasure version after reading `format.json`, returns
|
||
|
// successfully the version only if the backend is Erasure.
|
||
|
func formatGetBackendErasureVersion(formatPath string) (string, error) {
|
||
7 years ago
|
meta := &formatMetaV1{}
|
||
|
b, err := ioutil.ReadFile(formatPath)
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
if err = json.Unmarshal(b, meta); err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
if meta.Version != formatMetaVersionV1 {
|
||
|
return "", fmt.Errorf(`format.Version expected: %s, got: %s`, formatMetaVersionV1, meta.Version)
|
||
|
}
|
||
5 years ago
|
if meta.Format != formatBackendErasure {
|
||
|
return "", fmt.Errorf(`found backend %s, expected %s`, meta.Format, formatBackendErasure)
|
||
5 years ago
|
}
|
||
5 years ago
|
// Erasure backend found, proceed to detect version.
|
||
|
format := &formatErasureVersionDetect{}
|
||
5 years ago
|
if err = json.Unmarshal(b, format); err != nil {
|
||
|
return "", err
|
||
|
}
|
||
5 years ago
|
return format.Erasure.Version, nil
|
||
7 years ago
|
}
|
||
|
|
||
|
// Migrates all previous versions to latest version of `format.json`,
|
||
|
// this code calls migration in sequence, such as V1 is migrated to V2
|
||
|
// first before it V2 migrates to V3.
|
||
5 years ago
|
func formatErasureMigrate(export string) error {
|
||
7 years ago
|
formatPath := pathJoin(export, minioMetaBucket, formatConfigFile)
|
||
5 years ago
|
version, err := formatGetBackendErasureVersion(formatPath)
|
||
7 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
switch version {
|
||
5 years ago
|
case formatErasureVersionV1:
|
||
|
if err = formatErasureMigrateV1ToV2(export, version); err != nil {
|
||
7 years ago
|
return err
|
||
|
}
|
||
5 years ago
|
// Migrate successful v1 => v2, proceed to v2 => v3
|
||
5 years ago
|
version = formatErasureVersionV2
|
||
7 years ago
|
fallthrough
|
||
5 years ago
|
case formatErasureVersionV2:
|
||
|
if err = formatErasureMigrateV2ToV3(export, version); err != nil {
|
||
7 years ago
|
return err
|
||
|
}
|
||
5 years ago
|
// Migrate successful v2 => v3, v3 is latest
|
||
5 years ago
|
// version = formatXLVersionV3
|
||
7 years ago
|
fallthrough
|
||
5 years ago
|
case formatErasureVersionV3:
|
||
5 years ago
|
// v3 is the latest version, return.
|
||
7 years ago
|
return nil
|
||
|
}
|
||
|
return fmt.Errorf(`%s: unknown format version %s`, export, version)
|
||
|
}
|
||
|
|
||
|
// Migrates version V1 of format.json to version V2 of format.json,
|
||
|
// migration fails upon any error.
|
||
5 years ago
|
func formatErasureMigrateV1ToV2(export, version string) error {
|
||
|
if version != formatErasureVersionV1 {
|
||
|
return fmt.Errorf(`Disk %s: format version expected %s, found %s`, export, formatErasureVersionV1, version)
|
||
7 years ago
|
}
|
||
|
|
||
5 years ago
|
formatPath := pathJoin(export, minioMetaBucket, formatConfigFile)
|
||
|
|
||
5 years ago
|
formatV1 := &formatErasureV1{}
|
||
7 years ago
|
b, err := ioutil.ReadFile(formatPath)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
if err = json.Unmarshal(b, formatV1); err != nil {
|
||
|
return err
|
||
|
}
|
||
9 years ago
|
|
||
5 years ago
|
formatV2 := &formatErasureV2{}
|
||
7 years ago
|
formatV2.Version = formatMetaVersionV1
|
||
5 years ago
|
formatV2.Format = formatBackendErasure
|
||
|
formatV2.Erasure.Version = formatErasureVersionV2
|
||
|
formatV2.Erasure.DistributionAlgo = formatErasureVersionV2DistributionAlgoLegacy
|
||
|
formatV2.Erasure.This = formatV1.Erasure.Disk
|
||
|
formatV2.Erasure.Sets = make([][]string, 1)
|
||
|
formatV2.Erasure.Sets[0] = make([]string, len(formatV1.Erasure.JBOD))
|
||
|
copy(formatV2.Erasure.Sets[0], formatV1.Erasure.JBOD)
|
||
7 years ago
|
|
||
|
b, err = json.Marshal(formatV2)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return ioutil.WriteFile(formatPath, b, 0644)
|
||
|
}
|
||
7 years ago
|
|
||
7 years ago
|
// Migrates V2 for format.json to V3 (Flat hierarchy for multipart)
|
||
5 years ago
|
func formatErasureMigrateV2ToV3(export, version string) error {
|
||
|
if version != formatErasureVersionV2 {
|
||
|
return fmt.Errorf(`Disk %s: format version expected %s, found %s`, export, formatErasureVersionV2, version)
|
||
7 years ago
|
}
|
||
5 years ago
|
|
||
|
formatPath := pathJoin(export, minioMetaBucket, formatConfigFile)
|
||
5 years ago
|
formatV2 := &formatErasureV2{}
|
||
7 years ago
|
b, err := ioutil.ReadFile(formatPath)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
err = json.Unmarshal(b, formatV2)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
6 years ago
|
if err = removeAll(pathJoin(export, minioMetaMultipartBucket)); err != nil {
|
||
7 years ago
|
return err
|
||
|
}
|
||
6 years ago
|
|
||
|
if err = mkdirAll(pathJoin(export, minioMetaMultipartBucket), 0755); err != nil {
|
||
7 years ago
|
return err
|
||
|
}
|
||
|
|
||
|
// format-V2 struct is exactly same as format-V1 except that version is "3"
|
||
|
// which indicates the simplified multipart backend.
|
||
5 years ago
|
formatV3 := formatErasureV3{}
|
||
7 years ago
|
|
||
|
formatV3.Version = formatV2.Version
|
||
|
formatV3.Format = formatV2.Format
|
||
5 years ago
|
formatV3.Erasure = formatV2.Erasure
|
||
7 years ago
|
|
||
5 years ago
|
formatV3.Erasure.Version = formatErasureVersionV3
|
||
7 years ago
|
|
||
|
b, err = json.Marshal(formatV3)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return ioutil.WriteFile(formatPath, b, 0644)
|
||
|
}
|
||
|
|
||
7 years ago
|
// countErrs - count a specific error.
|
||
|
func countErrs(errs []error, err error) int {
|
||
|
var i = 0
|
||
|
for _, err1 := range errs {
|
||
7 years ago
|
if err1 == err {
|
||
7 years ago
|
i++
|
||
|
}
|
||
|
}
|
||
|
return i
|
||
9 years ago
|
}
|
||
|
|
||
7 years ago
|
// Does all errors indicate we need to initialize all disks?.
|
||
5 years ago
|
func shouldInitErasureDisks(errs []error) bool {
|
||
7 years ago
|
return countErrs(errs, errUnformattedDisk) == len(errs)
|
||
|
}
|
||
|
|
||
7 years ago
|
// Check if unformatted disks are equal to write quorum.
|
||
|
func quorumUnformattedDisks(errs []error) bool {
|
||
|
return countErrs(errs, errUnformattedDisk) >= (len(errs)/2)+1
|
||
|
}
|
||
|
|
||
5 years ago
|
// loadFormatErasureAll - load all format config from all input disks in parallel.
|
||
|
func loadFormatErasureAll(storageDisks []StorageAPI, heal bool) ([]*formatErasureV3, []error) {
|
||
9 years ago
|
// Initialize list of errors.
|
||
5 years ago
|
g := errgroup.WithNErrs(len(storageDisks))
|
||
9 years ago
|
|
||
|
// Initialize format configs.
|
||
5 years ago
|
var formats = make([]*formatErasureV3, len(storageDisks))
|
||
9 years ago
|
|
||
7 years ago
|
// Load format from each disk in parallel
|
||
5 years ago
|
for index := range storageDisks {
|
||
|
index := index
|
||
|
g.Go(func() error {
|
||
|
if storageDisks[index] == nil {
|
||
|
return errDiskNotFound
|
||
|
}
|
||
5 years ago
|
format, err := loadFormatErasure(storageDisks[index])
|
||
5 years ago
|
if err != nil {
|
||
|
return err
|
||
9 years ago
|
}
|
||
7 years ago
|
formats[index] = format
|
||
5 years ago
|
if !heal {
|
||
|
// If no healing required, make the disks valid and
|
||
|
// online.
|
||
5 years ago
|
storageDisks[index].SetDiskID(format.Erasure.This)
|
||
5 years ago
|
}
|
||
5 years ago
|
return nil
|
||
|
}, index)
|
||
9 years ago
|
}
|
||
|
|
||
5 years ago
|
// Return all formats and errors if any.
|
||
|
return formats, g.Wait()
|
||
9 years ago
|
}
|
||
|
|
||
5 years ago
|
func saveFormatErasure(disk StorageAPI, format interface{}, diskID string) error {
|
||
5 years ago
|
if format == nil || disk == nil {
|
||
|
return errDiskNotFound
|
||
|
}
|
||
|
|
||
5 years ago
|
if err := makeFormatErasureMetaVolumes(disk); err != nil {
|
||
5 years ago
|
return err
|
||
|
}
|
||
|
|
||
7 years ago
|
// Marshal and write to disk.
|
||
|
formatBytes, err := json.Marshal(format)
|
||
|
if err != nil {
|
||
|
return err
|
||
7 years ago
|
}
|
||
|
|
||
5 years ago
|
tmpFormat := mustGetUUID()
|
||
5 years ago
|
|
||
7 years ago
|
// Purge any existing temporary file, okay to ignore errors here.
|
||
5 years ago
|
defer disk.DeleteFile(minioMetaBucket, tmpFormat)
|
||
7 years ago
|
|
||
5 years ago
|
// write to unique file.
|
||
|
if err = disk.WriteAll(minioMetaBucket, tmpFormat, bytes.NewReader(formatBytes)); err != nil {
|
||
7 years ago
|
return err
|
||
7 years ago
|
}
|
||
|
|
||
5 years ago
|
// Rename file `uuid.json` --> `format.json`.
|
||
5 years ago
|
if err = disk.RenameFile(minioMetaBucket, tmpFormat, minioMetaBucket, formatConfigFile); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
disk.SetDiskID(diskID)
|
||
|
return nil
|
||
9 years ago
|
}
|
||
|
|
||
5 years ago
|
var ignoredHiddenDirectories = map[string]struct{}{
|
||
5 years ago
|
minioMetaBucket: {}, // metabucket '.minio.sys'
|
||
|
".minio": {}, // users may choose to double down the backend as the config folder for certs
|
||
|
".snapshot": {}, // .snapshot for ignoring NetApp based persistent volumes WAFL snapshot
|
||
|
"lost+found": {}, // 'lost+found' directory default on ext4 filesystems
|
||
|
"$RECYCLE.BIN": {}, // windows specific directory for each drive (hidden)
|
||
|
"System Volume Information": {}, // windows specific directory for each drive (hidden)
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
func isHiddenDirectories(vols ...VolInfo) bool {
|
||
|
for _, vol := range vols {
|
||
|
if _, ok := ignoredHiddenDirectories[vol.Name]; ok {
|
||
|
continue
|
||
6 years ago
|
}
|
||
5 years ago
|
return false
|
||
6 years ago
|
}
|
||
5 years ago
|
return true
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
// loadFormatErasure - loads format.json from disk.
|
||
|
func loadFormatErasure(disk StorageAPI) (format *formatErasureV3, err error) {
|
||
9 years ago
|
buf, err := disk.ReadAll(minioMetaBucket, formatConfigFile)
|
||
|
if err != nil {
|
||
9 years ago
|
// 'file not found' and 'volume not found' as
|
||
|
// same. 'volume not found' usually means its a fresh disk.
|
||
|
if err == errFileNotFound || err == errVolumeNotFound {
|
||
|
var vols []VolInfo
|
||
|
vols, err = disk.ListVols()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
5 years ago
|
if !isHiddenDirectories(vols...) {
|
||
|
// 'format.json' not found, but we found user data, reject such disks.
|
||
9 years ago
|
return nil, errCorruptedFormat
|
||
|
}
|
||
|
// No other data found, its a fresh disk.
|
||
|
return nil, errUnformattedDisk
|
||
|
}
|
||
9 years ago
|
return nil, err
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
|
// Try to decode format json into formatConfigV1 struct.
|
||
5 years ago
|
format = &formatErasureV3{}
|
||
9 years ago
|
if err = json.Unmarshal(buf, format); err != nil {
|
||
9 years ago
|
return nil, err
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
|
// Success.
|
||
9 years ago
|
return format, nil
|
||
|
}
|
||
|
|
||
5 years ago
|
// Valid formatErasure basic versions.
|
||
|
func checkFormatErasureValue(formatErasure *formatErasureV3) error {
|
||
7 years ago
|
// Validate format version and format type.
|
||
5 years ago
|
if formatErasure.Version != formatMetaVersionV1 {
|
||
|
return fmt.Errorf("Unsupported version of backend format [%s] found", formatErasure.Version)
|
||
8 years ago
|
}
|
||
5 years ago
|
if formatErasure.Format != formatBackendErasure {
|
||
|
return fmt.Errorf("Unsupported backend format [%s] found", formatErasure.Format)
|
||
7 years ago
|
}
|
||
5 years ago
|
if formatErasure.Erasure.Version != formatErasureVersionV3 {
|
||
|
return fmt.Errorf("Unsupported Erasure backend format found [%s]", formatErasure.Erasure.Version)
|
||
7 years ago
|
}
|
||
|
return nil
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
// Check all format values.
|
||
5 years ago
|
func checkFormatErasureValues(formats []*formatErasureV3, drivesPerSet int) error {
|
||
|
for i, formatErasure := range formats {
|
||
|
if formatErasure == nil {
|
||
7 years ago
|
continue
|
||
|
}
|
||
5 years ago
|
if err := checkFormatErasureValue(formatErasure); err != nil {
|
||
7 years ago
|
return err
|
||
|
}
|
||
5 years ago
|
if len(formats) != len(formatErasure.Erasure.Sets)*len(formatErasure.Erasure.Sets[0]) {
|
||
7 years ago
|
return fmt.Errorf("%s disk is already being used in another erasure deployment. (Number of disks specified: %d but the number of disks found in the %s disk's format.json: %d)",
|
||
5 years ago
|
humanize.Ordinal(i+1), len(formats), humanize.Ordinal(i+1), len(formatErasure.Erasure.Sets)*len(formatErasure.Erasure.Sets[0]))
|
||
7 years ago
|
}
|
||
5 years ago
|
// Only if custom erasure drive count is set,
|
||
|
// we should fail here other proceed to honor what
|
||
|
// is present on the disk.
|
||
5 years ago
|
if globalCustomErasureDriveCount && len(formatErasure.Erasure.Sets[0]) != drivesPerSet {
|
||
|
return fmt.Errorf("%s disk is already formatted with %d drives per erasure set. This cannot be changed to %d, please revert your MINIO_ERASURE_SET_DRIVE_COUNT setting", humanize.Ordinal(i+1), len(formatErasure.Erasure.Sets[0]), drivesPerSet)
|
||
5 years ago
|
}
|
||
7 years ago
|
}
|
||
7 years ago
|
return nil
|
||
|
}
|
||
7 years ago
|
|
||
5 years ago
|
// Get Deployment ID for the Erasure sets from format.json.
|
||
6 years ago
|
// This need not be in quorum. Even if one of the format.json
|
||
|
// file has this value, we assume it is valid.
|
||
|
// If more than one format.json's have different id, it is considered a corrupt
|
||
|
// backend format.
|
||
5 years ago
|
func formatErasureGetDeploymentID(refFormat *formatErasureV3, formats []*formatErasureV3) (string, error) {
|
||
6 years ago
|
var deploymentID string
|
||
|
for _, format := range formats {
|
||
|
if format == nil || format.ID == "" {
|
||
|
continue
|
||
|
}
|
||
5 years ago
|
if reflect.DeepEqual(format.Erasure.Sets, refFormat.Erasure.Sets) {
|
||
6 years ago
|
// Found an ID in one of the format.json file
|
||
|
// Set deploymentID for the first time.
|
||
|
if deploymentID == "" {
|
||
|
deploymentID = format.ID
|
||
|
} else if deploymentID != format.ID {
|
||
|
// DeploymentID found earlier doesn't match with the
|
||
|
// current format.json's ID.
|
||
|
return "", errCorruptedFormat
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return deploymentID, nil
|
||
|
}
|
||
|
|
||
5 years ago
|
// formatErasureFixDeploymentID - Add deployment id if it is not present.
|
||
|
func formatErasureFixDeploymentID(endpoints Endpoints, storageDisks []StorageAPI, refFormat *formatErasureV3) (err error) {
|
||
6 years ago
|
// Attempt to load all `format.json` from all disks.
|
||
|
var sErrs []error
|
||
5 years ago
|
formats, sErrs := loadFormatErasureAll(storageDisks, false)
|
||
6 years ago
|
for i, sErr := range sErrs {
|
||
|
if _, ok := formatCriticalErrors[sErr]; ok {
|
||
5 years ago
|
return config.ErrCorruptedBackend(err).Hint(fmt.Sprintf("Clear any pre-existing content on %s", endpoints[i]))
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
|
for index := range formats {
|
||
5 years ago
|
// If the Erasure sets do not match, set those formats to nil,
|
||
6 years ago
|
// We do not have to update the ID on those format.json file.
|
||
5 years ago
|
if formats[index] != nil && !reflect.DeepEqual(formats[index].Erasure.Sets, refFormat.Erasure.Sets) {
|
||
6 years ago
|
formats[index] = nil
|
||
|
}
|
||
|
}
|
||
5 years ago
|
refFormat.ID, err = formatErasureGetDeploymentID(refFormat, formats)
|
||
6 years ago
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// If ID is set, then some other node got the lock
|
||
|
// before this node could and generated an ID
|
||
|
// for the deployment. No need to generate one.
|
||
|
if refFormat.ID != "" {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ID is generated for the first time,
|
||
|
// We set the ID in all the formats and update.
|
||
|
refFormat.ID = mustGetUUID()
|
||
|
for _, format := range formats {
|
||
|
if format != nil {
|
||
|
format.ID = refFormat.ID
|
||
|
}
|
||
|
}
|
||
|
// Deployment ID needs to be set on all the disks.
|
||
|
// Save `format.json` across all disks.
|
||
5 years ago
|
return saveFormatErasureAll(GlobalContext, storageDisks, formats)
|
||
6 years ago
|
|
||
|
}
|
||
|
|
||
|
// Update only the valid local disks which have not been updated before.
|
||
5 years ago
|
func formatErasureFixLocalDeploymentID(endpoints Endpoints, storageDisks []StorageAPI, refFormat *formatErasureV3) error {
|
||
6 years ago
|
// If this server was down when the deploymentID was updated
|
||
|
// then we make sure that we update the local disks with the deploymentID.
|
||
5 years ago
|
|
||
|
// Initialize errs to collect errors inside go-routine.
|
||
|
g := errgroup.WithNErrs(len(storageDisks))
|
||
|
|
||
|
for index := range storageDisks {
|
||
|
index := index
|
||
|
g.Go(func() error {
|
||
|
if endpoints[index].IsLocal && storageDisks[index] != nil && storageDisks[index].IsOnline() {
|
||
5 years ago
|
format, err := loadFormatErasure(storageDisks[index])
|
||
5 years ago
|
if err != nil {
|
||
|
// Disk can be offline etc.
|
||
|
// ignore the errors seen here.
|
||
|
return nil
|
||
|
}
|
||
|
if format.ID != "" {
|
||
|
return nil
|
||
|
}
|
||
5 years ago
|
if !reflect.DeepEqual(format.Erasure.Sets, refFormat.Erasure.Sets) {
|
||
5 years ago
|
return nil
|
||
|
}
|
||
|
format.ID = refFormat.ID
|
||
5 years ago
|
if err := saveFormatErasure(storageDisks[index], format, format.Erasure.This); err != nil {
|
||
5 years ago
|
logger.LogIf(GlobalContext, err)
|
||
5 years ago
|
return fmt.Errorf("Unable to save format.json, %w", err)
|
||
|
}
|
||
6 years ago
|
}
|
||
5 years ago
|
return nil
|
||
|
}, index)
|
||
|
}
|
||
|
for _, err := range g.Wait() {
|
||
|
if err != nil {
|
||
|
return err
|
||
6 years ago
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
5 years ago
|
// Get backend Erasure format in quorum `format.json`.
|
||
|
func getFormatErasureInQuorum(formats []*formatErasureV3) (*formatErasureV3, error) {
|
||
7 years ago
|
formatHashes := make([]string, len(formats))
|
||
|
for i, format := range formats {
|
||
|
if format == nil {
|
||
7 years ago
|
continue
|
||
|
}
|
||
7 years ago
|
h := sha256.New()
|
||
5 years ago
|
for _, set := range format.Erasure.Sets {
|
||
7 years ago
|
for _, diskID := range set {
|
||
|
h.Write([]byte(diskID))
|
||
9 years ago
|
}
|
||
9 years ago
|
}
|
||
7 years ago
|
formatHashes[i] = hex.EncodeToString(h.Sum(nil))
|
||
9 years ago
|
}
|
||
8 years ago
|
|
||
7 years ago
|
formatCountMap := make(map[string]int)
|
||
|
for _, hash := range formatHashes {
|
||
|
if hash == "" {
|
||
|
continue
|
||
|
}
|
||
|
formatCountMap[hash]++
|
||
|
}
|
||
9 years ago
|
|
||
7 years ago
|
maxHash := ""
|
||
|
maxCount := 0
|
||
|
for hash, count := range formatCountMap {
|
||
|
if count > maxCount {
|
||
|
maxCount = count
|
||
|
maxHash = hash
|
||
8 years ago
|
}
|
||
7 years ago
|
}
|
||
|
|
||
|
if maxCount < len(formats)/2 {
|
||
5 years ago
|
return nil, errErasureReadQuorum
|
||
7 years ago
|
}
|
||
|
|
||
|
for i, hash := range formatHashes {
|
||
|
if hash == maxHash {
|
||
5 years ago
|
format := formats[i].Clone()
|
||
5 years ago
|
format.Erasure.This = ""
|
||
5 years ago
|
return format, nil
|
||
8 years ago
|
}
|
||
|
}
|
||
7 years ago
|
|
||
5 years ago
|
return nil, errErasureReadQuorum
|
||
8 years ago
|
}
|
||
|
|
||
5 years ago
|
func formatErasureV3Check(reference *formatErasureV3, format *formatErasureV3) error {
|
||
5 years ago
|
tmpFormat := format.Clone()
|
||
5 years ago
|
this := tmpFormat.Erasure.This
|
||
|
tmpFormat.Erasure.This = ""
|
||
|
if len(reference.Erasure.Sets) != len(format.Erasure.Sets) {
|
||
|
return fmt.Errorf("Expected number of sets %d, got %d", len(reference.Erasure.Sets), len(format.Erasure.Sets))
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
7 years ago
|
// Make sure that the sets match.
|
||
5 years ago
|
for i := range reference.Erasure.Sets {
|
||
|
if len(reference.Erasure.Sets[i]) != len(format.Erasure.Sets[i]) {
|
||
7 years ago
|
return fmt.Errorf("Each set should be of same size, expected %d got %d",
|
||
5 years ago
|
len(reference.Erasure.Sets[i]), len(format.Erasure.Sets[i]))
|
||
8 years ago
|
}
|
||
5 years ago
|
for j := range reference.Erasure.Sets[i] {
|
||
|
if reference.Erasure.Sets[i][j] != format.Erasure.Sets[i][j] {
|
||
7 years ago
|
return fmt.Errorf("UUID on positions %d:%d do not match with, expected %s got %s",
|
||
5 years ago
|
i, j, reference.Erasure.Sets[i][j], format.Erasure.Sets[i][j])
|
||
8 years ago
|
}
|
||
|
}
|
||
7 years ago
|
}
|
||
|
|
||
|
// Make sure that the diskID is found in the set.
|
||
5 years ago
|
for i := 0; i < len(tmpFormat.Erasure.Sets); i++ {
|
||
|
for j := 0; j < len(tmpFormat.Erasure.Sets[i]); j++ {
|
||
|
if this == tmpFormat.Erasure.Sets[i][j] {
|
||
7 years ago
|
return nil
|
||
8 years ago
|
}
|
||
|
}
|
||
|
}
|
||
5 years ago
|
return fmt.Errorf("Disk ID %s not found in any disk sets %s", this, format.Erasure.Sets)
|
||
8 years ago
|
}
|
||
|
|
||
5 years ago
|
// Initializes meta volume only on local storage disks.
|
||
5 years ago
|
func initErasureMetaVolumesInLocalDisks(storageDisks []StorageAPI, formats []*formatErasureV3) error {
|
||
5 years ago
|
|
||
|
// Compute the local disks eligible for meta volumes (re)initialization
|
||
|
var disksToInit []StorageAPI
|
||
|
for index := range storageDisks {
|
||
5 years ago
|
if formats[index] == nil || storageDisks[index] == nil || !storageDisks[index].IsLocal() {
|
||
5 years ago
|
// Ignore create meta volume on disks which are not found or not local.
|
||
|
continue
|
||
|
}
|
||
|
disksToInit = append(disksToInit, storageDisks[index])
|
||
|
}
|
||
5 years ago
|
|
||
|
// Initialize errs to collect errors inside go-routine.
|
||
5 years ago
|
g := errgroup.WithNErrs(len(disksToInit))
|
||
5 years ago
|
|
||
|
// Initialize all disks in parallel.
|
||
5 years ago
|
for index := range disksToInit {
|
||
|
// Initialize a new index variable in each loop so each
|
||
|
// goroutine will return its own instance of index variable.
|
||
5 years ago
|
index := index
|
||
|
g.Go(func() error {
|
||
5 years ago
|
return makeFormatErasureMetaVolumes(disksToInit[index])
|
||
5 years ago
|
}, index)
|
||
|
}
|
||
|
|
||
|
// Return upon first error.
|
||
|
for _, err := range g.Wait() {
|
||
|
if err == nil {
|
||
|
continue
|
||
|
}
|
||
|
return toObjectErr(err, minioMetaBucket)
|
||
|
}
|
||
|
|
||
|
// Return success here.
|
||
|
return nil
|
||
|
}
|
||
|
|
||
5 years ago
|
// saveFormatErasureAll - populates `format.json` on disks in its order.
|
||
|
func saveFormatErasureAll(ctx context.Context, storageDisks []StorageAPI, formats []*formatErasureV3) error {
|
||
5 years ago
|
g := errgroup.WithNErrs(len(storageDisks))
|
||
8 years ago
|
|
||
7 years ago
|
// Write `format.json` to all disks.
|
||
5 years ago
|
for index := range storageDisks {
|
||
|
index := index
|
||
|
g.Go(func() error {
|
||
5 years ago
|
return saveFormatErasure(storageDisks[index], formats[index], formats[index].Erasure.This)
|
||
5 years ago
|
}, index)
|
||
8 years ago
|
}
|
||
|
|
||
5 years ago
|
writeQuorum := getWriteQuorum(len(storageDisks))
|
||
5 years ago
|
// Wait for the routines to finish.
|
||
|
return reduceWriteQuorumErrs(ctx, g.Wait(), nil, writeQuorum)
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
// relinquishes the underlying connection for all storage disks.
|
||
|
func closeStorageDisks(storageDisks []StorageAPI) {
|
||
|
for _, disk := range storageDisks {
|
||
|
if disk == nil {
|
||
|
continue
|
||
|
}
|
||
|
disk.Close()
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
// Initialize storage disks for each endpoint.
|
||
|
// Errors are returned for each endpoint with matching index.
|
||
5 years ago
|
func initStorageDisksWithErrors(endpoints Endpoints) ([]StorageAPI, []error) {
|
||
7 years ago
|
// Bootstrap disks.
|
||
|
storageDisks := make([]StorageAPI, len(endpoints))
|
||
5 years ago
|
g := errgroup.WithNErrs(len(endpoints))
|
||
|
for index := range endpoints {
|
||
|
index := index
|
||
|
g.Go(func() error {
|
||
|
storageDisk, err := newStorageAPI(endpoints[index])
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
storageDisks[index] = storageDisk
|
||
|
return nil
|
||
|
}, index)
|
||
5 years ago
|
}
|
||
5 years ago
|
return storageDisks, g.Wait()
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
// formatErasureV3ThisEmpty - find out if '.This' field is empty
|
||
7 years ago
|
// in any of the input `formats`, if yes return true.
|
||
5 years ago
|
func formatErasureV3ThisEmpty(formats []*formatErasureV3) bool {
|
||
7 years ago
|
for _, format := range formats {
|
||
|
if format == nil {
|
||
|
continue
|
||
|
}
|
||
|
// NOTE: This code is specifically needed when migrating version
|
||
|
// V1 to V2 to V3, in a scenario such as this we only need to handle
|
||
|
// single sets since we never used to support multiple sets in releases
|
||
|
// with V1 format version.
|
||
5 years ago
|
if len(format.Erasure.Sets) > 1 {
|
||
7 years ago
|
continue
|
||
|
}
|
||
5 years ago
|
if format.Erasure.This == "" {
|
||
7 years ago
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
|
||
5 years ago
|
// fixFormatErasureV3 - fix format Erasure configuration on all disks.
|
||
|
func fixFormatErasureV3(storageDisks []StorageAPI, endpoints Endpoints, formats []*formatErasureV3) error {
|
||
5 years ago
|
g := errgroup.WithNErrs(len(formats))
|
||
|
for i := range formats {
|
||
|
i := i
|
||
|
g.Go(func() error {
|
||
|
if formats[i] == nil || !endpoints[i].IsLocal {
|
||
|
return nil
|
||
|
}
|
||
|
// NOTE: This code is specifically needed when migrating version
|
||
|
// V1 to V2 to V3, in a scenario such as this we only need to handle
|
||
|
// single sets since we never used to support multiple sets in releases
|
||
|
// with V1 format version.
|
||
5 years ago
|
if len(formats[i].Erasure.Sets) > 1 {
|
||
5 years ago
|
return nil
|
||
|
}
|
||
5 years ago
|
if formats[i].Erasure.This == "" {
|
||
|
formats[i].Erasure.This = formats[i].Erasure.Sets[0][i]
|
||
|
if err := saveFormatErasure(storageDisks[i], formats[i], formats[i].Erasure.This); err != nil {
|
||
5 years ago
|
return err
|
||
|
}
|
||
7 years ago
|
}
|
||
5 years ago
|
return nil
|
||
|
}, i)
|
||
|
}
|
||
|
for _, err := range g.Wait() {
|
||
|
if err != nil {
|
||
|
return err
|
||
7 years ago
|
}
|
||
|
}
|
||
|
return nil
|
||
5 years ago
|
|
||
7 years ago
|
}
|
||
|
|
||
5 years ago
|
// initFormatErasure - save Erasure format configuration on all disks.
|
||
|
func initFormatErasure(ctx context.Context, storageDisks []StorageAPI, setCount, drivesPerSet int, deploymentID string) (*formatErasureV3, error) {
|
||
|
format := newFormatErasureV3(setCount, drivesPerSet)
|
||
|
formats := make([]*formatErasureV3, len(storageDisks))
|
||
5 years ago
|
wantAtMost := ecDrivesNoConfig(drivesPerSet)
|
||
9 years ago
|
|
||
7 years ago
|
for i := 0; i < setCount; i++ {
|
||
5 years ago
|
hostCount := make(map[string]int, drivesPerSet)
|
||
5 years ago
|
for j := 0; j < drivesPerSet; j++ {
|
||
5 years ago
|
disk := storageDisks[i*drivesPerSet+j]
|
||
5 years ago
|
newFormat := format.Clone()
|
||
5 years ago
|
newFormat.Erasure.This = format.Erasure.Sets[i][j]
|
||
5 years ago
|
if deploymentID != "" {
|
||
|
newFormat.ID = deploymentID
|
||
|
}
|
||
5 years ago
|
hostCount[disk.Hostname()]++
|
||
5 years ago
|
formats[i*drivesPerSet+j] = newFormat
|
||
7 years ago
|
}
|
||
5 years ago
|
if len(hostCount) > 0 {
|
||
|
var once sync.Once
|
||
|
for host, count := range hostCount {
|
||
|
if count > wantAtMost {
|
||
|
if host == "" {
|
||
|
host = "local"
|
||
|
}
|
||
|
once.Do(func() {
|
||
|
if len(hostCount) == 1 {
|
||
|
return
|
||
|
}
|
||
|
logger.Info(" * Set %v:", i+1)
|
||
|
for j := 0; j < drivesPerSet; j++ {
|
||
|
disk := storageDisks[i*drivesPerSet+j]
|
||
|
logger.Info(" - Drive: %s", disk.String())
|
||
|
}
|
||
|
})
|
||
|
logger.Info(color.Yellow("WARNING:")+" Host %v has more than %v drives of set. "+
|
||
|
"A host failure will result in data becoming unavailable.", host, wantAtMost)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
9 years ago
|
}
|
||
|
|
||
7 years ago
|
// Save formats `format.json` across all disks.
|
||
5 years ago
|
if err := saveFormatErasureAll(ctx, storageDisks, formats); err != nil {
|
||
7 years ago
|
return nil, err
|
||
8 years ago
|
}
|
||
7 years ago
|
|
||
5 years ago
|
return getFormatErasureInQuorum(formats)
|
||
8 years ago
|
}
|
||
|
|
||
5 years ago
|
// ecDrivesNoConfig returns the erasure coded drives in a set if no config has been set.
|
||
|
// It will attempt to read it from env variable and fall back to drives/2.
|
||
|
func ecDrivesNoConfig(drivesPerSet int) int {
|
||
|
ecDrives := globalStorageClass.GetParityForSC(storageclass.STANDARD)
|
||
|
if ecDrives == 0 {
|
||
|
cfg, err := storageclass.LookupConfig(nil, drivesPerSet)
|
||
|
if err == nil {
|
||
|
ecDrives = cfg.Standard.Parity
|
||
|
}
|
||
|
if ecDrives == 0 {
|
||
|
ecDrives = drivesPerSet / 2
|
||
|
}
|
||
|
}
|
||
|
return ecDrives
|
||
|
}
|
||
|
|
||
5 years ago
|
// Make Erasure backend meta volumes.
|
||
|
func makeFormatErasureMetaVolumes(disk StorageAPI) error {
|
||
5 years ago
|
if disk == nil {
|
||
|
return errDiskNotFound
|
||
|
}
|
||
5 years ago
|
// Attempt to create MinIO internal buckets.
|
||
5 years ago
|
return disk.MakeVolBulk(minioMetaBucket, minioMetaTmpBucket, minioMetaMultipartBucket, dataUsageBucket)
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
// Get all UUIDs which are present in reference format should
|
||
|
// be present in the list of formats provided, those are considered
|
||
|
// as online UUIDs.
|
||
5 years ago
|
func getOnlineUUIDs(refFormat *formatErasureV3, formats []*formatErasureV3) (onlineUUIDs []string) {
|
||
7 years ago
|
for _, format := range formats {
|
||
|
if format == nil {
|
||
|
continue
|
||
|
}
|
||
5 years ago
|
for _, set := range refFormat.Erasure.Sets {
|
||
7 years ago
|
for _, uuid := range set {
|
||
5 years ago
|
if format.Erasure.This == uuid {
|
||
7 years ago
|
onlineUUIDs = append(onlineUUIDs, uuid)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
9 years ago
|
}
|
||
7 years ago
|
return onlineUUIDs
|
||
|
}
|
||
9 years ago
|
|
||
7 years ago
|
// Look for all UUIDs which are not present in reference format
|
||
|
// but are present in the onlineUUIDs list, construct of list such
|
||
|
// offline UUIDs.
|
||
5 years ago
|
func getOfflineUUIDs(refFormat *formatErasureV3, formats []*formatErasureV3) (offlineUUIDs []string) {
|
||
7 years ago
|
onlineUUIDs := getOnlineUUIDs(refFormat, formats)
|
||
5 years ago
|
for i, set := range refFormat.Erasure.Sets {
|
||
7 years ago
|
for j, uuid := range set {
|
||
|
var found bool
|
||
|
for _, onlineUUID := range onlineUUIDs {
|
||
5 years ago
|
if refFormat.Erasure.Sets[i][j] == onlineUUID {
|
||
7 years ago
|
found = true
|
||
|
}
|
||
|
}
|
||
|
if !found {
|
||
|
offlineUUIDs = append(offlineUUIDs, uuid)
|
||
|
}
|
||
|
}
|
||
9 years ago
|
}
|
||
7 years ago
|
return offlineUUIDs
|
||
7 years ago
|
}
|
||
|
|
||
7 years ago
|
// Mark all UUIDs that are offline.
|
||
5 years ago
|
func markUUIDsOffline(refFormat *formatErasureV3, formats []*formatErasureV3) {
|
||
7 years ago
|
offlineUUIDs := getOfflineUUIDs(refFormat, formats)
|
||
5 years ago
|
for i, set := range refFormat.Erasure.Sets {
|
||
7 years ago
|
for j := range set {
|
||
|
for _, offlineUUID := range offlineUUIDs {
|
||
5 years ago
|
if refFormat.Erasure.Sets[i][j] == offlineUUID {
|
||
|
refFormat.Erasure.Sets[i][j] = offlineDiskUUID
|
||
7 years ago
|
}
|
||
|
}
|
||
|
}
|
||
8 years ago
|
}
|
||
7 years ago
|
}
|
||
8 years ago
|
|
||
7 years ago
|
// Initialize a new set of set formats which will be written to all disks.
|
||
5 years ago
|
func newHealFormatSets(refFormat *formatErasureV3, setCount, drivesPerSet int, formats []*formatErasureV3, errs []error) [][]*formatErasureV3 {
|
||
|
newFormats := make([][]*formatErasureV3, setCount)
|
||
|
for i := range refFormat.Erasure.Sets {
|
||
|
newFormats[i] = make([]*formatErasureV3, drivesPerSet)
|
||
7 years ago
|
}
|
||
5 years ago
|
for i := range refFormat.Erasure.Sets {
|
||
|
for j := range refFormat.Erasure.Sets[i] {
|
||
5 years ago
|
if errs[i*drivesPerSet+j] == errUnformattedDisk || errs[i*drivesPerSet+j] == nil {
|
||
5 years ago
|
newFormats[i][j] = &formatErasureV3{}
|
||
7 years ago
|
newFormats[i][j].Version = refFormat.Version
|
||
6 years ago
|
newFormats[i][j].ID = refFormat.ID
|
||
7 years ago
|
newFormats[i][j].Format = refFormat.Format
|
||
5 years ago
|
newFormats[i][j].Erasure.Version = refFormat.Erasure.Version
|
||
|
newFormats[i][j].Erasure.DistributionAlgo = refFormat.Erasure.DistributionAlgo
|
||
7 years ago
|
}
|
||
5 years ago
|
if errs[i*drivesPerSet+j] == errUnformattedDisk {
|
||
5 years ago
|
newFormats[i][j].Erasure.This = ""
|
||
|
newFormats[i][j].Erasure.Sets = nil
|
||
7 years ago
|
continue
|
||
|
}
|
||
5 years ago
|
if errs[i*drivesPerSet+j] == nil {
|
||
5 years ago
|
newFormats[i][j].Erasure.This = formats[i*drivesPerSet+j].Erasure.This
|
||
|
newFormats[i][j].Erasure.Sets = nil
|
||
7 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
return newFormats
|
||
9 years ago
|
}
|