Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions cmd/erasure-server-pool-rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ type rebalanceInfo struct {

// rebalanceMeta contains information pertaining to an ongoing rebalance operation.
type rebalanceMeta struct {
cancel context.CancelFunc `msg:"-"` // to be invoked on rebalance-stop
lastRefreshedAt time.Time `msg:"-"`
StoppedAt time.Time `msg:"stopTs"` // Time when rebalance-stop was issued.
ID string `msg:"id"` // ID of the ongoing rebalance operation
PercentFreeGoal float64 `msg:"pf"` // Computed from total free space and capacity at the start of rebalance
PoolStats []*rebalanceStats `msg:"rss"` // Per-pool rebalance stats keyed by pool index
StoppedAt time.Time `msg:"stopTs"` // Time when rebalance-stop was issued.
ID string `msg:"id"` // ID of the ongoing rebalance operation
PercentFreeGoal float64 `msg:"pf"` // Computed from total free space and capacity at the start of rebalance
PoolStats []*rebalanceStats `msg:"rss"` // Per-pool rebalance stats keyed by pool index
}

var errRebalanceNotStarted = errors.New("rebalance not started")
Expand Down Expand Up @@ -313,8 +311,6 @@ func (r *rebalanceMeta) loadWithOpts(ctx context.Context, store objectIO, opts O
return err
}

r.lastRefreshedAt = time.Now()

return nil
}

Expand Down Expand Up @@ -944,7 +940,7 @@ func (z *erasureServerPools) StartRebalance() {
return
}
ctx, cancel := context.WithCancel(GlobalContext)
z.rebalMeta.cancel = cancel // to be used when rebalance-stop is called
z.rebalCancel = cancel // to be used when rebalance-stop is called
z.rebalMu.Unlock()

z.rebalMu.RLock()
Expand Down Expand Up @@ -987,10 +983,9 @@ func (z *erasureServerPools) StopRebalance() error {
return nil
}

if cancel := r.cancel; cancel != nil {
// cancel != nil only on pool leaders
r.cancel = nil
if cancel := z.rebalCancel; cancel != nil {
cancel()
z.rebalCancel = nil
}
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/erasure-server-pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ type erasureServerPools struct {
poolMetaMutex sync.RWMutex
poolMeta poolMeta

rebalMu sync.RWMutex
rebalMeta *rebalanceMeta
rebalMu sync.RWMutex
rebalMeta *rebalanceMeta
rebalCancel context.CancelFunc

deploymentID [16]byte
distributionAlgo string
Expand Down
Loading