The task is to support InnoDB/XtraDB atomic writes without using doublewrite buffer. The benefits of of it is better latency, and superior flash endurance. This approach also reduces write amplification on flash devices.
To support atomic writes, new boolean configuration option innodb_use_atomic_writes will be added . (default OFF).
Following happens if innodb_use_atomic_writes is ON (this should be done only on a system that supports atomic writes) :
innodb_use_doublewrite is switched OFF (since writes are atomic)
innodb_file_flush_method to O_DIRECT, unless already set to O_DIRECT or ALL_O_DIRECT, or to O_DIRECT_NO_FSYNC in 5.6.
The option causes Innodb to use posix_fallocate for file preallocation and extension. The reason behind it
is that atomic write option does not currently work for writes behind the end of file.
Upon opening Innodb data files, InnoDB/XtraDB will issue ioctl (DFS_IOCTL_ATOMIC_WRITE_SET). This new ioctl hints underlying filesystem to transparently convert normal writes (via pwrite(), write(), io_submit() calls) to atomic writes which is guaranteed by the underlying device. In case of ioctl() failure, opening of data file fails, and an error is returned to the calling code with a message written in the log file. In case the data file is system tablespace(ibdata1), mysqld does not start.
Currently only directFS file system supports atomics, however this approach is potentially extensible to other filesystems/devices choose to provide this functionality.
We'll need following define to InnoDB/XtraDB.
#define DFS_IOCTL_ATOMIC_WRITE_SET _IOW(0x95, 2, uint)