mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 16:23:28 +03:00
Removing readAllMeta from xl-v1-healing.go and placing it in xl-v1-utils.go (#2296)
This commit is contained in:
committed by
Harshavardhana
parent
1e3d80552f
commit
5fe72cf205
@@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"hash/crc32"
|
||||
"path"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Returns number of errors that occurred the most (incl. nil) and the
|
||||
@@ -112,6 +113,38 @@ func readXLMeta(disk StorageAPI, bucket string, object string) (xlMeta xlMetaV1,
|
||||
return xlMeta, nil
|
||||
}
|
||||
|
||||
// Reads all `xl.json` metadata as a xlMetaV1 slice.
|
||||
// Returns error slice indicating the failed metadata reads.
|
||||
func readAllXLMetadata(disks []StorageAPI, bucket, object string) ([]xlMetaV1, []error) {
|
||||
errs := make([]error, len(disks))
|
||||
metadataArray := make([]xlMetaV1, len(disks))
|
||||
var wg = &sync.WaitGroup{}
|
||||
// Read `xl.json` parallelly across disks.
|
||||
for index, disk := range disks {
|
||||
if disk == nil {
|
||||
errs[index] = errDiskNotFound
|
||||
continue
|
||||
}
|
||||
wg.Add(1)
|
||||
// Read `xl.json` in routine.
|
||||
go func(index int, disk StorageAPI) {
|
||||
defer wg.Done()
|
||||
var err error
|
||||
metadataArray[index], err = readXLMeta(disk, bucket, object)
|
||||
if err != nil {
|
||||
errs[index] = err
|
||||
return
|
||||
}
|
||||
}(index, disk)
|
||||
}
|
||||
|
||||
// Wait for all the routines to finish.
|
||||
wg.Wait()
|
||||
|
||||
// Return all the metadata.
|
||||
return metadataArray, errs
|
||||
}
|
||||
|
||||
// Return ordered partsMetadata depeinding on distribution.
|
||||
func getOrderedPartsMetadata(distribution []int, partsMetadata []xlMetaV1) (orderedPartsMetadata []xlMetaV1) {
|
||||
orderedPartsMetadata = make([]xlMetaV1, len(partsMetadata))
|
||||
|
||||
Reference in New Issue
Block a user