From: John Snow <jsnow@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
mreitz@redhat.com, vsementsov@parallels.com,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH 06/16] block: Introduce bdrv_dirty_bitmap_set_persistent
Date: Tue, 9 Feb 2016 17:04:21 -0500 [thread overview]
Message-ID: <56BA6265.3070006@redhat.com> (raw)
In-Reply-To: <1453804705-7205-7-git-send-email-famz@redhat.com>
On 01/26/2016 05:38 AM, Fam Zheng wrote:
> By implementing bdrv_dirty_bitmap_set_persistent, a driver can support
> the persistent dirty bitmap feature.
>
> Once a dirty bitmap is made persistent, the driver is responsible for saving
> the dirty bitmap when appropriate, for example before close; if a persistent
> bitmap is removed or made non-persistent, .bdrv_dirty_bitmap_set_persistent
> will be called, the driver should then remove the dirty bitmap from the disk.
>
> This operation is not recursed in block layer, a filter such as blkdebug needs
> to implement the callback and explicitly pass down to bs->file, etc.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> block/dirty-bitmap.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/block/block_int.h | 8 ++++++++
> include/block/dirty-bitmap.h | 4 ++++
> 3 files changed, 50 insertions(+)
>
> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
> index 1aa7f76..882a0db 100644
> --- a/block/dirty-bitmap.c
> +++ b/block/dirty-bitmap.c
> @@ -43,6 +43,7 @@ struct BdrvDirtyBitmap {
> int64_t size; /* Size of the bitmap (Number of sectors) */
> bool disabled; /* Bitmap is read-only */
> int active_iterators; /* How many iterators are active */
> + bool persistent; /* Whether this bitmap is persistent. */
> QLIST_ENTRY(BdrvDirtyBitmap) list;
> };
>
> @@ -71,6 +72,37 @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap)
> bitmap->name = NULL;
> }
>
What's the intended usage of flag_only? (/keeps reading/...)
> +int bdrv_dirty_bitmap_set_persistent(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + bool persistent, bool flag_only,
> + Error **errp)
> +{
> + int ret = 0;
> +
> + if (!bitmap->name) {
> + error_setg(errp, "Cannot change the persistent status of an anonymous"
> + "bitmap");
> + return -EINVAL;
> + }
> +
> + if (persistent == bitmap->persistent) {
> + return 0;
> + }
> +
> + if (!flag_only) {
> + if (!bs->drv || !bs->drv->bdrv_dirty_bitmap_set_persistent) {
> + error_setg(errp, "Not supported in this format.");
> + return -ENOTSUP;
> + }
> + ret = bs->drv->bdrv_dirty_bitmap_set_persistent(bs, bitmap, persistent,
> + errp);
> + }
> + if (!ret) {
> + bitmap->persistent = persistent;
> + }
> + return ret;
> +}
> +
> BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
> uint32_t granularity,
> const char *name,
> @@ -194,6 +226,12 @@ int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
> uint64_t granularity;
> BdrvDirtyBitmap *child;
>
> + if (bitmap->persistent) {
> + error_setg(errp, "Cannot create a successor for a bitmap that is "
> + "persistent");
> + return -1;
> + }
> +
> if (bdrv_dirty_bitmap_frozen(bitmap)) {
> error_setg(errp, "Cannot create a successor for a bitmap that is "
> "currently frozen");
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 5fa58e8..fbc34af 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -305,6 +305,14 @@ struct BlockDriver {
> */
> void (*bdrv_drain)(BlockDriverState *bs);
>
> + /**
> + * Make the dirty bitmap persistent if persistent=true or transient
> + * otherwise.
> + */
> + int (*bdrv_dirty_bitmap_set_persistent)(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + bool persistent, Error **errp);
> +
> QLIST_ENTRY(BlockDriver) list;
> };
>
> diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
> index d14d923..5885720 100644
> --- a/include/block/dirty-bitmap.h
> +++ b/include/block/dirty-bitmap.h
> @@ -24,6 +24,10 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,
> BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs,
> const char *name);
> void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap);
> +int bdrv_dirty_bitmap_set_persistent(BlockDriverState *bs,
> + BdrvDirtyBitmap *bitmap,
> + bool persistent, bool flag_only,
> + Error **errp);
> void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
> void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
> void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
>
next prev parent reply other threads:[~2016-02-09 22:04 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 10:38 [Qemu-devel] [RFC PATCH 00/16] Qemu Bit Map (QBM) - an overlay format for persistent dirty bitmap Fam Zheng
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 01/16] doc: Add QBM format specification Fam Zheng
2016-01-26 17:51 ` Eric Blake
2016-02-09 0:05 ` John Snow
2016-02-23 8:35 ` Markus Armbruster
2016-02-08 23:51 ` John Snow
2016-02-17 11:48 ` Vladimir Sementsov-Ogievskiy
2016-02-17 16:30 ` Vladimir Sementsov-Ogievskiy
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 02/16] block: Set dirty before doing write Fam Zheng
2016-01-26 17:52 ` Eric Blake
2016-02-09 0:11 ` John Snow
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 03/16] block: Allow .bdrv_close callback to release dirty bitmaps Fam Zheng
2016-01-26 17:53 ` Eric Blake
2016-02-09 0:23 ` John Snow
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 04/16] block: Move filename_decompose to block.c Fam Zheng
2016-01-27 16:07 ` Eric Blake
2016-02-09 20:56 ` John Snow
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 05/16] block: Make bdrv_get_cluster_size public Fam Zheng
2016-01-27 16:08 ` Eric Blake
2016-02-09 21:06 ` John Snow
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 06/16] block: Introduce bdrv_dirty_bitmap_set_persistent Fam Zheng
2016-02-09 21:31 ` John Snow
2016-02-09 22:04 ` John Snow [this message]
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 07/16] block: Only swap non-persistent dirty bitmaps Fam Zheng
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 08/16] qmp: Add optional parameter "persistent" in block-dirty-bitmap-add Fam Zheng
2016-02-09 22:05 ` John Snow
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 09/16] qmp: Add block-dirty-bitmap-set-persistent Fam Zheng
2016-02-09 22:49 ` John Snow
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 10/16] qbm: Implement format driver Fam Zheng
2016-02-17 13:30 ` Vladimir Sementsov-Ogievskiy
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 11/16] qapi: Add "qbm" as a generic cow " Fam Zheng
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 12/16] iotests: Add qbm format to 041 Fam Zheng
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 13/16] iotests: Add qbm to case 097 Fam Zheng
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 14/16] iotests: Add qbm to applicable test cases Fam Zheng
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 15/16] iotests: Add qbm specific test case 140 Fam Zheng
2016-01-26 10:38 ` [Qemu-devel] [RFC PATCH 16/16] iotests: Add persistent bitmap test case 141 Fam Zheng
2016-02-22 14:24 ` [Qemu-devel] [RFC PATCH 00/16] Qemu Bit Map (QBM) - an overlay format for persistent dirty bitmap Kevin Wolf
2016-02-23 3:40 ` Fam Zheng
2016-02-23 17:43 ` Kevin Wolf
2016-02-24 0:49 ` Fam Zheng
2016-02-23 9:14 ` Markus Armbruster
2016-02-23 11:28 ` Kevin Wolf
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=56BA6265.3070006@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@parallels.com \
/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).