[ Moved to virtio-dev, since we're now talking about an implementation ]
Paolo Bonzini <> writes:
> Il 17/09/2013 03:20, Rusty Russell ha scritto:
>> bdrv_co_flush() calls:
>>
>> bs->drv->bdrv_co_flush_to_disk
>>
>> or if that's NULL:
>>
>> bs->drv->bdrv_aio_flush
>>
>> or if that's NULL, does nothing.
>>
>> Now, qcow2 doesn't set bdrv_co_flush_to_disk or bdrv_aio_flush.
>
> It also does
>
> bdrv_co_flush(bs->file);
>
> and that's where bdrv_co_flush_to_disk gets called.
>
>> It seems a raw file will get an fdatasync, via bdrv_aio_flush() ->
>> raw_aio_flush(), but strace shows no fsync/fdatasync calls, even when I
>> just a raw file, and type "sync" in the guest:
>
> That's the same path that gets qcow2 flushed, actually. You need
> "strace -ff" because the flush is done in a thread pool.
Oops, I missed the -f. Unfortunately, it doesn't help. I only get
fdatasync on shutdown, not when I do ops in the guest.
So I ended up tracking this into the virtio_blk driver: the guest isn't
submitting any flush commands. It's accepted both the VIRTIO_BLK_F_WCE
and VIRTIO_BLK_F_CONFIG_WCE flags, and
/sys/devices/pci0000:00/0000:00:04.0/virtio0/block/vda/cache_type says
"write back".
It's mounted using ext4, default options. 3.12-rc1.
Clearly, I'm missing some Linux block layer thing. How do I get it to
submit a flush to the virtio_blk driver? I would expect "touch
some-new-file; sync" to do that.
Seriously confused,
Rusty.