qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block/qcow2: save dirty_bitmaps_loaded during reopen
@ 2018-06-08 12:32 Vladimir Sementsov-Ogievskiy
  2018-06-08 15:33 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2018-06-08 12:32 UTC (permalink / raw)
  To: qemu-devel, qemu-block; +Cc: mreitz, kwolf

This variable was introduced to handle reopens. We need it on the
following qcow2_do_open, to don't try load bitmaps again.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qcow2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/qcow2.c b/block/qcow2.c
index 549fee9b69..29f7eab576 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2178,6 +2178,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
     QDict *options;
     Error *local_err = NULL;
     int ret;
+    bool dirty_bitmaps_loaded = s->dirty_bitmaps_loaded;
 
     /*
      * Backing files are read-only which makes all of their metadata immutable,
@@ -2190,6 +2191,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
     qcow2_close(bs);
 
     memset(s, 0, sizeof(BDRVQcow2State));
+    s->dirty_bitmaps_loaded = dirty_bitmaps_loaded;
     options = qdict_clone_shallow(bs->options);
 
     flags &= ~BDRV_O_INACTIVE;
-- 
2.11.1

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

* Re: [Qemu-devel] [PATCH] block/qcow2: save dirty_bitmaps_loaded during reopen
  2018-06-08 12:32 [Qemu-devel] [PATCH] block/qcow2: save dirty_bitmaps_loaded during reopen Vladimir Sementsov-Ogievskiy
@ 2018-06-08 15:33 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2018-06-08 15:33 UTC (permalink / raw)
  To: qemu-devel, qemu-block; +Cc: kwolf, mreitz

08.06.2018 15:32, Vladimir Sementsov-Ogievskiy wrote:
> This variable was introduced to handle reopens. We need it on the
> following qcow2_do_open, to don't try load bitmaps again.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   block/qcow2.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 549fee9b69..29f7eab576 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -2178,6 +2178,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
>       QDict *options;
>       Error *local_err = NULL;
>       int ret;
> +    bool dirty_bitmaps_loaded = s->dirty_bitmaps_loaded;
>   
>       /*
>        * Backing files are read-only which makes all of their metadata immutable,
> @@ -2190,6 +2191,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
>       qcow2_close(bs);
>   
>       memset(s, 0, sizeof(BDRVQcow2State));
> +    s->dirty_bitmaps_loaded = dirty_bitmaps_loaded;
>       options = qdict_clone_shallow(bs->options);
>   
>       flags &= ~BDRV_O_INACTIVE;

Haha, this breaks 169 test.. Because, logic around dirty_bitmaps_loaded, 
which is fixed here, actually breaks it.

context:

static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
                                       int flags, Error **errp)
{

[...]

     if (s->dirty_bitmaps_loaded) {
         /* It's some kind of reopen. There are no known cases where we 
need to
          * reload bitmaps in such a situation, so it's safer to skip them.
*
          * Moreover, if we have some readonly bitmaps and we are 
reopening for
          * rw we should reopen bitmaps correspondingly.
*/
         if (bdrv_has_readonly_bitmaps(bs) &&
             !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & 
BDRV_O_INACTIVE))
{
             qcow2_reopen_bitmaps_rw_hint(bs, &header_updated, &local_err);
}
     } else {
         header_updated = qcow2_load_dirty_bitmaps(bs, &local_err);
         s->dirty_bitmaps_loaded = true;
     }

[...]

- First time, we go into "else" block, but there no bitmaps yet, as 
target is opened before source closed. On second time, we go into "if" 
block, but there is nothing to reopen.

I'll resend the patch, with additional fixing.

-- 
Best regards,
Vladimir

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

end of thread, other threads:[~2018-06-08 15:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-08 12:32 [Qemu-devel] [PATCH] block/qcow2: save dirty_bitmaps_loaded during reopen Vladimir Sementsov-Ogievskiy
2018-06-08 15:33 ` Vladimir Sementsov-Ogievskiy

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).