Ext3 Data=Ordered vs Data=Writeback mode

From Ext4
(Difference between revisions)
Jump to: navigation, search
(New page)

Revision as of 01:17, 21 July 2009

If a filesystem does not explicitly specify a data ordering mode, and the journal capability allowed it, ext3 used to historically default to 'data=ordered'. This become configurable in 2.6.30, when the configuration option CONFIG_EXT3_DEFAULTS_TO_ORDERED was added. If this CONFIG option is disabled, it will change the default to be data=writeback.

Data=ordered mode is the mode used by most distributions, but can introduce latency problems in some workloads, especially if there is a combination of high bandwidth background writes and foreground processes calling fsync() and waiting for the result. In worst case scenarios, the fsync() call can take 500ms to multiple seconds to return.

However, the problem with using a default of data=writeback, is that is that after a system crash or a power failure, files that were written right before the system went down could contain previously written data or other garbage. With data=ordered mode, journal commits are defferred until the data blocks get written to disk. This guarantees that any blocks in the file will be data written by the application, avoiding a possibility of a security breach, which is especially problematic on a multi-user system. (Note, however, that data=ordered does not guarantee that the file will be consistent at an application level; the application must use fsync() at appropriate commit points in order to guarantee application-level consistency.)

If you have been historically happy with ext3's performance, data=ordered mode will be a safe choice and you should enable CONFIG_EXT3_DEFAULTS_TO_ORDERED. However, if the latency problems are causing problems for you, and you understand the reliability and data privacy issues of data=writeback, you can disable this option.

Filesystems can be forced to use to use a specific data journalling mode by using specifying a mount option on the command line, or in /etc/fstab, or by using the "tune2fs -o journal_data_ordered" or "tune2fs -o journal_data_writeback" to specify a default mount option in the filesystem superblock.

Personal tools