diff mbox

[RFC,03/16] block: Allow .bdrv_close callback to release dirty bitmaps

Message ID 1453804705-7205-4-git-send-email-famz@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fam Zheng Jan. 26, 2016, 10:38 a.m. UTC
If the driver owns some dirty bitmaps, this assertion will fail.

The correct place to release them is in bdrv_close, so move the
assertion one line down.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eric Blake Jan. 26, 2016, 5:53 p.m. UTC | #1
On 01/26/2016 03:38 AM, Fam Zheng wrote:
> If the driver owns some dirty bitmaps, this assertion will fail.
> 
> The correct place to release them is in bdrv_close, so move the
> assertion one line down.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
John Snow Feb. 9, 2016, 12:23 a.m. UTC | #2
On 01/26/2016 05:38 AM, Fam Zheng wrote:
> If the driver owns some dirty bitmaps, this assertion will fail.
> 
> The correct place to release them is in bdrv_close, so move the
> assertion one line down.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index afb71c0..fa6ad1d 100644
> --- a/block.c
> +++ b/block.c
> @@ -2348,10 +2348,11 @@ static void bdrv_delete(BlockDriverState *bs)
>      assert(!bs->job);
>      assert(bdrv_op_blocker_is_empty(bs));
>      assert(!bs->refcnt);
> -    assert(QLIST_EMPTY(&bs->dirty_bitmaps));
>  
>      bdrv_close(bs);
>  
> +    assert(QLIST_EMPTY(&bs->dirty_bitmaps));
> +
>      /* remove from list, if necessary */
>      bdrv_make_anon(bs);
>  
> 

I think now is where we need to begin distinguishing internally owned
bitmaps from qmp/monitor created ones. I suppose this is just an assert
so it isn't changing much, but there are different ideas at play here...

- Bitmaps created internally for various reasons (backups, migration, etc)
- Bitmaps created explicitly by the user (transient bitmaps)
- Bitmaps autoloaded from qcow2, qbm, etc (persistent bitmaps)

We should still make sure we don't have any of the first two types when
we go to close the bitmap, and making sure we have none of the third is
reasonable after the close.
diff mbox

Patch

diff --git a/block.c b/block.c
index afb71c0..fa6ad1d 100644
--- a/block.c
+++ b/block.c
@@ -2348,10 +2348,11 @@  static void bdrv_delete(BlockDriverState *bs)
     assert(!bs->job);
     assert(bdrv_op_blocker_is_empty(bs));
     assert(!bs->refcnt);
-    assert(QLIST_EMPTY(&bs->dirty_bitmaps));
 
     bdrv_close(bs);
 
+    assert(QLIST_EMPTY(&bs->dirty_bitmaps));
+
     /* remove from list, if necessary */
     bdrv_make_anon(bs);