Using native AIO with qemu-kvm can cause filesystem corruption with sparse images on EXT4
Updated -
This information can also be found in the RHEL 6 Technical Notes
Direct Asynchronous IO (AIO) which is not issued on filesystem block boundaries, and which falls into a hole in a sparse file on ext4 or xfs filesystems, may corrupt file data if multiple IOs modify the same filesystem block. In particular, if qemu-kvm is used with the aio=native IO mode over a sparse device image hosted on the ext4 or xfs filesystem, guest filesystem corruption will occur if partitions are not aligned with the host filesystem block size. In general, do not use aio=native option along with cache=none for QEMU Avoid this potential problem by employing any one of these workarounds: 1) Align AIOs on filesystem block boundaries, or do not write to sparse files using AIO on xfs or ext4 filesystems. 2) KVM: Use a non-sparse system image file or allocate the space by zeroing out the entire file. 3) KVM: Create the image using an ext3 host filesystem instead of ext4. 4) KVM: Invoke qemu-kvm with aio=threads (this is the default). 5) KVM: Align all partitions within the guest image to the host's filesystem block boundary (default 4k).
Comments