From 9be7066715197578b62725caf3d619347c4c19c0 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 14 Jan 2020 17:13:58 -0800 Subject: [PATCH] fix: Hold locks before closing all drives (#8818) Fixes #8813 --- cmd/xl-sets.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/xl-sets.go b/cmd/xl-sets.go index 055d5558b..45376801f 100644 --- a/cmd/xl-sets.go +++ b/cmd/xl-sets.go @@ -234,8 +234,6 @@ func (s *xlSets) monitorAndConnectEndpoints(monitorInterval time.Duration) { func (s *xlSets) GetLockers(setIndex int) func() []dsync.NetLocker { return func() []dsync.NetLocker { - s.xlDisksMu.Lock() - defer s.xlDisksMu.Unlock() lockers := make([]dsync.NetLocker, s.drivesPerSet) copy(lockers, s.xlLockers[setIndex]) return lockers @@ -1301,7 +1299,9 @@ func (s *xlSets) ReloadFormat(ctx context.Context, dryRun bool) (err error) { s.format = refFormat // Close all existing disks and reconnect all the disks. + s.xlDisksMu.Lock() s.xlDisks.Close() + s.xlDisksMu.Unlock() s.connectDisks() // Restart monitoring loop to monitor reformatted disks again. @@ -1488,7 +1488,9 @@ func (s *xlSets) HealFormat(ctx context.Context, dryRun bool) (res madmin.HealRe s.format = refFormat // Disconnect/relinquish all existing disks, lockers and reconnect the disks, lockers. + s.xlDisksMu.Lock() s.xlDisks.Close() + s.xlDisksMu.Unlock() s.connectDisks() // Restart our monitoring loop to start monitoring newly formatted disks.