qemu io介绍(三)

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 O_DIRECT flag on its own makes an effort
              to transfer data synchronously, but does not give the
              guarantees of the O_SYNC flag that data and necessary metadata
              are transferred.  To guarantee synchronous I/O, O_SYNC must be
              used in addition to O_DIRECT.  See NOTES below for further
              discussion.
A semantically similar (but deprecated) interface for block
              devices is described in raw(8).
              尽量减少系统cache对IO的影响。一般会降低性能,但是它在一些特定的场景下
              非常的有效,比如用有自己的cache。用户态的buffer会直接写到文件中。
              这个标记会让读写变成同步操作,但是不能保证数据项O_SYNC那种方式
              中把数据真正的写入。为了保证数据的同步,O_DIRECT必须额外的加上O_SYNC
               也就是说,它同步的写入了数据,但是数据可能还在存储设备的缓存中。
              而O_SYNC保证数据写入到了存储中,即使直接把存储断电掉也不会数据丢失。
              因此它需要fsync。

O_DSYNC
              Write operations on the file will complete according to the
              requirements of synchronized I/O data integrity completion.
By the time write(2) (and similar) return, the output data has
              been transferred to the underlying hardware, along with any
              file metadata that would be required to retrieve that data
              (i.e., as though each write(2) was followed by a call to
              fdatasync(2)).  See NOTES below.
O_SYNC
              Write operations on the file will complete according to the
              requirements of synchronized I/O file integrity completion (by
              contrast with the synchronized I/O data integrity completion
              provided by O_DSYNC.)
By the time write(2) (and similar) return, the output data and
              associated file metadata have been transferred to the
              underlying hardware (i.e., as though each write(2) was
              followed by a call to fsync(2)).  See NOTES below.
              文件的写操作将会完成的完成。
              输出的数据和相应的元素都会写入到硬件中,就像后面调用了fsync一样。

 

posted @ 2017-11-18 14:39  你的KPI完成了吗  阅读(466)  评论(0)    收藏  举报