allow disabling O_DIRECT for write ops (#17751)

on really slow systems, O_DIRECT simply kills the drives
allow for a way to disable them.
This commit is contained in:
Harshavardhana 2023-07-29 15:17:56 -07:00 committed by GitHub
parent 9c0e8cd15b
commit f13cfcb83e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -284,6 +284,7 @@ func newXLStorage(ep Endpoint, cleanUp bool) (s *xlStorage, err error) {
s.formatLegacy = format.Erasure.DistributionAlgo == formatErasureVersionV2DistributionAlgoV1
}
if !globalAPIConfig.isDisableODirect() {
// Return an error if ODirect is not supported
// unless it is a single erasure disk mode
if err := s.checkODirectDiskSupport(); err == nil {
@ -296,6 +297,7 @@ func newXLStorage(ep Endpoint, cleanUp bool) (s *xlStorage, err error) {
return s, err
}
}
}
// Success.
return s, nil
@ -1896,7 +1898,8 @@ func (s *xlStorage) writeAllDirect(ctx context.Context, filePath string, fileSiz
return osErrToFileErr(err)
}
odirectEnabled := s.oDirect
odirectEnabled := !globalAPIConfig.isDisableODirect() && s.oDirect
var w *os.File
if odirectEnabled {
w, err = OpenFileDirectIO(filePath, flags, 0o666)

View File

@ -94,7 +94,7 @@ var (
},
config.HelpKV{
Key: apiDisableODirect,
Description: "set to disable O_DIRECT for reads under special conditions. NOTE: it is not recommended to disable O_DIRECT without prior testing" + defaultHelpPostfix(apiDisableODirect),
Description: "set to disable O_DIRECT for read and writes under special conditions. NOTE: it is not recommended to disable O_DIRECT without prior testing" + defaultHelpPostfix(apiDisableODirect),
Optional: true,
Type: "boolean",
},