fix: crash observed when position of drives different (#9490)

allocate the disk slice properly before populating
disk by its ID and its position.

Fixes #9416
This commit is contained in:
Harshavardhana 2020-04-29 13:42:37 -07:00 committed by GitHub
parent da87188ff8
commit c2529260e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -333,12 +333,15 @@ func newXLSets(ctx context.Context, endpoints Endpoints, storageDisks []StorageA
for i := 0; i < setCount; i++ {
s.xlDisks[i] = make([]StorageAPI, drivesPerSet)
s.xlLockers[i] = make([]dsync.NetLocker, drivesPerSet)
}
for i := 0; i < setCount; i++ {
var endpoints Endpoints
for j := 0; j < drivesPerSet; j++ {
endpoints = append(endpoints, s.endpoints[i*drivesPerSet+j])
// Rely on endpoints list to initialize, init lockers and available disks.
s.xlLockers[i][j] = newLockAPI(s.endpoints[i*drivesPerSet+j])
disk := storageDisks[i*drivesPerSet+j]
if disk == nil {
continue