Data inconsistency on LVM logical volume mounted as partition on ubuntu guest, when the written file's size is equal or greater than 27G. Description of problem: On the guest, writing a 27Gib file or larger result in inconsistent file checksum upon subsequent read. Steps to reproduce: **On the host** 0. Create a LVM logical volume on a Linux RAID 1 (with 1 disk only) ``` --- Logical volume --- LV Path /dev/davidahw2-vg4/lv0 LV Name lv0 VG Name davidahw2-vg4 LV UUID 5FbDcl-eSDe-7cXL-22tj-Lg6O-79AL-4Gq7gx LV Write Access read/write LV Creation host, time davida-hw2, 2021-12-06 16:45:00 +0800 LV Status available # open 1 LV Size <7.28 TiB Current LE 1907688 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4 --- Segments --- Logical extents 0 to 1907687: Type linear Physical volume /dev/md4 Physical extents 0 to 1907687 ``` 1. Format the logical volume as ext4 ``` mkfs -t ext4 /dev/davidahw2-vg4/lv0 ``` 2. Create a libvirt x86 64bits Ubuntu 22.04 machine mounting a LVM logical volume ```
``` **On the guest** 3. Mount libvirt/qemu provided block device /dev/sdd as ext4 partition ``` mount /dev/sdd /mnt/test ``` 4. Write **27G file** or larger **on the guest** causing the **2nd checksum to be different** ``` sync; head -c 27G myfile; sha256sum myfile; sha256sum myfile 8d3b4b263961d2c510390f99879be89b4b9134dc588139ede75573be1590115b myfile a8e886b3c39d9b4721e582c5e2ca25c76ff6561750ac6dc7aa7e70404661d1cf myfile <== ERROR: Inconsistent checksum ``` 5. Write **26G file** or larger **on the guest** and **both checksum are the same** ``` sync; head -c 26G myfile; sha256sum myfile; sha256sum myfile 598ac5da9b5bfa14d0ee664ae2590e09da772cba64cbc83ec049a656223c9401 myfile 598ac5da9b5bfa14d0ee664ae2590e09da772cba64cbc83ec049a656223c9401 myfile <== CORRECT: Consistent checksum ``` **Important**: - With the VM shutdown, the same commands on the same mounted ext4 partition **on the host** has consistent checksum every time for file sizes from 20G to 40G. - The disk has no sign of failure (no badblocks reported to the filesystem, MD raid reports a healthy raid setup, smart reports on error) Additional information: