Fix a panic for bucket heal (#4781)

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
Shubhendu
2023-12-07 14:13:17 -08:00
committed by GitHub
parent 1e2c5cec0a
commit 6defb9ef9a
+12 -3
View File
@@ -61,9 +61,18 @@ func (h hri) getReplicatedFileHCCChange() (b, a col, err error) {
getColCode := func(numAvail int) (c col, err error) {
// calculate color code for replicated object similar
// to erasure coded objects
quorum := h.DiskCount/h.SetCount/2 + 1
surplus := numAvail/h.SetCount - quorum
parity := h.DiskCount/h.SetCount - quorum
var quorum, surplus, parity int
if h.SetCount > 0 {
quorum = h.DiskCount/h.SetCount/2 + 1
surplus = numAvail/h.SetCount - quorum
parity = h.DiskCount/h.SetCount - quorum
} else {
// in case of bucket healing, disk count is for the node
// also explicitly set count would be set to invalid value of -1
quorum = h.DiskCount/2 + 1
surplus = numAvail - quorum
parity = h.DiskCount - quorum
}
c, err = getHColCode(surplus, parity)
return
}