mirror of
https://github.com/minio/minio.git
synced 2025-03-30 17:23:42 -04:00
fix: rebalance to account for object's on-disk size (#16240)
This commit is contained in:
parent
9e6cc847f8
commit
0159b56717
@ -57,15 +57,16 @@ type rebalanceStats struct {
|
|||||||
Info rebalanceInfo `json:"info" msg:"inf"`
|
Info rebalanceInfo `json:"info" msg:"inf"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *rebalanceStats) update(bucket string, oi ObjectInfo) {
|
func (rs *rebalanceStats) update(bucket string, fi FileInfo) {
|
||||||
if oi.IsLatest {
|
if fi.IsLatest {
|
||||||
rs.NumObjects++
|
rs.NumObjects++
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.NumVersions++
|
rs.NumVersions++
|
||||||
rs.Bytes += uint64(oi.Size)
|
onDiskSz := fi.Size * int64(fi.Erasure.DataBlocks+fi.Erasure.ParityBlocks) / int64(fi.Erasure.DataBlocks)
|
||||||
|
rs.Bytes += uint64(onDiskSz)
|
||||||
rs.Bucket = bucket
|
rs.Bucket = bucket
|
||||||
rs.Object = oi.Name
|
rs.Object = fi.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
type rstats []*rebalanceStats
|
type rstats []*rebalanceStats
|
||||||
@ -168,7 +169,7 @@ func (z *erasureServerPools) initRebalanceMeta(ctx context.Context, buckets []st
|
|||||||
return r.ID, nil
|
return r.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *erasureServerPools) updatePoolStats(poolIdx int, bucket string, oi ObjectInfo) {
|
func (z *erasureServerPools) updatePoolStats(poolIdx int, bucket string, fi FileInfo) {
|
||||||
z.rebalMu.Lock()
|
z.rebalMu.Lock()
|
||||||
defer z.rebalMu.Unlock()
|
defer z.rebalMu.Unlock()
|
||||||
|
|
||||||
@ -177,7 +178,7 @@ func (z *erasureServerPools) updatePoolStats(poolIdx int, bucket string, oi Obje
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r.PoolStats[poolIdx].update(bucket, oi)
|
r.PoolStats[poolIdx].update(bucket, fi)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -534,14 +535,13 @@ func (z *erasureServerPools) rebalanceBucket(ctx context.Context, bucket string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !failure {
|
if !failure {
|
||||||
z.updatePoolStats(poolIdx, bucket, version.ToObjectInfo(bucket, version.Name, vc.PrefixEnabled(version.Name)))
|
z.updatePoolStats(poolIdx, bucket, version)
|
||||||
rebalanced++
|
rebalanced++
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var failure bool
|
var failure bool
|
||||||
var oi ObjectInfo
|
|
||||||
for try := 0; try < 3; try++ {
|
for try := 0; try < 3; try++ {
|
||||||
// GetObjectReader.Close is called by rebalanceObject
|
// GetObjectReader.Close is called by rebalanceObject
|
||||||
gr, err := set.GetObjectNInfo(ctx,
|
gr, err := set.GetObjectNInfo(ctx,
|
||||||
@ -574,14 +574,13 @@ func (z *erasureServerPools) rebalanceBucket(ctx context.Context, bucket string,
|
|||||||
|
|
||||||
stopFn(nil)
|
stopFn(nil)
|
||||||
failure = false
|
failure = false
|
||||||
oi = gr.ObjInfo
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if failure {
|
if failure {
|
||||||
break // break out on first error
|
break // break out on first error
|
||||||
}
|
}
|
||||||
z.updatePoolStats(poolIdx, bucket, oi)
|
z.updatePoolStats(poolIdx, bucket, version)
|
||||||
rebalanced++
|
rebalanced++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user