()
| 308 | } |
| 309 | |
| 310 | func (bm *bcacheManager) spaceManager() { |
| 311 | ticker := time.NewTicker(SpaceCheckInterval) |
| 312 | tmpTicker := time.NewTicker(TmpFileCheckInterval) |
| 313 | |
| 314 | defer func() { |
| 315 | ticker.Stop() |
| 316 | tmpTicker.Stop() |
| 317 | }() |
| 318 | for { |
| 319 | select { |
| 320 | case <-ticker.C: |
| 321 | for _, store := range bm.bstore { |
| 322 | useRatio, files := store.diskUsageRatio() |
| 323 | log.LogDebugf("useRation(%v), files(%v)", useRatio, files) |
| 324 | if 1-useRatio < store.freeLimit || files > int64(store.limit) { |
| 325 | bm.freeSpace(store, 1-useRatio, files) |
| 326 | } |
| 327 | bm.cacheMetaCount.SetWithLabelValues(float64(useRatio), bm.vol, store.dir, "useRatio") |
| 328 | bm.cacheMetaCount.SetWithLabelValues(float64(files), bm.vol, store.dir, "files") |
| 329 | } |
| 330 | case <-tmpTicker.C: |
| 331 | for _, store := range bm.bstore { |
| 332 | useRatio, files := store.diskUsageRatio() |
| 333 | log.LogInfof("useRation(%v), files(%v)", useRatio, files) |
| 334 | bm.deleteTmpFile(store) |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | //lru cache |
| 341 | //func (bm *bcacheManager) freeSpace(index int, store *DiskStore, free float32, files int64) { |
no test coverage detected