环境

  • Red Hat Enterprise Linux 6
  • EXT4 Filesystem

问题

  • Does EXT4 support asynchronous I/O or direct I/O?
  • If EXT4 supports these features, how are they used?

决议

  • EXT4 file system supports both the asynchronous I/O and the Direct I/O features.
  • By default, asynchronous I/O is enabled.
  • If Direct I/O is needed, the application should use the O_DIRECT flag while doing the 'open()' system call.
  • If Direct I/O has to be used with an existing EXT4 filesystem, the 'sync' mount option should be used both while mounting manually, and when mounting via the /etc/fstab file for boot time activation.

NOTE: If both Direct I/O (DIO) and the 'sync' options are used, file performance will be decreased because the file system will over-ride the use of the kernel page cache. This increases the I/O calls to the underlying disk, which is hundreds of times slower than accessing data via the primary L1-L2 caches. It is best to understand the consequences/drawbacks of DIO prior to implementing it.