|
|
|
@ -25,6 +25,7 @@ import ( |
|
|
|
|
|
|
|
|
|
"github.com/minio/minio/cmd/logger" |
|
|
|
|
"github.com/minio/minio/pkg/bpool" |
|
|
|
|
"github.com/minio/minio/pkg/color" |
|
|
|
|
"github.com/minio/minio/pkg/dsync" |
|
|
|
|
"github.com/minio/minio/pkg/madmin" |
|
|
|
|
"github.com/minio/minio/pkg/sync/errgroup" |
|
|
|
@ -260,6 +261,7 @@ func (er erasureObjects) crawlAndGetDataUsage(ctx context.Context, buckets []Buc |
|
|
|
|
}, |
|
|
|
|
Cache: make(map[string]dataUsageEntry, len(oldCache.Cache)), |
|
|
|
|
} |
|
|
|
|
bloom := bf.bytes() |
|
|
|
|
|
|
|
|
|
// Put all buckets into channel.
|
|
|
|
|
bucketCh := make(chan BucketInfo, len(buckets)) |
|
|
|
@ -269,12 +271,21 @@ func (er erasureObjects) crawlAndGetDataUsage(ctx context.Context, buckets []Buc |
|
|
|
|
bucketCh <- b |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Add existing buckets.
|
|
|
|
|
|
|
|
|
|
// Add existing buckets if changes or lifecycles.
|
|
|
|
|
for _, b := range buckets { |
|
|
|
|
e := oldCache.find(b.Name) |
|
|
|
|
if e != nil { |
|
|
|
|
bucketCh <- b |
|
|
|
|
cache.replace(b.Name, dataUsageRoot, *e) |
|
|
|
|
lc, err := globalLifecycleSys.Get(b.Name) |
|
|
|
|
activeLC := err == nil && lc.HasActiveRules("", true) |
|
|
|
|
if activeLC || bf == nil || bf.containsDir(b.Name) { |
|
|
|
|
bucketCh <- b |
|
|
|
|
} else { |
|
|
|
|
if intDataUpdateTracker.debug { |
|
|
|
|
logger.Info(color.Green("crawlAndGetDataUsage:")+" Skipping bucket %v, not updated", b.Name) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -342,6 +353,7 @@ func (er erasureObjects) crawlAndGetDataUsage(ctx context.Context, buckets []Buc |
|
|
|
|
if cache.Info.Name == "" { |
|
|
|
|
cache.Info.Name = bucket.Name |
|
|
|
|
} |
|
|
|
|
cache.Info.BloomFilter = bloom |
|
|
|
|
if cache.Info.Name != bucket.Name { |
|
|
|
|
logger.LogIf(ctx, fmt.Errorf("cache name mismatch: %s != %s", cache.Info.Name, bucket.Name)) |
|
|
|
|
cache.Info = dataUsageCacheInfo{ |
|
|
|
@ -354,6 +366,7 @@ func (er erasureObjects) crawlAndGetDataUsage(ctx context.Context, buckets []Buc |
|
|
|
|
// Calc usage
|
|
|
|
|
before := cache.Info.LastUpdate |
|
|
|
|
cache, err = disk.CrawlAndGetDataUsage(ctx, cache) |
|
|
|
|
cache.Info.BloomFilter = nil |
|
|
|
|
if err != nil { |
|
|
|
|
logger.LogIf(ctx, err) |
|
|
|
|
if cache.Info.LastUpdate.After(before) { |
|
|
|
|