MCPcopy
hub / github.com/cubefs/cubefs / reBuildCacheKeys

Method reBuildCacheKeys

client/blockcache/bcache/manage.go:423–444  ·  view source on GitHub ↗
(dir string, store *DiskStore)

Source from the content-addressed store, hash-verified

421}
422
423func (bm *bcacheManager) reBuildCacheKeys(dir string, store *DiskStore) {
424 if _, err := os.Stat(dir); err != nil {
425 log.LogErrorf("cache dir %s is not exists", dir)
426 return
427 }
428 log.LogDebugf("reBuildCacheKeys(%s)", dir)
429 c := make(chan keyPair)
430 keyPrefix := filepath.Join(dir, Basedir)
431 go func() {
432 filepath.Walk(dir, bm.walker(c, keyPrefix, true))
433 close(c)
434 }()
435
436 for value := range c {
437 bm.Lock()
438 element := bm.lrulist.PushBack(value.it)
439 bm.bcacheKeys[value.key] = element
440 bm.Unlock()
441 log.LogDebugf("updateStat(%v)", value.it.size)
442 store.updateStat(value.it.size)
443 }
444}
445
446func (bm *bcacheManager) walker(c chan keyPair, prefix string, initial bool) filepath.WalkFunc {
447 return func(path string, info os.FileInfo, err error) error {

Callers 1

newBcacheManagerFunction · 0.95

Calls 9

walkerMethod · 0.95
LogErrorfFunction · 0.92
LogDebugfFunction · 0.92
LockMethod · 0.80
PushBackMethod · 0.80
updateStatMethod · 0.80
StatMethod · 0.65
JoinMethod · 0.65
UnlockMethod · 0.45

Tested by

no test coverage detected