On Wed, May 28, 2025 at 06:23:58PM +0200, Markus Armbruster wrote: > >> # TEST_DIR -- /work/armbru/qemu/bld-x86/scratch > > > > Which filesystem is TEST_DIR on? > > $ findmnt --target /work/armbru/qemu/bld-x86/scratch > TARGET SOURCE FSTYPE OPTIONS > /work /dev/mapper/luks-898519e7-f64e-4a69-8cf9-8532063d8bb9 > xfs > rw,relatime,seclabel,at
Thanks; I installed a temporary xfs system (a bit easier to do on Fedora than zfs), with my tweak to show actual du output, and see: -Destination is sparse; expected sparse +Destination is unexpected size (3145728); expected sparse which is exactly at the 3M cutoff. In fact: $ findmnt --target /mnt/sysroot/ TARGET SOURCE FSTYPE OPTIONS /mnt/sysroot /dev/mapper/my--vg-temp xfs rw,relatime,seclabel,attr2,inode64,logbufs=8,lo $ qemu-img create -f raw /mnt/sysroot/dir/src.img 20M Formatting '/mnt/sysroot/dir/src.img', fmt=raw size=20971520 $ qemu-io -c 'w 8M 2M' -f raw /mnt/sysroot/dir/src.img wrote 2097152/2097152 bytes at offset 8388608 2 MiB, 1 ops; 00.00 sec (704.781 MiB/sec and 352.3905 ops/sec) $ qemu-img map --output=json -f raw '/mnt/sysroot/dir/src.img' [{ "start": 0, "length": 4096, "depth": 0, "present": true, "zero": false, "data": true, "compressed": false, "offset": 0}, { "start": 4096, "length": 8384512, "depth": 0, "present": true, "zero": true, "data": false, "compressed": false, "offset": 4096}, { "start": 8388608, "length": 2097152, "depth": 0, "present": true, "zero": false, "data": true, "compressed": false, "offset": 8388608}, { "start": 10485760, "length": 10485760, "depth": 0, "present": true, "zero": true, "data": false, "compressed": false, "offset": 10485760}] $ du --block-size=1 /mnt/sysroot/dir/src.img 3145728 /mnt/sysroot/dir/src.img So, even though SEEK_HOLE was able to show 4k data at the head + 2M data at the 8M offset (matching how the file was built), du reports 3702 * 1k sectors or exactly 3M of disk usage. On the bright side, it's an easy fix: either s/-lt/-le/ or s/3/4/ in mirror-sparse for the bound of what forms a sparse file (we can easily explain how even though less than 3M is reported as a hole, disk usage can plausibly round its answers up and list every megabyte of content that contains at least some data, while still being an "accurate" measure of how sparse the file is). -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org