Patchwork block: complete all IOs before .bdrv_truncate

login
register
mail settings
Submitter Peter Lieven
Date Feb. 18, 2013, 12:48 p.m.
Message ID <5122231F.8070309@dlhnet.de>
Download mbox | patch
Permalink /patch/221299/
State New
Headers show

Comments

Peter Lieven - Feb. 18, 2013, 12:48 p.m.
bdrv_truncate() invalidates the bdrv_check_request() result for
in-flight requests, so there should better be none.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reported-by: Kevin Wolf <kwolf@redhat.com>
---
  block.c |    4 ++++
  1 file changed, 4 insertions(+)
Paolo Bonzini - Feb. 18, 2013, 12:49 p.m.
Il 18/02/2013 13:48, Peter Lieven ha scritto:
> bdrv_truncate() invalidates the bdrv_check_request() result for
> in-flight requests, so there should better be none.
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 50dab8e..d8880e3 100644
> --- a/block.c
> +++ b/block.c
> @@ -2427,6 +2427,10 @@ int bdrv_truncate(BlockDriverState *bs, int64_t
> offset)
>          return -EACCES;
>      if (bdrv_in_use(bs))
>          return -EBUSY;
> +
> +    /* there should be better no IOs in flight when we truncate the
> device */
> +    bdrv_drain_all();
> +
>      ret = drv->bdrv_truncate(bs, offset);
>      if (ret == 0) {
>          ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);

Cc: qemu-stable@nongnu.org
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Eric Blake - Feb. 18, 2013, 5:41 p.m.
On 02/18/2013 05:48 AM, Peter Lieven wrote:
> bdrv_truncate() invalidates the bdrv_check_request() result for
> in-flight requests, so there should better be none.
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 50dab8e..d8880e3 100644
> --- a/block.c
> +++ b/block.c
> @@ -2427,6 +2427,10 @@ int bdrv_truncate(BlockDriverState *bs, int64_t
> offset)
>          return -EACCES;
>      if (bdrv_in_use(bs))
>          return -EBUSY;
> +
> +    /* there should be better no IOs in flight when we truncate the
> device */

Grammar.  Not sure what you were trying to say, but this might be better:

/* There should not be any in-flight IOs when we truncate the device. */
Kevin Wolf - Feb. 20, 2013, 3:20 p.m.
On Mon, Feb 18, 2013 at 01:49:43PM +0100, Paolo Bonzini wrote:
> Il 18/02/2013 13:48, Peter Lieven ha scritto:
> > bdrv_truncate() invalidates the bdrv_check_request() result for
> > in-flight requests, so there should better be none.
> > 
> > Signed-off-by: Peter Lieven <pl@kamp.de>
> > Reported-by: Kevin Wolf <kwolf@redhat.com>
> 
> Cc: qemu-stable@nongnu.org
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/block.c b/block.c
index 50dab8e..d8880e3 100644
--- a/block.c
+++ b/block.c
@@ -2427,6 +2427,10 @@  int bdrv_truncate(BlockDriverState *bs, int64_t offset)
          return -EACCES;
      if (bdrv_in_use(bs))
          return -EBUSY;
+
+    /* there should be better no IOs in flight when we truncate the device */
+    bdrv_drain_all();
+
      ret = drv->bdrv_truncate(bs, offset);
      if (ret == 0) {
          ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);