storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/disk/directio_unsupported.go (about) 1 //go:build !linux && !netbsd && !freebsd && !darwin 2 // +build !linux,!netbsd,!freebsd,!darwin 3 4 /* 5 * Minio Cloud Storage, (C) 2019-2020 Minio, Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package disk 21 22 import ( 23 "os" 24 ) 25 26 // OpenBSD, Windows, and illumos do not support O_DIRECT. 27 // On Windows there is no documentation on disabling O_DIRECT. 28 // For these systems we do not attempt to build the 'directio' dependency since 29 // the O_DIRECT symbol may not be exposed resulting in a failed build. 30 // 31 // 32 // On illumos an explicit O_DIRECT flag is not necessary for two primary 33 // reasons. Note that ZFS is effectively the default filesystem on illumos 34 // systems. 35 // 36 // One benefit of using DirectIO on Linux is that the page cache will not be 37 // polluted with single-access data. The ZFS read cache (ARC) is scan-resistant 38 // so there is no risk of polluting the entire cache with data accessed once. 39 // Another goal of DirectIO is to minimize the mutation of data by the kernel 40 // before issuing IO to underlying devices. ZFS users often enable features like 41 // compression and checksumming which currently necessitates mutating data in 42 // the kernel. 43 // 44 // DirectIO semantics for a filesystem like ZFS would be quite different than 45 // the semantics on filesystems like XFS, and these semantics are not 46 // implemented at this time. 47 // For more information on why typical DirectIO semantics do not apply to ZFS 48 // see this ZFS-on-Linux commit message: 49 // https://github.com/openzfs/zfs/commit/a584ef26053065f486d46a7335bea222cb03eeea 50 51 // OpenFileDirectIO wrapper around os.OpenFile nothing special 52 func OpenFileDirectIO(filePath string, flag int, perm os.FileMode) (*os.File, error) { 53 return os.OpenFile(filePath, flag, perm) 54 } 55 56 // DisableDirectIO is a no-op 57 func DisableDirectIO(f *os.File) error { 58 return nil 59 } 60 61 // AlignedBlock simply returns an unaligned buffer 62 // for systems that do not support DirectIO. 63 func AlignedBlock(BlockSize int) []byte { 64 return make([]byte, BlockSize) 65 }