From: Max Reitz <mreitz@redhat.com>
To: John Snow <jsnow@redhat.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <famz@redhat.com>
Subject: Re: [Qemu-devel] [2.3 PATCH v7 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable
Date: Wed, 26 Nov 2014 13:51:56 +0100 [thread overview]
Message-ID: <5475CCEC.5090602@redhat.com> (raw)
In-Reply-To: <1416944800-17919-7-git-send-email-jsnow@redhat.com>
On 2014-11-25 at 20:46, John Snow wrote:
> From: Fam Zheng <famz@redhat.com>
>
> This allows to put the dirty bitmap into a disabled state where no more
> writes will be tracked.
>
> It will be used before backup or writing to persistent file.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> block.c | 15 +++++++++++++
> blockdev.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++
> include/block/block.h | 2 ++
> qapi/block-core.json | 28 +++++++++++++++++++++++
> qmp-commands.hx | 10 +++++++++
> 5 files changed, 117 insertions(+)
>
> diff --git a/block.c b/block.c
> index 9582550..7217066 100644
> --- a/block.c
> +++ b/block.c
> @@ -56,6 +56,7 @@ struct BdrvDirtyBitmap {
> int64_t size;
> int64_t granularity;
> char *name;
> + bool enabled;
> QLIST_ENTRY(BdrvDirtyBitmap) list;
> };
>
> @@ -5361,6 +5362,7 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
> bitmap->granularity = granularity;
> bitmap->bitmap = hbitmap_alloc(bitmap->size, ffs(sector_granularity) - 1);
> bitmap->name = g_strdup(name);
> + bitmap->enabled = true;
> QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list);
> return bitmap;
> }
> @@ -5379,6 +5381,16 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
> }
> }
>
> +void bdrv_disable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
> +{
> + bitmap->enabled = false;
> +}
> +
> +void bdrv_enable_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
> +{
> + bitmap->enabled = true;
> +}
> +
> BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
> {
> BdrvDirtyBitmap *bm;
> @@ -5447,6 +5459,9 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
> {
> BdrvDirtyBitmap *bitmap;
> QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
> + if (!bitmap->enabled) {
> + continue;
> + }
> hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors);
> }
> }
> diff --git a/blockdev.c b/blockdev.c
> index e2fe687..baaf902 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1873,6 +1873,68 @@ void qmp_block_dirty_bitmap_remove(const char *device, const char *name,
> bdrv_release_dirty_bitmap(bs, bitmap);
> }
>
> +static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *device,
> + const char *name,
> + Error **errp)
> +{
> + BlockDriverState *bs;
> + BdrvDirtyBitmap *bitmap;
> + Error *local_err = NULL;
> +
> + if (!device) {
> + error_setg(errp, "Device cannot be NULL");
> + return NULL;
> + }
> + if (!name) {
> + error_setg(errp, "Bitmap name cannot be NULL");
> + return NULL;
> + }
> +
> + bs = bdrv_lookup_bs(device, NULL, &local_err);
> + if (!bs) {
> + error_propagate(errp, local_err);
Comments from patch 2 apply here as well: I'm still in favor of
blk_by_name(), and you don't need local_err.
> + return NULL;
> + }
> +
> + bitmap = bdrv_find_dirty_bitmap(bs, name);
> + if (!bitmap) {
> + error_setg(errp, "Dirty bitmap not found: %s", name);
> + return NULL;
> + }
> +
> + return bitmap;
> +}
> +
> +void qmp_block_dirty_bitmap_enable(const char *device, const char *name,
> + Error **errp)
> +{
> + BdrvDirtyBitmap *bitmap;
> + Error *local_err = NULL;
> +
> + bitmap = block_dirty_bitmap_lookup(device, name, &local_err);
> + if (!bitmap) {
> + error_propagate(errp, local_err);
Again, no need for error_propagate().
> + return;
> + }
> +
> + bdrv_enable_dirty_bitmap(NULL, bitmap);
> +}
> +
> +void qmp_block_dirty_bitmap_disable(const char *device, const char *name,
> + Error **errp)
> +{
> + BdrvDirtyBitmap *bitmap;
> + Error *local_err = NULL;
> +
> + bitmap = block_dirty_bitmap_lookup(device, name, &local_err);
> + if (!bitmap) {
> + error_propagate(errp, local_err);
Here, too.
With or without any of the "ret = foo(..., &local_err); if (ret
indicates error) { error_propagate(errp, local_err);" replaced by "ret =
foo(..., errp); if (ret indicates error) {":
Reviewed-by: Max Reitz <mreitz@redhat.com>
next prev parent reply other threads:[~2014-11-26 12:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 19:46 [Qemu-devel] [2.3 PATCH v7 00/10] block: Incremental backup series John Snow
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 01/10] qapi: Add optional field "name" to block dirty bitmap John Snow
2014-11-26 11:22 ` Max Reitz
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 02/10] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove John Snow
2014-11-26 12:19 ` Max Reitz
2014-11-26 15:39 ` John Snow
2014-11-26 15:53 ` Max Reitz
2014-11-27 9:16 ` Markus Armbruster
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 03/10] block: Introduce bdrv_dirty_bitmap_granularity() John Snow
2014-11-26 12:29 ` Max Reitz
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 04/10] hbitmap: Add hbitmap_copy John Snow
2014-11-26 12:32 ` Max Reitz
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 05/10] block: Add bdrv_copy_dirty_bitmap and bdrv_reset_dirty_bitmap John Snow
2014-11-26 12:43 ` Max Reitz
2014-11-26 16:01 ` Eric Blake
2014-11-27 9:05 ` Markus Armbruster
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable John Snow
2014-11-26 12:51 ` Max Reitz [this message]
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 07/10] qmp: Add support of "dirty-bitmap" sync mode for drive-backup John Snow
2014-11-26 14:19 ` Max Reitz
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 08/10] qapi: Add transaction support to block-dirty-bitmap-{add, enable, disable} John Snow
2014-11-26 14:44 ` Max Reitz
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 09/10] qmp: Add dirty bitmap 'enabled' field in query-block John Snow
2014-11-26 14:49 ` Max Reitz
2014-11-25 19:46 ` [Qemu-devel] [2.3 PATCH v7 10/10] qemu-iotests: Add tests for drive-backup sync=dirty-bitmap John Snow
2014-11-26 14:52 ` Max Reitz
2014-11-25 19:55 ` [Qemu-devel] [2.3 PATCH v7 00/10] block: Incremental backup series John Snow
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=5475CCEC.5090602@redhat.com \
--to=mreitz@redhat.com \
--cc=famz@redhat.com \
--cc=jsnow@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.