blockdev: Promote several bitmap functions to non-static

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 <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-5-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
This commit is contained in:
Eric Blake 2020-05-12 20:16:43 -05:00
parent ef893b5c84
commit c6996cf9a6
2 changed files with 31 additions and 28 deletions

View file

@ -1197,7 +1197,7 @@ out_aio_context:
* *
* @return: A bitmap object on success, or NULL on failure. * @return: A bitmap object on success, or NULL on failure.
*/ */
static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node, BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
const char *name, const char *name,
BlockDriverState **pbs, BlockDriverState **pbs,
Error **errp) Error **errp)
@ -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, static void block_dirty_bitmap_merge_prepare(BlkActionState *common,
Error **errp) Error **errp)
{ {
@ -2189,15 +2184,11 @@ static void block_dirty_bitmap_merge_prepare(BlkActionState *common,
action = common->action->u.block_dirty_bitmap_merge.data; action = common->action->u.block_dirty_bitmap_merge.data;
state->bitmap = do_block_dirty_bitmap_merge(action->node, action->target, state->bitmap = block_dirty_bitmap_merge(action->node, action->target,
action->bitmaps, &state->backup, action->bitmaps, &state->backup,
errp); 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, static void block_dirty_bitmap_remove_prepare(BlkActionState *common,
Error **errp) Error **errp)
{ {
@ -2211,7 +2202,7 @@ static void block_dirty_bitmap_remove_prepare(BlkActionState *common,
action = common->action->u.block_dirty_bitmap_remove.data; action = common->action->u.block_dirty_bitmap_remove.data;
state->bitmap = do_block_dirty_bitmap_remove(action->node, action->name, state->bitmap = block_dirty_bitmap_remove(action->node, action->name,
false, &state->bs, errp); false, &state->bs, errp);
if (state->bitmap) { if (state->bitmap) {
bdrv_dirty_bitmap_skip_store(state->bitmap, true); bdrv_dirty_bitmap_skip_store(state->bitmap, true);
@ -2504,9 +2495,10 @@ out:
aio_context_release(aio_context); aio_context_release(aio_context);
} }
static BdrvDirtyBitmap *do_block_dirty_bitmap_remove( BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,
const char *node, const char *name, bool release, bool release,
BlockDriverState **bitmap_bs, Error **errp) BlockDriverState **bitmap_bs,
Error **errp)
{ {
BlockDriverState *bs; BlockDriverState *bs;
BdrvDirtyBitmap *bitmap; BdrvDirtyBitmap *bitmap;
@ -2548,7 +2540,7 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_remove(
void qmp_block_dirty_bitmap_remove(const char *node, const char *name, void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
Error **errp) Error **errp)
{ {
do_block_dirty_bitmap_remove(node, name, true, NULL, errp); block_dirty_bitmap_remove(node, name, true, NULL, errp);
} }
/** /**
@ -2609,9 +2601,8 @@ void qmp_block_dirty_bitmap_disable(const char *node, const char *name,
bdrv_disable_dirty_bitmap(bitmap); bdrv_disable_dirty_bitmap(bitmap);
} }
static BdrvDirtyBitmap *do_block_dirty_bitmap_merge( BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *node, const char *target,
const char *node, const char *target, BlockDirtyBitmapMergeSourceList *bms,
BlockDirtyBitmapMergeSourceList *bitmaps,
HBitmap **backup, Error **errp) HBitmap **backup, Error **errp)
{ {
BlockDriverState *bs; BlockDriverState *bs;
@ -2630,7 +2621,7 @@ static BdrvDirtyBitmap *do_block_dirty_bitmap_merge(
return NULL; return NULL;
} }
for (lst = bitmaps; lst; lst = lst->next) { for (lst = bms; lst; lst = lst->next) {
switch (lst->value->type) { switch (lst->value->type) {
const char *name, *node; const char *name, *node;
case QTYPE_QSTRING: case QTYPE_QSTRING:
@ -2675,7 +2666,7 @@ void qmp_block_dirty_bitmap_merge(const char *node, const char *target,
BlockDirtyBitmapMergeSourceList *bitmaps, BlockDirtyBitmapMergeSourceList *bitmaps,
Error **errp) Error **errp)
{ {
do_block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp); block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp);
} }
BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node, BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,

View file

@ -1344,4 +1344,16 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv,
Error **errp); Error **errp);
extern QemuOptsList bdrv_create_opts_simple; 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 */ #endif /* BLOCK_INT_H */