mirror of https://github.com/minio/minio.git
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:
parent
9c0e8cd15b
commit
f13cfcb83e
|
@ -284,16 +284,18 @@ func newXLStorage(ep Endpoint, cleanUp bool) (s *xlStorage, err error) {
|
|||
s.formatLegacy = format.Erasure.DistributionAlgo == formatErasureVersionV2DistributionAlgoV1
|
||||
}
|
||||
|
||||
// Return an error if ODirect is not supported
|
||||
// unless it is a single erasure disk mode
|
||||
if err := s.checkODirectDiskSupport(); err == nil {
|
||||
s.oDirect = true
|
||||
} else {
|
||||
// Allow if unsupported platform or single disk.
|
||||
if errors.Is(err, errUnsupportedDisk) && globalIsErasureSD || !disk.ODirectPlatform {
|
||||
s.oDirect = false
|
||||
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 {
|
||||
s.oDirect = true
|
||||
} else {
|
||||
return s, err
|
||||
// Allow if unsupported platform or single disk.
|
||||
if errors.Is(err, errUnsupportedDisk) && globalIsErasureSD || !disk.ODirectPlatform {
|
||||
s.oDirect = false
|
||||
} else {
|
||||
return s, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue