fix: a crash when disk is nil, safe access on erasureDisks (#11089)

fixes #11088
master
Harshavardhana 4 years ago committed by GitHub
parent 9adc33efbb
commit db7890660e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      cmd/erasure-server-sets.go
  2. 10
      cmd/erasure.go

@ -99,12 +99,18 @@ func (z *erasureServerPools) GetDisksID(ids ...string) []StorageAPI {
idMap[id] = struct{}{} idMap[id] = struct{}{}
} }
res := make([]StorageAPI, 0, len(idMap)) res := make([]StorageAPI, 0, len(idMap))
for _, ss := range z.serverPools { for _, s := range z.serverPools {
for _, disks := range ss.erasureDisks { s.erasureDisksMu.RLock()
defer s.erasureDisksMu.RUnlock()
for _, disks := range s.erasureDisks {
for _, disk := range disks { for _, disk := range disks {
id, _ := disk.GetDiskID() if disk == OfflineDisk {
if _, ok := idMap[id]; ok { continue
res = append(res, disk) }
if id, _ := disk.GetDiskID(); id != "" {
if _, ok := idMap[id]; ok {
res = append(res, disk)
}
} }
} }
} }

@ -251,10 +251,14 @@ func (er erasureObjects) crawlAndGetDataUsage(ctx context.Context, buckets []Buc
// Collect disks for healing. // Collect disks for healing.
allDisks := er.getDisks() allDisks := er.getDisks()
allDiskIDs := make([]string, len(allDisks)) allDiskIDs := make([]string, 0, len(allDisks))
for i, disk := range allDisks { for _, disk := range allDisks {
if disk == OfflineDisk {
// its possible that disk is OfflineDisk
continue
}
id, _ := disk.GetDiskID() id, _ := disk.GetDiskID()
allDiskIDs[i] = id allDiskIDs = append(allDiskIDs, id)
} }
// Load bucket totals // Load bucket totals

Loading…
Cancel
Save