From 5b2ced01191adbeb1ece99625581f76037d5bcbc Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 29 Dec 2023 09:30:10 -0800 Subject: [PATCH] re-use globalLocalDrives properly (#18721) --- cmd/erasure-sets.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index 0d4a1ecbe..663fed580 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -262,9 +262,11 @@ func (s *erasureSets) connectDisks() { s.erasureDisks[setIndex][diskIndex] = disk s.erasureDisksMu.Unlock() - globalLocalDrivesMu.Lock() - globalLocalSetDrives[s.poolIndex][setIndex][diskIndex] = disk - globalLocalDrivesMu.Unlock() + if disk.IsLocal() && globalIsDistErasure { + globalLocalDrivesMu.Lock() + globalLocalSetDrives[s.poolIndex][setIndex][diskIndex] = disk + globalLocalDrivesMu.Unlock() + } }(endpoint) } @@ -403,6 +405,18 @@ func newErasureSets(ctx context.Context, endpoints PoolEndpoints, storageDisks [ if disk == nil { continue } + + if disk.IsLocal() && globalIsDistErasure { + globalLocalDrivesMu.RLock() + ldisk := globalLocalSetDrives[poolIdx][i][j] + if ldisk == nil { + globalLocalDrivesMu.RUnlock() + continue + } + disk = ldisk + globalLocalDrivesMu.RUnlock() + } + innerWg.Add(1) go func(disk StorageAPI, i, j int) { defer innerWg.Done()