* [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place
@ 2010-01-12 12:49 Christoph Hellwig
2010-01-12 17:42 ` Kevin Wolf
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Christoph Hellwig @ 2010-01-12 12:49 UTC (permalink / raw)
To: qemu-devel
The backing device is only modified from bdrv_commit. So instead of
flushing it every time bdrv_flush is called for the front-end device
only flush it after we're written data to it in bdrv_commit.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: qemu/block.c
===================================================================
--- qemu.orig/block.c 2010-01-12 11:34:35.549024986 +0100
+++ qemu/block.c 2010-01-12 11:43:28.965006129 +0100
@@ -623,6 +623,12 @@ int bdrv_commit(BlockDriverState *bs)
if (drv->bdrv_make_empty)
return drv->bdrv_make_empty(bs);
+ /*
+ * Make sure all data we wrote to the backing device is actually
+ * stable on disk.
+ */
+ if (bs->backing_hd)
+ bdrv_flush(bs->backing_hd);
return 0;
}
@@ -1124,12 +1130,8 @@ const char *bdrv_get_device_name(BlockDr
void bdrv_flush(BlockDriverState *bs)
{
- if (!bs->drv)
- return;
- if (bs->drv->bdrv_flush)
+ if (bs->drv && bs->drv->bdrv_flush)
bs->drv->bdrv_flush(bs);
- if (bs->backing_hd)
- bdrv_flush(bs->backing_hd);
}
void bdrv_flush_all(void)
@@ -1806,11 +1808,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDr
if (!drv)
return NULL;
-
- /*
- * Note that unlike bdrv_flush the driver is reponsible for flushing a
- * backing image if it exists.
- */
return drv->bdrv_aio_flush(bs, cb, opaque);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place
2010-01-12 12:49 [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place Christoph Hellwig
@ 2010-01-12 17:42 ` Kevin Wolf
2010-01-12 17:44 ` Christoph Hellwig
2010-01-12 18:13 ` [Qemu-devel] [PATCH 1/2 v2] " Christoph Hellwig
2010-01-13 23:26 ` [Qemu-devel] [PATCH 1/2] " Anthony Liguori
2 siblings, 1 reply; 9+ messages in thread
From: Kevin Wolf @ 2010-01-12 17:42 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: qemu-devel
Am 12.01.2010 13:49, schrieb Christoph Hellwig:
>
> The backing device is only modified from bdrv_commit. So instead of
> flushing it every time bdrv_flush is called for the front-end device
> only flush it after we're written data to it in bdrv_commit.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c 2010-01-12 11:34:35.549024986 +0100
> +++ qemu/block.c 2010-01-12 11:43:28.965006129 +0100
> @@ -623,6 +623,12 @@ int bdrv_commit(BlockDriverState *bs)
> if (drv->bdrv_make_empty)
> return drv->bdrv_make_empty(bs);
>
> + /*
> + * Make sure all data we wrote to the backing device is actually
> + * stable on disk.
> + */
> + if (bs->backing_hd)
> + bdrv_flush(bs->backing_hd);
> return 0;
> }
Format drivers with a bdrv_make_empty return before the flush, so it
won't work for qcow1. Looks good otherwise.
If it has done a bdrv_make_empty we might also want to flush bs?
Kevin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place
2010-01-12 17:42 ` Kevin Wolf
@ 2010-01-12 17:44 ` Christoph Hellwig
0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2010-01-12 17:44 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Christoph Hellwig, qemu-devel
On Tue, Jan 12, 2010 at 06:42:20PM +0100, Kevin Wolf wrote:
> > @@ -623,6 +623,12 @@ int bdrv_commit(BlockDriverState *bs)
> > if (drv->bdrv_make_empty)
> > return drv->bdrv_make_empty(bs);
> >
> > + /*
> > + * Make sure all data we wrote to the backing device is actually
> > + * stable on disk.
> > + */
> > + if (bs->backing_hd)
> > + bdrv_flush(bs->backing_hd);
> > return 0;
> > }
>
> Format drivers with a bdrv_make_empty return before the flush, so it
> won't work for qcow1. Looks good otherwise.
Oh, okay.
> If it has done a bdrv_make_empty we might also want to flush bs?
Indeed. I'll spin a new version.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 1/2 v2] block: flush backing_hd in the right place
2010-01-12 12:49 [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place Christoph Hellwig
2010-01-12 17:42 ` Kevin Wolf
@ 2010-01-12 18:13 ` Christoph Hellwig
2010-01-13 9:50 ` Kevin Wolf
2010-01-13 23:26 ` [Qemu-devel] [PATCH 1/2] " Anthony Liguori
2 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2010-01-12 18:13 UTC (permalink / raw)
To: qemu-devel
The backing device is only modified from bdrv_commit. So instead of
flushing it every time bdrv_flush is called for the front-end device
only flush it after we're written data to it in bdrv_commit.
Also flush the frontend image if we have a make_empty method that
possibly writes to it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: qemu/block.c
===================================================================
--- qemu.orig/block.c 2010-01-12 19:08:07.363003775 +0100
+++ qemu/block.c 2010-01-12 19:09:10.836255948 +0100
@@ -589,6 +589,7 @@ int bdrv_commit(BlockDriverState *bs)
BlockDriver *drv = bs->drv;
int64_t i, total_sectors;
int n, j;
+ int ret = 0;
unsigned char sector[512];
if (!drv)
@@ -620,10 +621,18 @@ int bdrv_commit(BlockDriverState *bs)
}
}
- if (drv->bdrv_make_empty)
- return drv->bdrv_make_empty(bs);
+ if (drv->bdrv_make_empty) {
+ ret = drv->bdrv_make_empty(bs);
+ bdrv_flush(bs);
+ }
- return 0;
+ /*
+ * Make sure all data we wrote to the backing device is actually
+ * stable on disk.
+ */
+ if (bs->backing_hd)
+ bdrv_flush(bs->backing_hd);
+ return ret;
}
static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
@@ -1124,12 +1133,8 @@ const char *bdrv_get_device_name(BlockDr
void bdrv_flush(BlockDriverState *bs)
{
- if (!bs->drv)
- return;
- if (bs->drv->bdrv_flush)
+ if (bs->drv && bs->drv->bdrv_flush)
bs->drv->bdrv_flush(bs);
- if (bs->backing_hd)
- bdrv_flush(bs->backing_hd);
}
void bdrv_flush_all(void)
@@ -1806,11 +1811,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDr
if (!drv)
return NULL;
-
- /*
- * Note that unlike bdrv_flush the driver is reponsible for flushing a
- * backing image if it exists.
- */
return drv->bdrv_aio_flush(bs, cb, opaque);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2 v2] block: flush backing_hd in the right place
2010-01-12 18:13 ` [Qemu-devel] [PATCH 1/2 v2] " Christoph Hellwig
@ 2010-01-13 9:50 ` Kevin Wolf
0 siblings, 0 replies; 9+ messages in thread
From: Kevin Wolf @ 2010-01-13 9:50 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: qemu-devel
Am 12.01.2010 19:13, schrieb Christoph Hellwig:
> The backing device is only modified from bdrv_commit. So instead of
> flushing it every time bdrv_flush is called for the front-end device
> only flush it after we're written data to it in bdrv_commit.
>
> Also flush the frontend image if we have a make_empty method that
> possibly writes to it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c 2010-01-12 19:08:07.363003775 +0100
> +++ qemu/block.c 2010-01-12 19:09:10.836255948 +0100
> @@ -589,6 +589,7 @@ int bdrv_commit(BlockDriverState *bs)
> BlockDriver *drv = bs->drv;
> int64_t i, total_sectors;
> int n, j;
> + int ret = 0;
> unsigned char sector[512];
>
> if (!drv)
> @@ -620,10 +621,18 @@ int bdrv_commit(BlockDriverState *bs)
> }
> }
>
> - if (drv->bdrv_make_empty)
> - return drv->bdrv_make_empty(bs);
> + if (drv->bdrv_make_empty) {
> + ret = drv->bdrv_make_empty(bs);
> + bdrv_flush(bs);
> + }
Indentation is off here (but it already was before the patch). The logic
looks good to me now.
Kevin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place
2010-01-12 12:49 [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place Christoph Hellwig
2010-01-12 17:42 ` Kevin Wolf
2010-01-12 18:13 ` [Qemu-devel] [PATCH 1/2 v2] " Christoph Hellwig
@ 2010-01-13 23:26 ` Anthony Liguori
2010-01-14 10:21 ` Kevin Wolf
2 siblings, 1 reply; 9+ messages in thread
From: Anthony Liguori @ 2010-01-13 23:26 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: qemu-devel
On 01/12/2010 06:49 AM, Christoph Hellwig wrote:
> The backing device is only modified from bdrv_commit. So instead of
> flushing it every time bdrv_flush is called for the front-end device
> only flush it after we're written data to it in bdrv_commit.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
>
Applied. Thanks.
Regards,
Anthony Liguori
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c 2010-01-12 11:34:35.549024986 +0100
> +++ qemu/block.c 2010-01-12 11:43:28.965006129 +0100
> @@ -623,6 +623,12 @@ int bdrv_commit(BlockDriverState *bs)
> if (drv->bdrv_make_empty)
> return drv->bdrv_make_empty(bs);
>
> + /*
> + * Make sure all data we wrote to the backing device is actually
> + * stable on disk.
> + */
> + if (bs->backing_hd)
> + bdrv_flush(bs->backing_hd);
> return 0;
> }
>
> @@ -1124,12 +1130,8 @@ const char *bdrv_get_device_name(BlockDr
>
> void bdrv_flush(BlockDriverState *bs)
> {
> - if (!bs->drv)
> - return;
> - if (bs->drv->bdrv_flush)
> + if (bs->drv&& bs->drv->bdrv_flush)
> bs->drv->bdrv_flush(bs);
> - if (bs->backing_hd)
> - bdrv_flush(bs->backing_hd);
> }
>
> void bdrv_flush_all(void)
> @@ -1806,11 +1808,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDr
>
> if (!drv)
> return NULL;
> -
> - /*
> - * Note that unlike bdrv_flush the driver is reponsible for flushing a
> - * backing image if it exists.
> - */
> return drv->bdrv_aio_flush(bs, cb, opaque);
> }
>
>
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place
2010-01-13 23:26 ` [Qemu-devel] [PATCH 1/2] " Anthony Liguori
@ 2010-01-14 10:21 ` Kevin Wolf
2010-01-17 11:32 ` [Qemu-devel] [PATCH] block: fix cache flushing in bdrv_commit Christoph Hellwig
0 siblings, 1 reply; 9+ messages in thread
From: Kevin Wolf @ 2010-01-14 10:21 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Christoph Hellwig, qemu-devel
Am 14.01.2010 00:26, schrieb Anthony Liguori:
> On 01/12/2010 06:49 AM, Christoph Hellwig wrote:
>> The backing device is only modified from bdrv_commit. So instead of
>> flushing it every time bdrv_flush is called for the front-end device
>> only flush it after we're written data to it in bdrv_commit.
>>
>> Signed-off-by: Christoph Hellwig<hch@lst.de>
>>
>
> Applied. Thanks.
Anthony, you seem to have missed the v2 patch that considered my review
comments. Can you please apply the diff between v1 and v2 on top?
Kevin
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH] block: fix cache flushing in bdrv_commit
2010-01-14 10:21 ` Kevin Wolf
@ 2010-01-17 11:32 ` Christoph Hellwig
2010-01-20 14:58 ` Anthony Liguori
0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2010-01-17 11:32 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Christoph Hellwig, qemu-devel
On Thu, Jan 14, 2010 at 11:21:15AM +0100, Kevin Wolf wrote:
> Anthony, you seem to have missed the v2 patch that considered my review
> comments. Can you please apply the diff between v1 and v2 on top?
Here is the differences in patch form:
---
From: Christoph Hellwig <hch@lst.de>
Subject: block: fix cache flushing in bdrv_commit
As pointed out by Kevin Wolf the previous patch returned early if we
there is a bdrv_make_empty method and it missed a cache flush for the
frontend device after the bdev_make_empty call. This patch fixes it
up.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: qemu/block.c
===================================================================
--- qemu.orig/block.c 2010-01-17 12:27:03.589006970 +0100
+++ qemu/block.c 2010-01-17 12:27:55.718008519 +0100
@@ -589,6 +589,7 @@ int bdrv_commit(BlockDriverState *bs)
BlockDriver *drv = bs->drv;
int64_t i, total_sectors;
int n, j;
+ int ret = 0;
unsigned char sector[512];
if (!drv)
@@ -620,8 +621,10 @@ int bdrv_commit(BlockDriverState *bs)
}
}
- if (drv->bdrv_make_empty)
- return drv->bdrv_make_empty(bs);
+ if (drv->bdrv_make_empty) {
+ ret = drv->bdrv_make_empty(bs);
+ bdrv_flush(bs);
+ }
/*
* Make sure all data we wrote to the backing device is actually
@@ -629,7 +632,7 @@ int bdrv_commit(BlockDriverState *bs)
*/
if (bs->backing_hd)
bdrv_flush(bs->backing_hd);
- return 0;
+ return ret;
}
/*
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] block: fix cache flushing in bdrv_commit
2010-01-17 11:32 ` [Qemu-devel] [PATCH] block: fix cache flushing in bdrv_commit Christoph Hellwig
@ 2010-01-20 14:58 ` Anthony Liguori
0 siblings, 0 replies; 9+ messages in thread
From: Anthony Liguori @ 2010-01-20 14:58 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Kevin Wolf, qemu-devel
On 01/17/2010 05:32 AM, Christoph Hellwig wrote:
> On Thu, Jan 14, 2010 at 11:21:15AM +0100, Kevin Wolf wrote:
>
>> Anthony, you seem to have missed the v2 patch that considered my review
>> comments. Can you please apply the diff between v1 and v2 on top?
>>
> Here is the differences in patch form:
>
> ---
> From: Christoph Hellwig<hch@lst.de>
> Subject: block: fix cache flushing in bdrv_commit
>
> As pointed out by Kevin Wolf the previous patch returned early if we
> there is a bdrv_make_empty method and it missed a cache flush for the
> frontend device after the bdev_make_empty call. This patch fixes it
> up.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
>
Applied. Thanks.
Regards,
Anthony Liguori
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c 2010-01-17 12:27:03.589006970 +0100
> +++ qemu/block.c 2010-01-17 12:27:55.718008519 +0100
> @@ -589,6 +589,7 @@ int bdrv_commit(BlockDriverState *bs)
> BlockDriver *drv = bs->drv;
> int64_t i, total_sectors;
> int n, j;
> + int ret = 0;
> unsigned char sector[512];
>
> if (!drv)
> @@ -620,8 +621,10 @@ int bdrv_commit(BlockDriverState *bs)
> }
> }
>
> - if (drv->bdrv_make_empty)
> - return drv->bdrv_make_empty(bs);
> + if (drv->bdrv_make_empty) {
> + ret = drv->bdrv_make_empty(bs);
> + bdrv_flush(bs);
> + }
>
> /*
> * Make sure all data we wrote to the backing device is actually
> @@ -629,7 +632,7 @@ int bdrv_commit(BlockDriverState *bs)
> */
> if (bs->backing_hd)
> bdrv_flush(bs->backing_hd);
> - return 0;
> + return ret;
> }
>
> /*
>
>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-01-20 14:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-12 12:49 [Qemu-devel] [PATCH 1/2] block: flush backing_hd in the right place Christoph Hellwig
2010-01-12 17:42 ` Kevin Wolf
2010-01-12 17:44 ` Christoph Hellwig
2010-01-12 18:13 ` [Qemu-devel] [PATCH 1/2 v2] " Christoph Hellwig
2010-01-13 9:50 ` Kevin Wolf
2010-01-13 23:26 ` [Qemu-devel] [PATCH 1/2] " Anthony Liguori
2010-01-14 10:21 ` Kevin Wolf
2010-01-17 11:32 ` [Qemu-devel] [PATCH] block: fix cache flushing in bdrv_commit Christoph Hellwig
2010-01-20 14:58 ` Anthony Liguori
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).