qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, John Snow <jsnow@redhat.com>,
	qemu-devel@nongnu.org, armbru@redhat.com,
	vsementsov@parallels.com, stefanha@redhat.com, mreitz@redhat.com
Subject: [Qemu-devel] [PATCH v6 08/21] block: Add bitmap disabled status
Date: Fri, 17 Apr 2015 19:49:56 -0400	[thread overview]
Message-ID: <1429314609-29776-9-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1429314609-29776-1-git-send-email-jsnow@redhat.com>

Add a status indicating the enabled/disabled state of the bitmap.
A bitmap is by default enabled, but you can lock the bitmap into
a read-only state by setting disabled = true.

A previous version of this patch added a QMP interface for changing
the state of the bitmap, but it has since been removed for now until
a use case emerges where this state must be revealed to the user.

The disabled state WILL be used internally for bitmap migration and
bitmap persistence.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block.c               | 25 +++++++++++++++++++++++++
 include/block/block.h |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/block.c b/block.c
index 41c5a67..db742a9 100644
--- a/block.c
+++ b/block.c
@@ -54,6 +54,7 @@
 struct BdrvDirtyBitmap {
     HBitmap *bitmap;
     char *name;
+    bool disabled;
     QLIST_ENTRY(BdrvDirtyBitmap) list;
 };
 
@@ -5481,10 +5482,16 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
     bitmap = g_new0(BdrvDirtyBitmap, 1);
     bitmap->bitmap = hbitmap_alloc(bitmap_size, ffs(sector_granularity) - 1);
     bitmap->name = g_strdup(name);
+    bitmap->disabled = false;
     QLIST_INSERT_HEAD(&bs->dirty_bitmaps, bitmap, list);
     return bitmap;
 }
 
+bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap)
+{
+    return !bitmap->disabled;
+}
+
 void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
 {
     BdrvDirtyBitmap *bm, *next;
@@ -5499,6 +5506,16 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
     }
 }
 
+void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
+{
+    bitmap->disabled = true;
+}
+
+void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
+{
+    bitmap->disabled = false;
+}
+
 BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
 {
     BdrvDirtyBitmap *bm;
@@ -5563,12 +5580,14 @@ void bdrv_dirty_iter_init(BlockDriverState *bs,
 void bdrv_set_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
                            int64_t cur_sector, int nr_sectors)
 {
+    assert(bdrv_dirty_bitmap_enabled(bitmap));
     hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors);
 }
 
 void bdrv_reset_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
                              int64_t cur_sector, int nr_sectors)
 {
+    assert(bdrv_dirty_bitmap_enabled(bitmap));
     hbitmap_reset(bitmap->bitmap, cur_sector, nr_sectors);
 }
 
@@ -5577,6 +5596,9 @@ static void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
 {
     BdrvDirtyBitmap *bitmap;
     QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
+        if (!bdrv_dirty_bitmap_enabled(bitmap)) {
+            continue;
+        }
         hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors);
     }
 }
@@ -5586,6 +5608,9 @@ static void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector,
 {
     BdrvDirtyBitmap *bitmap;
     QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
+        if (!bdrv_dirty_bitmap_enabled(bitmap)) {
+            continue;
+        }
         hbitmap_reset(bitmap->bitmap, cur_sector, nr_sectors);
     }
 }
diff --git a/include/block/block.h b/include/block/block.h
index 493b7c5..029a8a7 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -457,9 +457,12 @@ BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs,
                                         const char *name);
 void bdrv_dirty_bitmap_make_anon(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
 void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
+void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
+void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
 BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs);
 uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs);
 uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap);
+bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap);
 int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector);
 void bdrv_set_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
                            int64_t cur_sector, int nr_sectors);
-- 
2.1.0

  parent reply	other threads:[~2015-04-17 23:50 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-17 23:49 [Qemu-devel] [PATCH v6 00/21] block: transactionless incremental backup series John Snow
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 01/21] docs: incremental backup documentation John Snow
2015-04-22 16:17   ` Max Reitz
2015-04-22 19:20   ` Eric Blake
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 02/21] qapi: Add optional field "name" to block dirty bitmap John Snow
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 03/21] qmp: Ensure consistent granularity type John Snow
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 04/21] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove John Snow
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 05/21] block: Introduce bdrv_dirty_bitmap_granularity() John Snow
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 06/21] hbitmap: cache array lengths John Snow
2015-04-23 13:39   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 07/21] hbitmap: add hbitmap_merge John Snow
2015-04-22 16:22   ` Max Reitz
2015-04-22 22:00   ` Eric Blake
2015-04-23 13:40   ` Stefan Hajnoczi
2015-04-17 23:49 ` John Snow [this message]
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 09/21] block: Add bitmap successors John Snow
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 10/21] qmp: Add support of "dirty-bitmap" sync mode for drive-backup John Snow
2015-04-22 16:33   ` Max Reitz
2015-04-22 22:11   ` Eric Blake
2015-04-23 13:47   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-17 23:49 ` [Qemu-devel] [PATCH v6 11/21] qmp: add block-dirty-bitmap-clear John Snow
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 12/21] qmp: Add dirty bitmap status field in query-block John Snow
2015-04-22 22:18   ` Eric Blake
2015-04-22 22:22     ` John Snow
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 13/21] block: add BdrvDirtyBitmap documentation John Snow
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 14/21] block: Ensure consistent bitmap function prototypes John Snow
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 15/21] block: Resize bitmaps on bdrv_truncate John Snow
2015-04-22 16:35   ` Max Reitz
2015-04-23 13:51   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 16/21] hbitmap: truncate tests John Snow
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 17/21] iotests: add invalid input incremental backup tests John Snow
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 18/21] iotests: add QMP event waiting queue John Snow
2015-04-22 16:50   ` Max Reitz
2015-04-23 14:24   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 19/21] iotests: add simple incremental backup case John Snow
2015-04-23 14:28   ` Stefan Hajnoczi
2015-05-22 15:02   ` Kevin Wolf
2015-05-22 15:29     ` John Snow
2015-05-22 15:37       ` Kevin Wolf
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 20/21] iotests: add incremental backup failure recovery test John Snow
2015-04-23 14:28   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-11-27 17:14   ` [Qemu-devel] " Kevin Wolf
2015-11-30 17:17     ` John Snow
2015-12-01  9:31       ` Kevin Wolf
2015-04-17 23:50 ` [Qemu-devel] [PATCH v6 21/21] iotests: add incremental backup granularity tests John Snow
2015-04-23 14:29   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-23 13:19 ` [Qemu-devel] [Qemu-block] [PATCH v6 00/21] block: transactionless incremental backup series Stefan Hajnoczi
2015-04-23 14:41   ` John Snow
2015-04-23 19:18     ` Eric Blake
2015-04-23 19:40       ` John Snow
2015-04-24  8:37         ` Stefan Hajnoczi
2015-04-24 14:02 ` [Qemu-devel] " Stefan Hajnoczi

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=1429314609-29776-9-git-send-email-jsnow@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).