qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected
@ 2013-01-18 15:43 Liu Yuan
  2013-01-18 15:56 ` Stefan Hajnoczi
  2013-01-18 18:06 ` Liu Yuan
  0 siblings, 2 replies; 5+ messages in thread
From: Liu Yuan @ 2013-01-18 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Paolo Bonzini

Hi List,
   Recently I found bdrv_co_flush_to_disk() doesn't work as expected. As
it is advertised

    /*
     * Flushes all data that was already written to the OS all the way
down to
     * the disk (for example raw-posix calls fsync()).
     */
    int coroutine_fn (*bdrv_co_flush_to_disk)(BlockDriverState *bs);

The fsync(2) or similar flush requests in the guest OS will trigger this
handler of the attached disk.

But I noticed that this handler isn't called at all when guest is
running if I attach another disk as 'cache=writeback', for e.g

 # start up the guest
 $ qemu-system-x86_64 --enable-kvm -drive
file=~/images/test1,if=virtio,cache=writeback -smp 2 -cpu host -m 1024
-drive file=sheepdog:test,if=virtio,cache=writeback
 # write to the /dev/vdb of the guest
 # sudo dd if=/dev/urandom of=/dev/vdb bs=4M count=1 oflag=direct,sync

This doesn't trigger flush for vdb device. I also write a small program
to call fsync(2) to the device, no flush neither.

Only the poweroff of the guest will trigger the flush request for vdb.
So is this expected behavior and I am missing something?

Thanks,
Yuan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected
  2013-01-18 15:43 [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected Liu Yuan
@ 2013-01-18 15:56 ` Stefan Hajnoczi
  2013-01-18 16:13   ` Liu Yuan
  2013-01-18 16:28   ` Liu Yuan
  2013-01-18 18:06 ` Liu Yuan
  1 sibling, 2 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2013-01-18 15:56 UTC (permalink / raw)
  To: Liu Yuan; +Cc: Kevin Wolf, Paolo Bonzini, qemu-devel

On Fri, Jan 18, 2013 at 4:43 PM, Liu Yuan <namei.unix@gmail.com> wrote:
>    Recently I found bdrv_co_flush_to_disk() doesn't work as expected. As
> it is advertised
>
>     /*
>      * Flushes all data that was already written to the OS all the way
> down to
>      * the disk (for example raw-posix calls fsync()).
>      */
>     int coroutine_fn (*bdrv_co_flush_to_disk)(BlockDriverState *bs);
>
> The fsync(2) or similar flush requests in the guest OS will trigger this
> handler of the attached disk.
>
> But I noticed that this handler isn't called at all when guest is
> running if I attach another disk as 'cache=writeback', for e.g
>
>  # start up the guest
>  $ qemu-system-x86_64 --enable-kvm -drive
> file=~/images/test1,if=virtio,cache=writeback -smp 2 -cpu host -m 1024
> -drive file=sheepdog:test,if=virtio,cache=writeback
>  # write to the /dev/vdb of the guest
>  # sudo dd if=/dev/urandom of=/dev/vdb bs=4M count=1 oflag=direct,sync
>
> This doesn't trigger flush for vdb device. I also write a small program
> to call fsync(2) to the device, no flush neither.
>
> Only the poweroff of the guest will trigger the flush request for vdb.
> So is this expected behavior and I am missing something?

How are you checking that sd_co_flush_to_disk() is called?  Please
post the diff.

Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected
  2013-01-18 15:56 ` Stefan Hajnoczi
@ 2013-01-18 16:13   ` Liu Yuan
  2013-01-18 16:28   ` Liu Yuan
  1 sibling, 0 replies; 5+ messages in thread
From: Liu Yuan @ 2013-01-18 16:13 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Kevin Wolf, Paolo Bonzini, qemu-devel

On 01/18/2013 11:56 PM, Stefan Hajnoczi wrote:
> How are you checking that sd_co_flush_to_disk() is called?  Please
> post the diff.

>From the sheep.log, I can see

Jan 19 00:09:39 [main] queue_request(355) FLUSH_VDI, 1
...

This means a flush request is sent from QEMU. I added a printf() in
sd_co_flush_to_disk (sheepdog.c) also confirmed that sd_co_flush_to_disk
wasn't called until I typed 'poweroff' in the guest.

Thanks,
Yuan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected
  2013-01-18 15:56 ` Stefan Hajnoczi
  2013-01-18 16:13   ` Liu Yuan
@ 2013-01-18 16:28   ` Liu Yuan
  1 sibling, 0 replies; 5+ messages in thread
From: Liu Yuan @ 2013-01-18 16:28 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Kevin Wolf, Paolo Bonzini, qemu-devel

On 01/18/2013 11:56 PM, Stefan Hajnoczi wrote:
> How are you checking that sd_co_flush_to_disk() is called?  Please
> post the diff.

Okay, this is where I added printf().

Yuan

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 3e49bb8..41edd46 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1714,6 +1714,7 @@ static int coroutine_fn
sd_co_flush_to_disk(BlockDriverState *bs)
     AIOReq *aio_req;
     int ret;

+    printf("hello\n");
     if (s->cache_flags != SD_FLAG_CMD_CACHE) {
         return 0;
     }

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected
  2013-01-18 15:43 [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected Liu Yuan
  2013-01-18 15:56 ` Stefan Hajnoczi
@ 2013-01-18 18:06 ` Liu Yuan
  1 sibling, 0 replies; 5+ messages in thread
From: Liu Yuan @ 2013-01-18 18:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Paolo Bonzini

On 01/18/2013 11:43 PM, Liu Yuan wrote:
>  # start up the guest
>  $ qemu-system-x86_64 --enable-kvm -drive
> file=~/images/test1,if=virtio,cache=writeback -smp 2 -cpu host -m 1024
> -drive file=sheepdog:test,if=virtio,cache=writeback
>  # write to the /dev/vdb of the guest
>  # sudo dd if=/dev/urandom of=/dev/vdb bs=4M count=1 oflag=direct,sync
> 
> This doesn't trigger flush for vdb device. I also write a small program
> to call fsync(2) to the device, no flush neither.
> 
> Only the poweroff of the guest will trigger the flush request for vdb.
> So is this expected behavior and I am missing something?

Oops, it is something wrong in the Guest. I created a new guest and it
works like a charm. Sorry for the false alarm.

Thanks,
Yuan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-01-18 18:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-18 15:43 [Qemu-devel] bdrv_co_flush_to_disk() don't flush as expected Liu Yuan
2013-01-18 15:56 ` Stefan Hajnoczi
2013-01-18 16:13   ` Liu Yuan
2013-01-18 16:28   ` Liu Yuan
2013-01-18 18:06 ` Liu Yuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).