mirror of
https://github.com/minio/minio.git
synced 2025-11-13 07:11:44 -05:00
XL: Refactor usage of reduceErrs and consistent behavior. (#2240)
This refactor is also needed in lieu of our quorum requirement change for the newly understood logic behind klauspost/reedsolom implementation.
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
f67c930731
commit
cef26fd6ea
@@ -270,7 +270,7 @@ func (xl xlObjects) statPart(bucket, object, uploadID, partName string) (fileInf
|
||||
}
|
||||
|
||||
// commitXLMetadata - commit `xl.json` from source prefix to destination prefix in the given slice of disks.
|
||||
func commitXLMetadata(disks []StorageAPI, srcPrefix, dstPrefix string, writeQuorum, readQuorum int) error {
|
||||
func commitXLMetadata(disks []StorageAPI, srcPrefix, dstPrefix string, quorum int) error {
|
||||
var wg = &sync.WaitGroup{}
|
||||
var mErrs = make([]error, len(disks))
|
||||
|
||||
@@ -303,35 +303,16 @@ func commitXLMetadata(disks []StorageAPI, srcPrefix, dstPrefix string, writeQuor
|
||||
wg.Wait()
|
||||
|
||||
// Do we have write Quorum?.
|
||||
if !isDiskQuorum(mErrs, writeQuorum) {
|
||||
// Do we have readQuorum?.
|
||||
if isDiskQuorum(mErrs, readQuorum) {
|
||||
// Return success.
|
||||
return nil
|
||||
}
|
||||
if !isDiskQuorum(mErrs, quorum) {
|
||||
// Delete all `xl.json` successfully renamed.
|
||||
deleteAllXLMetadata(disks, minioMetaBucket, dstPrefix, mErrs)
|
||||
return errXLWriteQuorum
|
||||
}
|
||||
|
||||
// Reduce errors and verify quourm and return.
|
||||
if errCount, reducedErr := reduceErrs(mErrs); reducedErr != nil {
|
||||
if errCount < writeQuorum {
|
||||
// Delete all `xl.json` successfully renamed.
|
||||
deleteAllXLMetadata(disks, minioMetaBucket, dstPrefix, mErrs)
|
||||
return errXLWriteQuorum
|
||||
}
|
||||
if isErrIgnored(reducedErr, []error{
|
||||
errDiskNotFound,
|
||||
errDiskAccessDenied,
|
||||
errFaultyDisk,
|
||||
errVolumeNotFound,
|
||||
}) {
|
||||
return nil
|
||||
}
|
||||
return reducedErr
|
||||
}
|
||||
|
||||
// Success.
|
||||
return nil
|
||||
return reduceErrs(mErrs, []error{
|
||||
errDiskNotFound,
|
||||
errDiskAccessDenied,
|
||||
errFaultyDisk,
|
||||
errVolumeNotFound,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user