From c93157019ffecb98c08d7d50a439667e1aa093c2 Mon Sep 17 00:00:00 2001 From: poornas Date: Mon, 2 Mar 2020 19:42:26 -0800 Subject: [PATCH] Allow gc to run in parallel on cache drives (#9051) --- cmd/disk-cache.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index 6c88dd2e1..e6633f12e 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -695,7 +695,6 @@ func newServerCacheObjects(ctx context.Context, config cache.Config) (CacheObjec func (c *cacheObjects) gc(ctx context.Context, doneCh chan struct{}) { ticker := time.NewTicker(cacheGCInterval) - var gcLock sync.Mutex defer ticker.Stop() for { @@ -711,14 +710,12 @@ func (c *cacheObjects) gc(ctx context.Context, doneCh chan struct{}) { if dcache.gcCount() == 0 { continue } - gcLock.Lock() wg.Add(1) - go func(d *diskCache, l *sync.Mutex) { + go func(d *diskCache) { defer wg.Done() d.resetGCCounter() d.purge(ctx, doneCh) - l.Unlock() - }(dcache, &gcLock) + }(dcache) } wg.Wait() }