github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/disk/directio_unsupported.go (about) 1 //go:build windows || openbsd || plan9 2 3 // Copyright (c) 2015-2023 MinIO, Inc. 4 // 5 // This file is part of MinIO Object Storage stack 6 // 7 // This program is free software: you can redistribute it and/or modify 8 // it under the terms of the GNU Affero General Public License as published by 9 // the Free Software Foundation, either version 3 of the License, or 10 // (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU Affero General Public License for more details. 16 // 17 // You should have received a copy of the GNU Affero General Public License 18 // along with this program. If not, see <http://www.gnu.org/licenses/>. 19 20 package disk 21 22 import ( 23 "os" 24 ) 25 26 // ODirectPlatform indicates if the platform supports O_DIRECT 27 const ODirectPlatform = false 28 29 // OpenBSD, Windows, and illumos do not support O_DIRECT. 30 // On Windows there is no documentation on disabling O_DIRECT. 31 // For these systems we do not attempt to build the 'directio' dependency since 32 // the O_DIRECT symbol may not be exposed resulting in a failed build. 33 // 34 // 35 // On illumos an explicit O_DIRECT flag is not necessary for two primary 36 // reasons. Note that ZFS is effectively the default filesystem on illumos 37 // systems. 38 // 39 // One benefit of using DirectIO on Linux is that the page cache will not be 40 // polluted with single-access data. The ZFS read cache (ARC) is scan-resistant 41 // so there is no risk of polluting the entire cache with data accessed once. 42 // Another goal of DirectIO is to minimize the mutation of data by the kernel 43 // before issuing IO to underlying devices. ZFS users often enable features like 44 // compression and checksumming which currently necessitates mutating data in 45 // the kernel. 46 // 47 // DirectIO semantics for a filesystem like ZFS would be quite different than 48 // the semantics on filesystems like XFS, and these semantics are not 49 // implemented at this time. 50 // For more information on why typical DirectIO semantics do not apply to ZFS 51 // see this ZFS-on-Linux commit message: 52 // https://github.com/openzfs/zfs/commit/a584ef26053065f486d46a7335bea222cb03eeea 53 54 // OpenFileDirectIO wrapper around os.OpenFile nothing special 55 func OpenFileDirectIO(filePath string, flag int, perm os.FileMode) (*os.File, error) { 56 return os.OpenFile(filePath, flag, perm) 57 } 58 59 // DisableDirectIO is a no-op 60 func DisableDirectIO(f *os.File) error { 61 return nil 62 } 63 64 // AlignedBlock simply returns an unaligned buffer 65 // for systems that do not support DirectIO. 66 func AlignedBlock(blockSize int) []byte { 67 return make([]byte, blockSize) 68 }