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. 12
      cmd/erasure-server-sets.go
  2. 10
      cmd/erasure.go

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

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

Loading…
Cancel
Save