Skip to content

Commit

Permalink
storage summary: minimum object size may show zero (fix)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Oct 29, 2024
1 parent b77a7dd commit 2f20f0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
12 changes: 6 additions & 6 deletions cmn/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package cmn
import (
"errors"
"fmt"
"math"
"reflect"
"sort"
"strings"
Expand Down Expand Up @@ -317,12 +318,8 @@ func (s AllBsummResults) Aggregate(from *BsummResult) AllBsummResults {

// across targets
func aggr(from, to *BsummResult) {
if from.ObjSize.Min < to.ObjSize.Min {
to.ObjSize.Min = from.ObjSize.Min
}
if from.ObjSize.Max > to.ObjSize.Max {
to.ObjSize.Max = from.ObjSize.Max
}
to.ObjSize.Min = min(from.ObjSize.Min, to.ObjSize.Min)
to.ObjSize.Max = max(from.ObjSize.Max, to.ObjSize.Max)
to.ObjCount.Present += from.ObjCount.Present
to.ObjCount.Remote += from.ObjCount.Remote
to.TotalSize.OnDisk += from.TotalSize.OnDisk
Expand All @@ -343,6 +340,9 @@ func (s AllBsummResults) Finalize(dsize map[string]uint64, testingEnv bool) {
if summ.ObjCount.Present > 0 {
summ.ObjSize.Avg = int64(cos.DivRoundU64(summ.TotalSize.PresentObjs, summ.ObjCount.Present))
}
if summ.ObjSize.Min == math.MaxInt64 {
summ.ObjSize.Min = 0
}
if totalDisksSize > 0 {
summ.UsedPct = cos.DivRoundU64(summ.TotalSize.OnDisk*100, totalDisksSize)
}
Expand Down
13 changes: 6 additions & 7 deletions xact/xs/nsumm.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ func (r *XactNsumm) Snap() (snap *core.Snap) {

func (r *XactNsumm) Result() (cmn.AllBsummResults, error) {
if r.single {
var res cmn.BsummResult
r.cloneRes(&res, &r.oneRes)
return cmn.AllBsummResults{&res}, r.Err()
var dst cmn.BsummResult
r.cloneRes(&dst, &r.oneRes)
return cmn.AllBsummResults{&dst}, r.Err()
}

all := make(cmn.AllBsummResults, 0, len(r.mapRes))
Expand All @@ -303,12 +303,11 @@ func (r *XactNsumm) cloneRes(dst, src *cmn.BsummResult) {
dst.TotalSize.RemoteObjs = ratomic.LoadUint64(&src.TotalSize.RemoteObjs)
}

dst.ObjSize.Max = ratomic.LoadInt64(&src.ObjSize.Max)
dst.ObjSize.Min = ratomic.LoadInt64(&src.ObjSize.Min)
if dst.ObjSize.Min == math.MaxInt64 {
dst.ObjSize.Min = 0
if dst.ObjSize.Max > 0 {
dst.ObjSize.Min = min(dst.ObjSize.Min, dst.ObjSize.Max)
}
dst.ObjSize.Max = ratomic.LoadInt64(&src.ObjSize.Max)

// compute the current (maybe, running-and-changing) average and used %%
if dst.ObjCount.Present > 0 {
dst.ObjSize.Avg = int64(cos.DivRoundU64(dst.TotalSize.PresentObjs, dst.ObjCount.Present))
Expand Down

0 comments on commit 2f20f0a

Please sign in to comment.