|
|
@ -34,6 +34,8 @@ const ( |
|
|
|
xlMetaV1File = "file.json" |
|
|
|
xlMetaV1File = "file.json" |
|
|
|
// Maximum erasure blocks.
|
|
|
|
// Maximum erasure blocks.
|
|
|
|
maxErasureBlocks = 16 |
|
|
|
maxErasureBlocks = 16 |
|
|
|
|
|
|
|
// Minimum erasure blocks.
|
|
|
|
|
|
|
|
minErasureBlocks = 8 |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// XL layer structure.
|
|
|
|
// XL layer structure.
|
|
|
@ -51,18 +53,22 @@ func newXL(disks ...string) (StorageAPI, error) { |
|
|
|
// Initialize XL.
|
|
|
|
// Initialize XL.
|
|
|
|
xl := &XL{} |
|
|
|
xl := &XL{} |
|
|
|
|
|
|
|
|
|
|
|
// Verify disks.
|
|
|
|
// Verify total number of disks.
|
|
|
|
totalDisks := len(disks) |
|
|
|
totalDisks := len(disks) |
|
|
|
if totalDisks > maxErasureBlocks { |
|
|
|
if totalDisks > maxErasureBlocks { |
|
|
|
return nil, errMaxDisks |
|
|
|
return nil, errMaxDisks |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if totalDisks < minErasureBlocks { |
|
|
|
|
|
|
|
return nil, errMinDisks |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// isEven function to verify if a given number if even.
|
|
|
|
// isEven function to verify if a given number if even.
|
|
|
|
isEven := func(number int) bool { |
|
|
|
isEven := func(number int) bool { |
|
|
|
return number%2 == 0 |
|
|
|
return number%2 == 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: verify if this makes sense in future.
|
|
|
|
// Verify if we have even number of disks.
|
|
|
|
|
|
|
|
// only combination of 8, 10, 12, 14, 16 are supported.
|
|
|
|
if !isEven(totalDisks) { |
|
|
|
if !isEven(totalDisks) { |
|
|
|
return nil, errNumDisks |
|
|
|
return nil, errNumDisks |
|
|
|
} |
|
|
|
} |
|
|
@ -85,8 +91,13 @@ func newXL(disks ...string) (StorageAPI, error) { |
|
|
|
storageDisks := make([]StorageAPI, len(disks)) |
|
|
|
storageDisks := make([]StorageAPI, len(disks)) |
|
|
|
for index, disk := range disks { |
|
|
|
for index, disk := range disks { |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
|
|
|
|
// Intentionally ignore disk not found errors while
|
|
|
|
|
|
|
|
// initializing POSIX, so that we have successfully
|
|
|
|
|
|
|
|
// initialized posix Storage.
|
|
|
|
|
|
|
|
// Subsequent calls to XL/Erasure will manage any errors
|
|
|
|
|
|
|
|
// related to disks.
|
|
|
|
storageDisks[index], err = newPosix(disk) |
|
|
|
storageDisks[index], err = newPosix(disk) |
|
|
|
if err != nil { |
|
|
|
if err != nil && err != errDiskNotFound { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -153,6 +164,9 @@ func (xl XL) MakeVol(volume string) error { |
|
|
|
|
|
|
|
|
|
|
|
// Make a volume entry on all underlying storage disks.
|
|
|
|
// Make a volume entry on all underlying storage disks.
|
|
|
|
for index, disk := range xl.storageDisks { |
|
|
|
for index, disk := range xl.storageDisks { |
|
|
|
|
|
|
|
if disk == nil { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
wg.Add(1) |
|
|
|
wg.Add(1) |
|
|
|
// Make a volume inside a go-routine.
|
|
|
|
// Make a volume inside a go-routine.
|
|
|
|
go func(index int, disk StorageAPI) { |
|
|
|
go func(index int, disk StorageAPI) { |
|
|
|