disable check for DirectIO in standalone FS mode (#9558)

This commit is contained in:
Anis Elleuch 2020-05-08 20:07:51 +01:00 committed by GitHub
parent 0f1389e992
commit 6885c72f32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -129,12 +129,9 @@ func NewFSObjectLayer(fsPath string) (ObjectLayer, error) {
}
var err error
if fsPath, err = getValidPath(fsPath); err != nil {
if fsPath, err = getValidPath(fsPath, false); err != nil {
if err == errMinDiskSize {
return nil, config.ErrUnableToWriteInBackend(err).Hint(err.Error())
} else if err == errUnsupportedDisk {
hint := fmt.Sprintf("'%s' does not support O_DIRECT flags, refusing to use", fsPath)
return nil, config.ErrUnsupportedBackend(err).Hint(hint)
}
// Show a descriptive error with a hint about how to fix it.

View File

@ -140,7 +140,7 @@ func checkPathLength(pathName string) error {
return nil
}
func getValidPath(path string) (string, error) {
func getValidPath(path string, requireDirectIO bool) (string, error) {
if path == "" {
return path, errInvalidArgument
}
@ -181,9 +181,16 @@ func getValidPath(path string) (string, error) {
fn := pathJoin(path, ".writable-check-"+hex.EncodeToString(rnd[:])+".tmp")
defer os.Remove(fn)
var file *os.File
if requireDirectIO {
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)
}
// open file in direct I/O and use default umask, this also verifies
// if direct i/o failed.
file, err := disk.OpenFileDirectIO(fn, os.O_CREATE|os.O_EXCL, 0666)
if err != nil {
if isSysErrInvalidArg(err) {
return path, errUnsupportedDisk
@ -222,7 +229,7 @@ func isDirEmpty(dirname string) bool {
// Initialize a new storage disk.
func newPosix(path string) (*posix, error) {
var err error
if path, err = getValidPath(path); err != nil {
if path, err = getValidPath(path, true); err != nil {
return nil, err
}
_, err = os.Stat(path)