mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
fix: a crash when disk is nil, safe access on erasureDisks (#11089)
fixes #11088
This commit is contained in:
parent
9adc33efbb
commit
db7890660e
@ -99,12 +99,18 @@ 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 _, ok := idMap[id]; ok {
|
||||
res = append(res, disk)
|
||||
if disk == OfflineDisk {
|
||||
continue
|
||||
}
|
||||
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.
|
||||
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…
Reference in New Issue
Block a user