From 2b4531f069958d913411aac24ec28e5e705f591b Mon Sep 17 00:00:00 2001 From: Aditya Manthramurthy Date: Mon, 9 Oct 2023 17:08:40 -0700 Subject: [PATCH] fix: O_DIRECT is on only for multi-disk setups (#18194) Disable it for single disk/unsupported platforms --- cmd/xl-storage.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index 15ee9a9b9..86f14d898 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -290,17 +290,14 @@ 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 { + // Return an error if ODirect is not supported. Single disk will have + // oDirect off. + if globalIsErasureSD || !disk.ODirectPlatform { + s.oDirect = false + } else 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 - } else { - return s, err - } + return s, err } // Success.