|
|
@ -22,7 +22,6 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
|
"sync" |
|
|
|
|
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
jsoniter "github.com/json-iterator/go" |
|
|
|
jsoniter "github.com/json-iterator/go" |
|
|
@ -160,10 +159,7 @@ func updateUsage(basePath string, doneCh <-chan struct{}, waitForLowActiveIO fun |
|
|
|
ObjectsSizesHistogram: make(map[string]uint64), |
|
|
|
ObjectsSizesHistogram: make(map[string]uint64), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
numWorkers := 4 |
|
|
|
fastWalk(basePath, 1, doneCh, func(path string, typ os.FileMode) error { |
|
|
|
var mutex sync.Mutex // Mutex to update dataUsageInfo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastWalk(basePath, numWorkers, doneCh, func(path string, typ os.FileMode) error { |
|
|
|
|
|
|
|
// Wait for I/O to go down.
|
|
|
|
// Wait for I/O to go down.
|
|
|
|
waitForLowActiveIO() |
|
|
|
waitForLowActiveIO() |
|
|
|
|
|
|
|
|
|
|
@ -177,16 +173,11 @@ func updateUsage(basePath string, doneCh <-chan struct{}, waitForLowActiveIO fun |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if entry == "" && typ&os.ModeDir != 0 { |
|
|
|
if entry == "" && typ&os.ModeDir != 0 { |
|
|
|
mutex.Lock() |
|
|
|
|
|
|
|
dataUsageInfo.BucketsCount++ |
|
|
|
dataUsageInfo.BucketsCount++ |
|
|
|
dataUsageInfo.BucketsSizes[bucket] = 0 |
|
|
|
dataUsageInfo.BucketsSizes[bucket] = 0 |
|
|
|
mutex.Unlock() |
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mutex.Lock() |
|
|
|
|
|
|
|
defer mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if typ&os.ModeDir != 0 { |
|
|
|
if typ&os.ModeDir != 0 { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|