mirror of https://github.com/minio/minio.git
Healing process should not heal root disk (#7089)
This commit is contained in:
parent
e8c18bc145
commit
82af0be1aa
22
cmd/posix.go
22
cmd/posix.go
|
@ -303,9 +303,10 @@ func (s *posix) IsOnline() bool {
|
||||||
// DiskInfo is an extended type which returns current
|
// DiskInfo is an extended type which returns current
|
||||||
// disk usage per path.
|
// disk usage per path.
|
||||||
type DiskInfo struct {
|
type DiskInfo struct {
|
||||||
Total uint64
|
Total uint64
|
||||||
Free uint64
|
Free uint64
|
||||||
Used uint64
|
Used uint64
|
||||||
|
RootDisk bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskInfo provides current information about disk space usage,
|
// DiskInfo provides current information about disk space usage,
|
||||||
|
@ -319,12 +320,17 @@ func (s *posix) DiskInfo() (info DiskInfo, err error) {
|
||||||
if !s.diskMount {
|
if !s.diskMount {
|
||||||
used = atomic.LoadUint64(&s.totalUsed)
|
used = atomic.LoadUint64(&s.totalUsed)
|
||||||
}
|
}
|
||||||
return DiskInfo{
|
|
||||||
Total: di.Total,
|
|
||||||
Free: di.Free,
|
|
||||||
Used: used,
|
|
||||||
}, nil
|
|
||||||
|
|
||||||
|
rootDisk, err := disk.IsRootDisk(s.diskPath)
|
||||||
|
if err != nil {
|
||||||
|
return info, err
|
||||||
|
}
|
||||||
|
return DiskInfo{
|
||||||
|
Total: di.Total,
|
||||||
|
Free: di.Free,
|
||||||
|
Used: used,
|
||||||
|
RootDisk: rootDisk,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getVolDir - will convert incoming volume names to
|
// getVolDir - will convert incoming volume names to
|
||||||
|
|
|
@ -1029,6 +1029,18 @@ func (s *xlSets) HealFormat(ctx context.Context, dryRun bool) (res madmin.HealRe
|
||||||
}
|
}
|
||||||
}(storageDisks)
|
}(storageDisks)
|
||||||
|
|
||||||
|
for i, disk := range storageDisks {
|
||||||
|
info, err := disk.DiskInfo()
|
||||||
|
if err != nil {
|
||||||
|
storageDisks[i] = nil
|
||||||
|
}
|
||||||
|
if info.RootDisk {
|
||||||
|
// We should not heal on root disk. i.e in a situation where the minio-administrator has unmounted a
|
||||||
|
// defective drive we should not heal a path on the root disk.
|
||||||
|
storageDisks[i] = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
formats, sErrs := loadFormatXLAll(storageDisks)
|
formats, sErrs := loadFormatXLAll(storageDisks)
|
||||||
if err = checkFormatXLValues(formats); err != nil {
|
if err = checkFormatXLValues(formats); err != nil {
|
||||||
return madmin.HealResultItem{}, err
|
return madmin.HealResultItem{}, err
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package disk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsRootDisk returns if diskPath belongs to root-disk, i.e the disk mounted at "/"
|
||||||
|
func IsRootDisk(diskPath string) (bool, error) {
|
||||||
|
rootDisk := false
|
||||||
|
diskInfo, err := os.Stat(diskPath)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
rootInfo, err := os.Stat("/")
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
diskStat, diskStatOK := diskInfo.Sys().(*syscall.Stat_t)
|
||||||
|
rootStat, rootStatOK := rootInfo.Sys().(*syscall.Stat_t)
|
||||||
|
if diskStatOK && rootStatOK {
|
||||||
|
if diskStat.Dev == rootStat.Dev {
|
||||||
|
// Indicate if the disk path is on root disk. This is used to indicate the healing
|
||||||
|
// process not to format the drive and end up healing it.
|
||||||
|
rootDisk = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rootDisk, nil
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
// +build windows
|
||||||
|
|
||||||
|
package disk
|
||||||
|
|
||||||
|
// IsRootDisk returns if diskPath belongs to root-disk, i.e the disk mounted at "/"
|
||||||
|
func IsRootDisk(diskPath string) (bool, error) {
|
||||||
|
// On windows a disk can never be mounted on a subpath.
|
||||||
|
return false, nil
|
||||||
|
}
|
Loading…
Reference in New Issue