[09/10] block: fix backup in vmdk format image
diff mbox

Message ID 1463229957-14253-10-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev May 14, 2016, 12:45 p.m. UTC
From: Pavel Butsykin <pbutsykin@virtuozzo.com>

The vmdk format has the extents and bs->file can be equal to the first
extension. Before start of the backup we do detach the old context on the
target drive at the bdrv_attach_aio_context. For the vmdk drive this means
a double detach of the same block driver state, because the detach occurs
for s->extents[0].file and bs->file.

To fix we  just skip the detach if s->extents[i].file and bs->file are the
same. This approach is already used in the vmdk_free_extents() and the
vmdk_get_allocated_file_size(), so it won't be some innovation :)

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Jeff Cody <jcody@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Eric Blake <eblake@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
---
 block/vmdk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Stefan Hajnoczi May 27, 2016, 6:01 p.m. UTC | #1
On Sat, May 14, 2016 at 03:45:57PM +0300, Denis V. Lunev wrote:
> From: Pavel Butsykin <pbutsykin@virtuozzo.com>
> 
> The vmdk format has the extents and bs->file can be equal to the first
> extension. Before start of the backup we do detach the old context on the
> target drive at the bdrv_attach_aio_context. For the vmdk drive this means
> a double detach of the same block driver state, because the detach occurs
> for s->extents[0].file and bs->file.
> 
> To fix we  just skip the detach if s->extents[i].file and bs->file are the
> same. This approach is already used in the vmdk_free_extents() and the
> vmdk_get_allocated_file_size(), so it won't be some innovation :)
> 
> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Jeff Cody <jcody@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Eric Blake <eblake@redhat.com>
> CC: John Snow <jsnow@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/vmdk.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 9530b30..0550924 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -2305,7 +2305,10 @@ static void vmdk_detach_aio_context(BlockDriverState *bs)
>      int i;
>  
>      for (i = 0; i < s->num_extents; i++) {
> -        bdrv_detach_aio_context(s->extents[i].file->bs);
> +        BdrvChild *file = s->extents[i].file;
> +        if (file != bs->file) {
> +            bdrv_detach_aio_context(file->bs);
> +        }
>      }
>  }

I think this fix is no longer necessary.  Max eliminated
vmdk_detach_aio_context() here:

[PULL 24/31] block: Propagate AioContext change to all children

Patch
diff mbox

diff --git a/block/vmdk.c b/block/vmdk.c
index 9530b30..0550924 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -2305,7 +2305,10 @@  static void vmdk_detach_aio_context(BlockDriverState *bs)
     int i;
 
     for (i = 0; i < s->num_extents; i++) {
-        bdrv_detach_aio_context(s->extents[i].file->bs);
+        BdrvChild *file = s->extents[i].file;
+        if (file != bs->file) {
+            bdrv_detach_aio_context(file->bs);
+        }
     }
 }