mrf: Avoid rare data race and more simplification (#12791)

This change avoids a rare data race and simplify the function that
returns MRF last activity information.
This commit is contained in:
Anis Elleuch
2021-07-26 16:00:59 +01:00
committed by GitHub
parent 7106e9394c
commit 39874b77ed
3 changed files with 39 additions and 44 deletions
+2 -13
View File
@@ -68,17 +68,6 @@ func newBgHealSequence() *healSequence {
}
}
func getCurrentMRFStatus() madmin.MRFStatus {
mrfInfo := globalMRFState.getCurrentMRFRoundInfo()
return madmin.MRFStatus{
BytesHealed: mrfInfo.bytesHealed,
ItemsHealed: mrfInfo.itemsHealed,
TotalItems: mrfInfo.itemsHealed + mrfInfo.pendingItems,
TotalBytes: mrfInfo.bytesHealed + mrfInfo.pendingBytes,
Started: mrfInfo.triggeredAt,
}
}
// getBackgroundHealStatus will return the
func getBackgroundHealStatus(ctx context.Context, o ObjectLayer) (madmin.BgHealState, bool) {
if globalBackgroundHealState == nil {
@@ -94,9 +83,9 @@ func getBackgroundHealStatus(ctx context.Context, o ObjectLayer) (madmin.BgHealS
ScannedItemsCount: bgSeq.getScannedItemsCount(),
}
if globalMRFState != nil {
if globalMRFState.initialized() {
status.MRF = map[string]madmin.MRFStatus{
globalLocalNodeName: getCurrentMRFStatus(),
globalLocalNodeName: globalMRFState.getCurrentMRFRoundInfo(),
}
}