From commit 
https://git.qemu.org/?p=qemu.git;a=commit;h=c8bb23cbdbe32f5c326365e0a82e1b0e68cdcd8a
 
for qcow2 file in ocfs2 filesystem, do_fallocate with (FALLOC_FL_PUNCH_HOLE | 
FALLOC_FL_KEEP_SIZE) 
will be called when allocate a new cluster.  It's not necessary and also cause 
data error.

1. create a ocfs2 cluster and   `mkfs.ocfs2 -b 4k -C 1M -N 2 /dev/sdb1`  then 
`mount /dev/sdb1 /mnt`
2. qemu-img create -f qcow2 -o cluster_size=256k /mnt/test.img 1G
3. attach /mnt/test.img to a linux vm as vdb
4. in vm, `dd if=/root/foo of=/dev/vdb bs=4k count=1` 
5. `hexdump -C /dev/vdb -n 4096`   the output is not identical to the file 
/root/foo

After remove do_fallocate with (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE) in 
handle_aiocb_write_zeroes , 
it's good.

Chang Limin

Reply via email to