https://access.redhat.com/solutions/696903
SOLUTION UNVERIFIED - 已更新 2015年二月8日10:36 -
环境
- Red Hat Enterprise Linux (ALL)
问题
- Is there any command available to enable O_DIRECT on a ext4 filesystem ?
- How to enable O_DIRECT on any file system, so that data is directly written to disk without using the cache?
决议
O_DIRECT
is neither a filesystem feature nor there is a command to enable the same.O_DIRECT
is a status flag passed tofcntl(2)
by an application while opening a file or creating a file.
根源
O_DIRECT
is not a file system wide option and is a status flag which is passed by the application while opening/creating a file.
From man open(2)
O_DIRECT (Since Linux 2.4.10)
Try to minimize cache effects of the I/O to and from this file. In general this will degrade performance, but it is useful
in special situations, such as when applications do their own caching. File I/O is done directly to/from user space
buffers. The I/O is synchronous, that is, at the completion of a read(2) or write(2), data is guaranteed to have been
transferred.