mirror of
https://github.com/minio/minio.git
synced 2025-01-24 21:23:15 -05:00
calculate disk cache usage percent accurately (#16740)
This commit is contained in:
parent
958bba5b42
commit
f350953a19
@ -25,7 +25,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
objectlock "github.com/minio/minio/internal/bucket/object/lock"
|
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].UsageSize = info.Used
|
||||||
cacheDiskStats[i].TotalCapacity = info.Total
|
cacheDiskStats[i].TotalCapacity = info.Total
|
||||||
cacheDiskStats[i].Dir = dcache.stats.Dir
|
cacheDiskStats[i].Dir = dcache.stats.Dir
|
||||||
atomic.StoreInt32(&cacheDiskStats[i].UsageState, atomic.LoadInt32(&dcache.stats.UsageState))
|
if info.Total != 0 {
|
||||||
atomic.StoreUint64(&cacheDiskStats[i].UsagePercent, atomic.LoadUint64(&dcache.stats.UsagePercent))
|
// 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
|
return cacheDiskStats
|
||||||
|
Loading…
x
Reference in New Issue
Block a user