mirror of
https://github.com/minio/minio.git
synced 2025-05-22 18:11:50 -04:00
fix: A possible crash when fi.Erasure.Distribution is empty (#10779)
This commit is contained in:
parent
bfc36aed89
commit
e0655e24f2
@ -167,7 +167,14 @@ func disksWithAllParts(ctx context.Context, onlineDisks []StorageAPI, partsMetad
|
|||||||
// consider the offline disks as consistent.
|
// consider the offline disks as consistent.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if len(meta.Erasure.Distribution) != len(onlineDisks) {
|
||||||
|
// Erasure distribution seems to have lesser
|
||||||
|
// number of items than number of online disks.
|
||||||
|
inconsistent++
|
||||||
|
continue
|
||||||
|
}
|
||||||
if meta.Erasure.Distribution[i] != meta.Erasure.Index {
|
if meta.Erasure.Distribution[i] != meta.Erasure.Index {
|
||||||
|
// Mismatch indexes with distribution order
|
||||||
inconsistent++
|
inconsistent++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,6 +200,16 @@ func disksWithAllParts(ctx context.Context, onlineDisks []StorageAPI, partsMetad
|
|||||||
if !meta.IsValid() {
|
if !meta.IsValid() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(meta.Erasure.Distribution) != len(onlineDisks) {
|
||||||
|
// Erasure distribution is not the same as onlineDisks
|
||||||
|
// attempt a fix if possible, assuming other entries
|
||||||
|
// might have the right erasure distribution.
|
||||||
|
partsMetadata[i] = FileInfo{}
|
||||||
|
dataErrs[i] = errFileCorrupt
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Since erasure.Distribution is trustable we can fix the mismatching erasure.Index
|
// Since erasure.Distribution is trustable we can fix the mismatching erasure.Index
|
||||||
if meta.Erasure.Distribution[i] != meta.Erasure.Index {
|
if meta.Erasure.Distribution[i] != meta.Erasure.Index {
|
||||||
partsMetadata[i] = FileInfo{}
|
partsMetadata[i] = FileInfo{}
|
||||||
|
@ -90,9 +90,12 @@ func (fi FileInfo) IsValid() bool {
|
|||||||
}
|
}
|
||||||
dataBlocks := fi.Erasure.DataBlocks
|
dataBlocks := fi.Erasure.DataBlocks
|
||||||
parityBlocks := fi.Erasure.ParityBlocks
|
parityBlocks := fi.Erasure.ParityBlocks
|
||||||
|
correctIndexes := (fi.Erasure.Index > 0 &&
|
||||||
|
fi.Erasure.Index <= dataBlocks+parityBlocks &&
|
||||||
|
len(fi.Erasure.Distribution) == (dataBlocks+parityBlocks))
|
||||||
return ((dataBlocks >= parityBlocks) &&
|
return ((dataBlocks >= parityBlocks) &&
|
||||||
(dataBlocks != 0) && (parityBlocks != 0) &&
|
(dataBlocks != 0) && (parityBlocks != 0) &&
|
||||||
(fi.Erasure.Index > 0 && fi.Erasure.Distribution != nil))
|
correctIndexes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToObjectInfo - Converts metadata to object info.
|
// ToObjectInfo - Converts metadata to object info.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user