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