fallback O_DIRECT if not supported, do regular reads() (#13680)

This commit is contained in:
Harshavardhana 2021-11-17 15:48:47 -08:00 committed by GitHub
parent 3d2bc15e9a
commit 9c5d9ae376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ package ioutil
import (
"io"
"os"
"github.com/minio/minio/internal/disk"
)
@ -32,7 +33,12 @@ import (
func ReadFile(name string) ([]byte, error) {
f, err := disk.OpenFileDirectIO(name, readMode, 0666)
if err != nil {
return nil, err
// fallback if there is an error to read
// 'name' with O_DIRECT
f, err = os.OpenFile(name, readMode, 0666)
if err != nil {
return nil, err
}
}
r := &ODirectReader{
File: f,