From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: John Snow <jsnow@redhat.com>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/5] block/dirty-bitmap: rework bdrv_remove_persistent_dirty_bitmap
Date: Fri, 7 Jun 2019 14:41:41 +0000 [thread overview]
Message-ID: <36d3d30b-08ad-f5a1-ae56-eb2af8866528@virtuozzo.com> (raw)
In-Reply-To: <20190606184159.979-4-jsnow@redhat.com>
06.06.2019 21:41, John Snow wrote:
> Allow propagating error code information from
> bdrv_remove_persistent_dirty_bitmap as well.
>
> Give it an interface that matches the newly revised
> bdrv_add_persistent_dirty_bitmap, including removing the persistent flag
> when the operation succeeds and refusing to operate on bitmaps that are
> not persistent.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> block/qcow2.h | 6 +++---
> include/block/block_int.h | 6 +++---
> include/block/dirty-bitmap.h | 6 +++---
> block/dirty-bitmap.c | 25 ++++++++++++++++++++-----
> block/qcow2-bitmap.c | 16 +++++++++-------
> blockdev.c | 15 ++++++---------
> 6 files changed, 44 insertions(+), 30 deletions(-)
>
> diff --git a/block/qcow2.h b/block/qcow2.h
> index 95d723d3c0..ce07f003f7 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -745,9 +745,9 @@ int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
> int qcow2_add_persistent_dirty_bitmap(BlockDriverState *bs,
> BdrvDirtyBitmap *bitmap,
> Error **errp);
> -void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> - const char *name,
> - Error **errp);
> +int qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + Error **errp);
>
> ssize_t coroutine_fn
> qcow2_co_compress(BlockDriverState *bs, void *dest, size_t dest_size,
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 93bbb66cd0..59f8cb9c12 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -540,9 +540,9 @@ struct BlockDriver {
> int (*bdrv_add_persistent_dirty_bitmap)(BlockDriverState *bs,
> BdrvDirtyBitmap *bitmap,
> Error **errp);
> - void (*bdrv_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
> - const char *name,
> - Error **errp);
> + int (*bdrv_remove_persistent_dirty_bitmap)(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + Error **errp);
>
> /**
> * Register/unregister a buffer for I/O. For example, when the driver is
> diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
> index c37edbe05f..88a9832ddc 100644
> --- a/include/block/dirty-bitmap.h
> +++ b/include/block/dirty-bitmap.h
> @@ -41,9 +41,9 @@ void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs);
> int bdrv_add_persistent_dirty_bitmap(BlockDriverState *bs,
> BdrvDirtyBitmap *bitmap,
> Error **errp);
> -void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> - const char *name,
> - Error **errp);
> +int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + Error **errp);
> void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
> void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
> void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap);
> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
> index 615f8480b2..4667f9e65a 100644
> --- a/block/dirty-bitmap.c
> +++ b/block/dirty-bitmap.c
> @@ -455,15 +455,30 @@ void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs)
> * BdrvDirtyBitmap can have .persistent = true but not yet saved and have no
> * stored version. For such bitmap bdrv_remove_persistent_dirty_bitmap() should
> * not fail.
> - * This function doesn't release corresponding BdrvDirtyBitmap.
> + * This function doesn't release the corresponding BdrvDirtyBitmap.
> */
> -void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> - const char *name,
> - Error **errp)
> +int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + Error **errp)
> {
> + int ret = 0;
> +
> + if (!bdrv_dirty_bitmap_get_persistence(bitmap)) {
> + error_setg(errp, "Bitmap '%s' is not persistent, "
> + "so it cannot be removed from node '%s'",
> + bdrv_dirty_bitmap_name(bitmap),
> + bdrv_get_device_or_node_name(bs));
> + return -EINVAL;
> + }
> +
> if (bs->drv && bs->drv->bdrv_remove_persistent_dirty_bitmap) {
> - bs->drv->bdrv_remove_persistent_dirty_bitmap(bs, name, errp);
> + ret = bs->drv->bdrv_remove_persistent_dirty_bitmap(bs, bitmap, errp);
> }
> + if (!ret) {
> + bdrv_dirty_bitmap_set_persistence(bitmap, false);
> + }
> +
> + return ret;
> }
>
> int bdrv_add_persistent_dirty_bitmap(BlockDriverState *bs,
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index c3a72ca782..930a6c91ff 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -1402,23 +1402,24 @@ static Qcow2Bitmap *find_bitmap_by_name(Qcow2BitmapList *bm_list,
> return NULL;
> }
>
> -void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> - const char *name,
> - Error **errp)
> +int qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + Error **errp)
> {
> - int ret;
> + int ret = 0;
dead assignment
> BDRVQcow2State *s = bs->opaque;
> Qcow2Bitmap *bm;
> Qcow2BitmapList *bm_list;
> + const char *name = bdrv_dirty_bitmap_name(bitmap);
>
> if (s->nb_bitmaps == 0) {
> /* Absence of the bitmap is not an error: see explanation above
> * bdrv_remove_persistent_dirty_bitmap() definition. */
> - return;
> + return 0;
> }
>
> - if (bitmap_list_load(bs, &bm_list, errp)) {
> - return;
> + if ((ret = bitmap_list_load(bs, &bm_list, errp))) {
> + return ret;
> }
>
> bm = find_bitmap_by_name(bm_list, name);
if (bm == NULL) {
goto fail;
}
You don't set ret, as it's considered success. Worth s/fail/out then (preexisting, of course)?
> @@ -1439,6 +1440,7 @@ void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> fail:
> bitmap_free(bm);
> bitmap_list_free(bm_list);
> + return ret;
> }
>
> void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
> diff --git a/blockdev.c b/blockdev.c
> index 169a8da831..82f02d8e72 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2875,7 +2875,6 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
> {
> BlockDriverState *bs;
> BdrvDirtyBitmap *bitmap;
> - Error *local_err = NULL;
Oh, that's cool. And it was my mistake to create interfaces provoking endless local_errors..
> AioContext *aio_context = NULL;
>
> bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
> @@ -2889,20 +2888,18 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
> }
>
> if (bdrv_dirty_bitmap_get_persistence(bitmap)) {
> + int ret;
> +
> aio_context = bdrv_get_aio_context(bs);
and here, could you define aio_context in this block?
> aio_context_acquire(aio_context);
> - bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err);
> - if (local_err != NULL) {
> - error_propagate(errp, local_err);
> - goto out;
> + ret = bdrv_remove_persistent_dirty_bitmap(bs, bitmap, errp);
> + aio_context_release(aio_context);
> + if (ret) {
> + return;
> }
> }
>
> bdrv_release_dirty_bitmap(bs, bitmap);
> - out:
> - if (aio_context) {
> - aio_context_release(aio_context);
> - }
> }
>
> /**
>
With some my suggestions or without:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
--
Best regards,
Vladimir
next prev parent reply other threads:[~2019-06-07 16:14 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-06 18:41 [Qemu-devel] [PATCH 0/5] block/dirty-bitmap: check number and size constraints against queued bitmaps John Snow
2019-06-06 18:41 ` [Qemu-devel] [PATCH 1/5] block/qcow2-bitmap: allow bitmap_list_load to return an error code John Snow
2019-06-07 2:07 ` Eric Blake
2019-06-07 12:36 ` Vladimir Sementsov-Ogievskiy
2019-06-06 18:41 ` [Qemu-devel] [PATCH 2/5] block/dirty-bitmap: Refactor bdrv_can_store_new_bitmap John Snow
2019-06-07 2:16 ` Eric Blake
2019-06-07 14:29 ` Vladimir Sementsov-Ogievskiy
2019-06-07 18:10 ` John Snow
2019-06-07 18:15 ` Eric Blake
2019-06-07 18:17 ` Vladimir Sementsov-Ogievskiy
2019-06-07 18:23 ` Vladimir Sementsov-Ogievskiy
2019-06-07 22:08 ` John Snow
2019-06-10 9:29 ` Vladimir Sementsov-Ogievskiy
2019-06-06 18:41 ` [Qemu-devel] [PATCH 3/5] block/dirty-bitmap: rework bdrv_remove_persistent_dirty_bitmap John Snow
2019-06-07 2:24 ` Eric Blake
2019-06-07 14:41 ` Vladimir Sementsov-Ogievskiy [this message]
2019-06-07 18:16 ` John Snow
2019-06-06 18:41 ` [Qemu-devel] [PATCH 4/5] block/qcow2-bitmap: Count queued bitmaps towards nb_bitmaps John Snow
2019-06-07 2:27 ` Eric Blake
2019-06-07 18:04 ` John Snow
2019-06-07 14:58 ` Vladimir Sementsov-Ogievskiy
2019-06-07 18:24 ` John Snow
2019-06-06 18:41 ` [Qemu-devel] [PATCH 5/5] block/qcow2-bitmap: Count queued bitmaps towards directory_size John Snow
2019-06-07 2:30 ` Eric Blake
2019-06-07 19:24 ` John Snow
2019-06-06 21:54 ` [Qemu-devel] [PATCH 0/5] block/dirty-bitmap: check number and size constraints against queued bitmaps no-reply
2019-06-06 22:26 ` John Snow
2019-10-09 18:57 ` Eric Blake
2019-10-09 20:44 ` John Snow
2019-10-10 6:23 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=36d3d30b-08ad-f5a1-ae56-eb2af8866528@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=fam@euphon.net \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).