From 1813ff9dfae5d0322bf5b17ae35ce84d8a000f99 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Wed, 17 Jun 2020 08:54:41 -0700 Subject: [PATCH] Re-add missing bucket bloom filters (#9861) --- cmd/data-update-tracker.go | 4 ++-- cmd/erasure.go | 17 +++++++++++++++-- cmd/fs-v1.go | 5 +---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cmd/data-update-tracker.go b/cmd/data-update-tracker.go index be96e133c..1b59f328f 100644 --- a/cmd/data-update-tracker.go +++ b/cmd/data-update-tracker.go @@ -120,8 +120,8 @@ func (b bloomFilter) containsDir(in string) bool { } // bytes returns the bloom filter serialized as a byte slice. -func (b bloomFilter) bytes() []byte { - if b.BloomFilter == nil { +func (b *bloomFilter) bytes() []byte { + if b == nil || b.BloomFilter == nil { return nil } var buf bytes.Buffer diff --git a/cmd/erasure.go b/cmd/erasure.go index 22e2484f0..a38b4eb27 100644 --- a/cmd/erasure.go +++ b/cmd/erasure.go @@ -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) { diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index a39678acb..04b9d698f 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -248,10 +248,7 @@ func (fs *FSObjects) CrawlAndGetDataUsage(ctx context.Context, bf *bloomFilter, if err != nil { return err } - totalCache.Info.BloomFilter = nil - if bf != nil { - totalCache.Info.BloomFilter = bf.bytes() - } + totalCache.Info.BloomFilter = bf.bytes() // Clear totals. var root dataUsageEntry