From 35ef35b5c1f80a7580900be61407bebd65b48d77 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Sun, 18 Jun 2023 19:14:53 +0100 Subject: [PATCH] fix a integer divide by zero crash during rebalance (#17455) A state is updated with a delete marker, which does not have parity or data blocks defined, which can cause the integer divide by zero panics. This commit fixes to avoid panics. --- cmd/erasure-server-pool-rebalance.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/erasure-server-pool-rebalance.go b/cmd/erasure-server-pool-rebalance.go index 30cd15ade..909cf20af 100644 --- a/cmd/erasure-server-pool-rebalance.go +++ b/cmd/erasure-server-pool-rebalance.go @@ -63,7 +63,10 @@ func (rs *rebalanceStats) update(bucket string, fi FileInfo) { } rs.NumVersions++ - onDiskSz := fi.Size * int64(fi.Erasure.DataBlocks+fi.Erasure.ParityBlocks) / int64(fi.Erasure.DataBlocks) + onDiskSz := int64(0) + if !fi.Deleted { + onDiskSz = fi.Size * int64(fi.Erasure.DataBlocks+fi.Erasure.ParityBlocks) / int64(fi.Erasure.DataBlocks) + } rs.Bytes += uint64(onDiskSz) rs.Bucket = bucket rs.Object = fi.Name