Sure,  on what commit should apply this patch?<span></span><br><br>On Friday, December 13, 2013, Liu Yuan  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Dec 13, 2013 at 05:01:42PM +0100, Hadrien KOHL wrote:<br>

> Here we go:<br>
><br>
> # qemu-img create -f qcow2 sheepdog:test 10G<br>
> Formatting 'sheepdog:test', fmt=qcow2 size=10737418240 encryption=off<br>
> cluster_size=65536 lazy_refcounts=off<br>
><br>
> # qemu-system-x86_64 -machine accel=kvm:tcg -drive<br>
> file=sheepdog:127.0.0.1:7000:test,if=none,id=virtio-disk0,format=qcow2,cache=writeback<br>
> -cdrom /vm/iso/install-amd64-minimal-20131010.iso -device<br>
> virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=virtio-disk0,id=virtio-disk0,bootindex=1<br>
> -boot cd -m 1024 -name test -vnc <a href="http://172.16.0.11:0" target="_blank">172.16.0.11:0</a> -bios<br>
> /usr/local/share/qemu/bios.bin<br>
> 65798144, 73555968<br>
> qemu-system-x86_64: shrinking is not supported<br>
> 371130368, 379322368<br>
> qemu-system-x86_64: shrinking is not supported<br>
> 455671808, 472121344<br>
> qemu-system-x86_64: shrinking is not supported<br>
> 666042368, 674234368<br>
> qemu-system-x86_64: shrinking is not supported<br>
> 776339456, 791805952<br>
> qemu-system-x86_64: shrinking is not supported<br>
> 796459008, 796471296<br>
> qemu-system-x86_64: shrinking is not supported<br>
><br>
<br>
Can you try following patch to see if it fixes the problem?<br>
<br>
diff --git a/block/sheepdog.c b/block/sheepdog.c<br>
index b4ae50f..e1164a0 100644<br>
--- a/block/sheepdog.c<br>
+++ b/block/sheepdog.c<br>
@@ -2046,13 +2046,14 @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,<br>
 {<br>
     SheepdogAIOCB *acb;<br>
     int ret;<br>
+    int64_t offset = (sector_num + nb_sectors) * BDRV_SECTOR_SIZE;<br>
+    BDRVSheepdogState *s = bs->opaque;<br>
<br>
-    if (bs->growable && sector_num + nb_sectors > bs->total_sectors) {<br>
-        ret = sd_truncate(bs, (sector_num + nb_sectors) * BDRV_SECTOR_SIZE);<br>
+    if (bs->growable && offset > s->inode.vdi_size) {<br>
+        ret = sd_truncate(bs, offset);<br>
         if (ret < 0) {<br>
             return ret;<br>
         }<br>
-        bs->total_sectors = sector_num + nb_sectors;<br>
     }<br>
<br>
     acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);<br>
</blockquote>