mirror of
https://github.com/minio/minio.git
synced 2025-04-30 06:31:32 -04:00
fallback O_DIRECT if not supported, do regular reads() (#13680)
This commit is contained in:
parent
3d2bc15e9a
commit
9c5d9ae376
@ -19,6 +19,7 @@ package ioutil
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/minio/minio/internal/disk"
|
"github.com/minio/minio/internal/disk"
|
||||||
)
|
)
|
||||||
@ -32,7 +33,12 @@ import (
|
|||||||
func ReadFile(name string) ([]byte, error) {
|
func ReadFile(name string) ([]byte, error) {
|
||||||
f, err := disk.OpenFileDirectIO(name, readMode, 0666)
|
f, err := disk.OpenFileDirectIO(name, readMode, 0666)
|
||||||
if err != nil {
|
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{
|
r := &ODirectReader{
|
||||||
File: f,
|
File: f,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user