fix: ignore faulty drives and continue (#10511)

drives might return different types of errors
handle them individually, and for some errors
just log an error and continue
This commit is contained in:
Harshavardhana
2020-09-18 12:09:05 -07:00
committed by GitHub
parent 1cf322b7d4
commit 7f9498f43f
5 changed files with 45 additions and 32 deletions

View File

@@ -176,15 +176,6 @@ func getValidPath(path string, requireDirectIO bool) (string, error) {
return path, errDiskNotDir
}
di, err := getDiskInfo(path)
if err != nil {
return path, err
}
if err = checkDiskMinTotal(di); err != nil {
return path, err
}
// check if backend is writable.
var rnd [8]byte
_, _ = rand.Read(rnd[:])
@@ -195,6 +186,7 @@ func getValidPath(path string, requireDirectIO bool) (string, error) {
var file *os.File
if requireDirectIO {
// only erasure coding needs direct-io support
file, err = disk.OpenFileDirectIO(fn, os.O_CREATE|os.O_EXCL, 0666)
} else {
file, err = os.OpenFile(fn, os.O_CREATE|os.O_EXCL, 0666)
@@ -204,12 +196,22 @@ func getValidPath(path string, requireDirectIO bool) (string, error) {
// if direct i/o failed.
if err != nil {
if isSysErrInvalidArg(err) {
// O_DIRECT not supported
return path, errUnsupportedDisk
}
return path, err
return path, osErrToFileErr(err)
}
file.Close()
di, err := getDiskInfo(path)
if err != nil {
return path, err
}
if err = checkDiskMinTotal(di); err != nil {
return path, err
}
return path, nil
}