mirror of
https://github.com/minio/minio.git
synced 2025-01-24 13:13:16 -05:00
calculate disk cache usage percent accurately (#16740)
This commit is contained in:
parent
958bba5b42
commit
f350953a19
@ -25,7 +25,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
objectlock "github.com/minio/minio/internal/bucket/object/lock"
|
||||
@ -893,8 +892,16 @@ func newServerCacheObjects(ctx context.Context, config cache.Config) (CacheObjec
|
||||
cacheDiskStats[i].UsageSize = info.Used
|
||||
cacheDiskStats[i].TotalCapacity = info.Total
|
||||
cacheDiskStats[i].Dir = dcache.stats.Dir
|
||||
atomic.StoreInt32(&cacheDiskStats[i].UsageState, atomic.LoadInt32(&dcache.stats.UsageState))
|
||||
atomic.StoreUint64(&cacheDiskStats[i].UsagePercent, atomic.LoadUint64(&dcache.stats.UsagePercent))
|
||||
if info.Total != 0 {
|
||||
// UsageState
|
||||
gcTriggerPct := dcache.quotaPct * dcache.highWatermark / 100
|
||||
usedPercent := float64(info.Used) * 100 / float64(info.Total)
|
||||
if usedPercent >= float64(gcTriggerPct) {
|
||||
cacheDiskStats[i].UsageState = 1
|
||||
}
|
||||
// UsagePercent
|
||||
cacheDiskStats[i].UsagePercent = uint64(usedPercent)
|
||||
}
|
||||
}
|
||||
}
|
||||
return cacheDiskStats
|
||||
|
Loading…
x
Reference in New Issue
Block a user