[08/21] block: introduce auto-loading bitmaps
diff mbox

Message ID 1479835586-74394-9-git-send-email-vsementsov@virtuozzo.com
State New
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy Nov. 22, 2016, 5:26 p.m. UTC
Auto loading bitmaps are bitmaps store in the disk image, which should
be loaded when the image is opened and become BdrvDirtyBitmaps for the
corresponding drive.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block.c                   | 14 ++++++++++++++
 include/block/block.h     |  2 ++
 include/block/block_int.h |  3 +++
 3 files changed, 19 insertions(+)

Comments

Max Reitz Dec. 7, 2016, 6:34 p.m. UTC | #1
On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:
> Auto loading bitmaps are bitmaps store in the disk image, which should

s/store/stored/

> be loaded when the image is opened and become BdrvDirtyBitmaps for the
> corresponding drive.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block.c                   | 14 ++++++++++++++
>  include/block/block.h     |  2 ++
>  include/block/block_int.h |  3 +++
>  3 files changed, 19 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 39ddea3..450379c 100644
> --- a/block.c
> +++ b/block.c
> @@ -1137,6 +1137,13 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
>          goto free_and_fail;
>      }
>  
> +    bdrv_load_autoloading_dirty_bitmaps(bs, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        ret = -EINVAL;
> +        goto free_and_fail;
> +    }
> +
>      assert(bdrv_opt_mem_align(bs) != 0);
>      assert(bdrv_min_mem_align(bs) != 0);
>      assert(is_power_of_2(bs->bl.request_alignment));

These asserts should stay directly after the bdrv_refresh_limits() block
(i.e. the bdrv_load_autoloading_dirty_bitmaps() call should be moved
here, after them).

The rest looks good.

Max

> @@ -4093,3 +4100,10 @@ void bdrv_del_child(BlockDriverState *parent_bs, BdrvChild *child, Error **errp)
>  
>      parent_bs->drv->bdrv_del_child(parent_bs, child, errp);
>  }
> +
> +void bdrv_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp)
> +{
> +    if (bs->drv && bs->drv->bdrv_load_autoloading_dirty_bitmaps) {
> +        bs->drv->bdrv_load_autoloading_dirty_bitmaps(bs, errp);
> +    }
> +}
> diff --git a/include/block/block.h b/include/block/block.h
> index 49bb0b2..f701da2 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -552,4 +552,6 @@ void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child,
>                      Error **errp);
>  void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp);
>  
> +void bdrv_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp);
> +
>  #endif
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 83a423c..ca955f0 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -320,6 +320,9 @@ struct BlockDriver {
>      void (*bdrv_del_child)(BlockDriverState *parent, BdrvChild *child,
>                             Error **errp);
>  
> +    void (*bdrv_load_autoloading_dirty_bitmaps)(BlockDriverState *bs,
> +                                                Error **errp);
> +
>      QLIST_ENTRY(BlockDriver) list;
>  };
>  
>
John Snow Dec. 7, 2016, 10:51 p.m. UTC | #2
On 11/22/2016 12:26 PM, Vladimir Sementsov-Ogievskiy wrote:
> Auto loading bitmaps are bitmaps store in the disk image, which should
> be loaded when the image is opened and become BdrvDirtyBitmaps for the
> corresponding drive.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block.c                   | 14 ++++++++++++++
>  include/block/block.h     |  2 ++
>  include/block/block_int.h |  3 +++
>  3 files changed, 19 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 39ddea3..450379c 100644
> --- a/block.c
> +++ b/block.c
> @@ -1137,6 +1137,13 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
>          goto free_and_fail;
>      }
>  
> +    bdrv_load_autoloading_dirty_bitmaps(bs, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        ret = -EINVAL;
> +        goto free_and_fail;
> +    }
> +
>      assert(bdrv_opt_mem_align(bs) != 0);
>      assert(bdrv_min_mem_align(bs) != 0);
>      assert(is_power_of_2(bs->bl.request_alignment));
> @@ -4093,3 +4100,10 @@ void bdrv_del_child(BlockDriverState *parent_bs, BdrvChild *child, Error **errp)
>  
>      parent_bs->drv->bdrv_del_child(parent_bs, child, errp);
>  }
> +
> +void bdrv_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp)
> +{
> +    if (bs->drv && bs->drv->bdrv_load_autoloading_dirty_bitmaps) {
> +        bs->drv->bdrv_load_autoloading_dirty_bitmaps(bs, errp);
> +    }
> +}
> diff --git a/include/block/block.h b/include/block/block.h
> index 49bb0b2..f701da2 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -552,4 +552,6 @@ void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child,
>                      Error **errp);
>  void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp);
>  
> +void bdrv_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp);
> +
>  #endif
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 83a423c..ca955f0 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -320,6 +320,9 @@ struct BlockDriver {
>      void (*bdrv_del_child)(BlockDriverState *parent, BdrvChild *child,
>                             Error **errp);
>  
> +    void (*bdrv_load_autoloading_dirty_bitmaps)(BlockDriverState *bs,
> +                                                Error **errp);
> +
>      QLIST_ENTRY(BlockDriver) list;
>  };
>  
> 

If you address Max's comments:

Reviewed-by: John Snow <jsnow@redhat.com>

Patch
diff mbox

diff --git a/block.c b/block.c
index 39ddea3..450379c 100644
--- a/block.c
+++ b/block.c
@@ -1137,6 +1137,13 @@  static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
         goto free_and_fail;
     }
 
+    bdrv_load_autoloading_dirty_bitmaps(bs, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        ret = -EINVAL;
+        goto free_and_fail;
+    }
+
     assert(bdrv_opt_mem_align(bs) != 0);
     assert(bdrv_min_mem_align(bs) != 0);
     assert(is_power_of_2(bs->bl.request_alignment));
@@ -4093,3 +4100,10 @@  void bdrv_del_child(BlockDriverState *parent_bs, BdrvChild *child, Error **errp)
 
     parent_bs->drv->bdrv_del_child(parent_bs, child, errp);
 }
+
+void bdrv_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp)
+{
+    if (bs->drv && bs->drv->bdrv_load_autoloading_dirty_bitmaps) {
+        bs->drv->bdrv_load_autoloading_dirty_bitmaps(bs, errp);
+    }
+}
diff --git a/include/block/block.h b/include/block/block.h
index 49bb0b2..f701da2 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -552,4 +552,6 @@  void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child,
                     Error **errp);
 void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp);
 
+void bdrv_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp);
+
 #endif
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 83a423c..ca955f0 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -320,6 +320,9 @@  struct BlockDriver {
     void (*bdrv_del_child)(BlockDriverState *parent, BdrvChild *child,
                            Error **errp);
 
+    void (*bdrv_load_autoloading_dirty_bitmaps)(BlockDriverState *bs,
+                                                Error **errp);
+
     QLIST_ENTRY(BlockDriver) list;
 };