Re: [PATCH v3 4/9] blockdev: Promote several bitmap functions to non-static

2020-05-11 Thread Max Reitz
On 08.05.20 20:03, Eric Blake wrote:
> The next patch will split blockdev.c, which will require accessing
> some previously-static functions from more than one .c file.  But part
> of promoting a function to public is picking a naming scheme that does
> not reek of exposing too many internals (two of the three functions
> were named starting with 'do_').  To make future code motion easier,
> perform the function rename and non-static promotion into its own
> patch.
> 
> Signed-off-by: Eric Blake 
> ---
>  include/block/block_int.h | 12 +++
>  blockdev.c| 45 ---
>  2 files changed, 30 insertions(+), 27 deletions(-)

Reviewed-by: Max Reitz 

> diff --git a/blockdev.c b/blockdev.c
> index b3c840ec0312..fbeb38437869 100644
> --- a/blockdev.c
> +++ b/blockdev.c

[...]

> @@ -2504,9 +2495,10 @@ out:
>  aio_context_release(aio_context);
>  }
> 
> -static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
> -const char *node, const char *name, bool release,
> -BlockDriverState **bitmap_bs, Error **errp)
> +BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char 
> *name,
> +   bool release,
> +   BlockDriverState **bitmap_bs,

I’m not entirely sure what this parameter is even used for, but it
obviously doesn’t concern this patch.

Max

> +   Error **errp)
>  {
>  BlockDriverState *bs;
>  BdrvDirtyBitmap *bitmap;



signature.asc
Description: OpenPGP digital signature


[PATCH v3 4/9] blockdev: Promote several bitmap functions to non-static

2020-05-08 Thread Eric Blake
The next patch will split blockdev.c, which will require accessing
some previously-static functions from more than one .c file.  But part
of promoting a function to public is picking a naming scheme that does
not reek of exposing too many internals (two of the three functions
were named starting with 'do_').  To make future code motion easier,
perform the function rename and non-static promotion into its own
patch.

Signed-off-by: Eric Blake 
---
 include/block/block_int.h | 12 +++
 blockdev.c| 45 ---
 2 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/include/block/block_int.h b/include/block/block_int.h
index cb1082da4c43..e71505951d48 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -1344,4 +1344,16 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver 
*drv,
 Error **errp);
 extern QemuOptsList bdrv_create_opts_simple;

+BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
+   const char *name,
+   BlockDriverState **pbs,
+   Error **errp);
+BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
+  BlockDirtyBitmapMergeSourceList *bms,
+  HBitmap **backup, Error **errp);
+BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,
+   bool release,
+   BlockDriverState **bitmap_bs,
+   Error **errp);
+
 #endif /* BLOCK_INT_H */
diff --git a/blockdev.c b/blockdev.c
index b3c840ec0312..fbeb38437869 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1197,10 +1197,10 @@ out_aio_context:
  *
  * @return: A bitmap object on success, or NULL on failure.
  */
-static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
-  const char *name,
-  BlockDriverState **pbs,
-  Error **errp)
+BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
+   const char *name,
+   BlockDriverState **pbs,
+   Error **errp)
 {
 BlockDriverState *bs;
 BdrvDirtyBitmap *bitmap;
@@ -2171,11 +2171,6 @@ static void 
block_dirty_bitmap_disable_abort(BlkActionState *common)
 }
 }

-static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(
-const char *node, const char *target,
-BlockDirtyBitmapMergeSourceList *bitmaps,
-HBitmap **backup, Error **errp);
-
 static void block_dirty_bitmap_merge_prepare(BlkActionState *common,
  Error **errp)
 {
@@ -2189,15 +2184,11 @@ static void 
block_dirty_bitmap_merge_prepare(BlkActionState *common,

 action = common->action->u.block_dirty_bitmap_merge.data;

-state->bitmap = do_block_dirty_bitmap_merge(action->node, action->target,
-action->bitmaps, 
>backup,
-errp);
+state->bitmap = block_dirty_bitmap_merge(action->node, action->target,
+ action->bitmaps, >backup,
+ errp);
 }

-static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
-const char *node, const char *name, bool release,
-BlockDriverState **bitmap_bs, Error **errp);
-
 static void block_dirty_bitmap_remove_prepare(BlkActionState *common,
   Error **errp)
 {
@@ -2211,8 +2202,8 @@ static void 
block_dirty_bitmap_remove_prepare(BlkActionState *common,

 action = common->action->u.block_dirty_bitmap_remove.data;

-state->bitmap = do_block_dirty_bitmap_remove(action->node, action->name,
- false, >bs, errp);
+state->bitmap = block_dirty_bitmap_remove(action->node, action->name,
+  false, >bs, errp);
 if (state->bitmap) {
 bdrv_dirty_bitmap_skip_store(state->bitmap, true);
 bdrv_dirty_bitmap_set_busy(state->bitmap, true);
@@ -2504,9 +2495,10 @@ out:
 aio_context_release(aio_context);
 }

-static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
-const char *node, const char *name, bool release,
-BlockDriverState **bitmap_bs, Error **errp)
+BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,
+   bool release,
+   BlockDriverState **bitmap_bs,
+   Error **errp)
 {