From 4bda4e4e2b6be4240707d77b73134962392849c5 Mon Sep 17 00:00:00 2001 From: Aditya Manthramurthy Date: Thu, 5 Oct 2023 19:54:49 -0700 Subject: [PATCH] fix: check for disk-level O_DIRECT support (#18173) Disk level O_DIRECT support checking at xl storage initialization was conditional on a config setting being enabled. (This never took effect because config initialization happens after ObjectLayer is ready.) This is not necessary as the config setting is dynamic - O_DIRECT should be enabled via runtime config. So we need to do the disk level support check regardless of the config setting. --- cmd/xl-storage.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index c42ac77ef..15ee9a9b9 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -290,18 +290,16 @@ func newXLStorage(ep Endpoint, cleanUp bool) (s *xlStorage, err error) { s.formatLegacy = format.Erasure.DistributionAlgo == formatErasureVersionV2DistributionAlgoV1 } - if globalAPIConfig.odirectEnabled() { - // 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 + // 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 } 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 } }