|
|
@ -19,6 +19,7 @@ package cmd |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
|
|
|
|
|
"sync" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/minio/minio/cmd/logger" |
|
|
|
"github.com/minio/minio/cmd/logger" |
|
|
|
"github.com/minio/minio/pkg/bpool" |
|
|
|
"github.com/minio/minio/pkg/bpool" |
|
|
@ -70,26 +71,32 @@ func (d byDiskTotal) Less(i, j int) bool { |
|
|
|
// getDisksInfo - fetch disks info across all other storage API.
|
|
|
|
// getDisksInfo - fetch disks info across all other storage API.
|
|
|
|
func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks int, offlineDisks int) { |
|
|
|
func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks int, offlineDisks int) { |
|
|
|
disksInfo = make([]DiskInfo, len(disks)) |
|
|
|
disksInfo = make([]DiskInfo, len(disks)) |
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
for i, storageDisk := range disks { |
|
|
|
for i, storageDisk := range disks { |
|
|
|
if storageDisk == nil { |
|
|
|
if storageDisk == nil { |
|
|
|
// Storage disk is empty, perhaps ignored disk or not available.
|
|
|
|
// Storage disk is empty, perhaps ignored disk or not available.
|
|
|
|
offlineDisks++ |
|
|
|
offlineDisks++ |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
info, err := storageDisk.DiskInfo() |
|
|
|
wg.Add(1) |
|
|
|
if err != nil { |
|
|
|
go func(id int, sDisk StorageAPI) { |
|
|
|
ctx := context.Background() |
|
|
|
defer wg.Done() |
|
|
|
logger.GetReqInfo(ctx).AppendTags("disk", storageDisk.String()) |
|
|
|
info, err := sDisk.DiskInfo() |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
if err != nil { |
|
|
|
if IsErr(err, baseErrs...) { |
|
|
|
reqInfo := (&logger.ReqInfo{}).AppendTags("disk", sDisk.String()) |
|
|
|
offlineDisks++ |
|
|
|
ctx := logger.SetReqInfo(context.Background(), reqInfo) |
|
|
|
continue |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
|
|
|
|
if IsErr(err, baseErrs...) { |
|
|
|
|
|
|
|
offlineDisks++ |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
onlineDisks++ |
|
|
|
onlineDisks++ |
|
|
|
disksInfo[id] = info |
|
|
|
disksInfo[i] = info |
|
|
|
}(i, storageDisk) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Wait for the routines.
|
|
|
|
|
|
|
|
wg.Wait() |
|
|
|
// Success.
|
|
|
|
// Success.
|
|
|
|
return disksInfo, onlineDisks, offlineDisks |
|
|
|
return disksInfo, onlineDisks, offlineDisks |
|
|
|
} |
|
|
|
} |
|
|
|