mirror of
https://github.com/minio/minio.git
synced 2025-01-22 20:23:14 -05:00
Fix hasSpaceFor in SNSD setup (#17630)
If drive is offline or filled we divide by 0. Fixes #17629 Bonus: Reject when any valid disk exceeds minimum inode threshold.
This commit is contained in:
parent
f64d62b01d
commit
9885a0a6af
@ -1166,7 +1166,7 @@ func hasSpaceFor(di []*DiskInfo, size int64) (bool, error) {
|
|||||||
var total uint64
|
var total uint64
|
||||||
var nDisks int
|
var nDisks int
|
||||||
for _, disk := range di {
|
for _, disk := range di {
|
||||||
if disk == nil || disk.Total == 0 || (disk.FreeInodes < diskMinInodes && disk.UsedInodes > 0) {
|
if disk == nil || disk.Total == 0 {
|
||||||
// Disk offline, no inodes or something else is wrong.
|
// Disk offline, no inodes or something else is wrong.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -1175,16 +1175,20 @@ func hasSpaceFor(di []*DiskInfo, size int64) (bool, error) {
|
|||||||
available += disk.Total - disk.Used
|
available += disk.Total - disk.Used
|
||||||
}
|
}
|
||||||
|
|
||||||
if nDisks < len(di)/2 {
|
if nDisks < len(di)/2 || nDisks <= 0 {
|
||||||
return false, fmt.Errorf("not enough online disks to calculate the available space, expected (%d)/(%d)", (len(di)/2)+1, nDisks)
|
return false, fmt.Errorf("not enough online disks to calculate the available space, expected (%d)/(%d)", (len(di)/2)+1, nDisks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check we have enough on each disk, ignoring diskFillFraction.
|
// Check we have enough on each disk, ignoring diskFillFraction.
|
||||||
perDisk := size / int64(nDisks)
|
perDisk := size / int64(nDisks)
|
||||||
for _, disk := range di {
|
for _, disk := range di {
|
||||||
if disk == nil || disk.Total == 0 || (disk.FreeInodes < diskMinInodes && disk.UsedInodes > 0) {
|
if disk == nil || disk.Total == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if disk.FreeInodes < diskMinInodes && disk.UsedInodes > 0 {
|
||||||
|
// We have an inode count, but not enough inodes.
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
if int64(disk.Free) <= perDisk {
|
if int64(disk.Free) <= perDisk {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user