From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, John Snow <jsnow@redhat.com>,
jcody@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/9] hbitmap: add hbitmap_copy
Date: Thu, 4 Jun 2015 20:20:35 -0400 [thread overview]
Message-ID: <1433463642-21840-3-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1433463642-21840-1-git-send-email-jsnow@redhat.com>
It would be nice to have the flexibility to decide that
we would like multiple backup chains (perhaps of differing
frequency, or stored at different sites -- who knows.)
If the user didn't have the foresight to add all the requisite
bitmaps before the drive was engaged, the copy function will
allow them to later differentiate an incremental backup chain
into two or more chains at will.
hbitmap_copy here is just the primitive to make copies of the
implementation bitmap.
Signed-off-by: John Snow <jsnow@redhat.com>
---
include/qemu/hbitmap.h | 9 +++++++++
util/hbitmap.c | 17 +++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index f0a85f8..e24fbe7 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -88,6 +88,15 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size);
bool hbitmap_merge(HBitmap *a, const HBitmap *b);
/**
+ * hbitmap_copy:
+ * @hb: The bitmap to copy.
+ * @return The newly copied bitmap.
+ *
+ * Given a bitmap, create a new one with all the same bits set.
+ */
+HBitmap *hbitmap_copy(const HBitmap *hb);
+
+/**
* hbitmap_empty:
* @hb: HBitmap to operate on.
*
diff --git a/util/hbitmap.c b/util/hbitmap.c
index a10c7ae..544ecd5 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -93,6 +93,9 @@ struct HBitmap {
/* The length of each levels[] array. */
uint64_t sizes[HBITMAP_LEVELS];
+
+ /* NB: If any pointers are introduced into this structure, take care to
+ * update hbitmap_copy() accordingly. */
};
/* Advance hbi to the next nonzero word and return it. hbi->pos
@@ -480,3 +483,17 @@ bool hbitmap_merge(HBitmap *a, const HBitmap *b)
return true;
}
+
+
+HBitmap *hbitmap_copy(const HBitmap *bitmap)
+{
+ int i;
+ HBitmap *hb = g_memdup(bitmap, sizeof(HBitmap));
+
+ for (i = HBITMAP_LEVELS - 1; i >= 0; i--) {
+ hb->levels[i] = g_memdup(bitmap->levels[i],
+ hb->sizes[i] * sizeof(unsigned long));
+ }
+
+ return hb;
+}
--
2.1.0
next prev parent reply other threads:[~2015-06-05 0:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 0:20 [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 1/9] qapi: Rename 'dirty-bitmap' mode to 'incremental' John Snow
2015-06-05 2:34 ` Eric Blake
2015-06-25 16:16 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-05 0:20 ` John Snow [this message]
2015-06-05 2:37 ` [Qemu-devel] [PATCH 2/9] hbitmap: add hbitmap_copy Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 3/9] block: add bdrv_copy_dirty_bitmap John Snow
2015-06-05 2:42 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 4/9] qapi: add Copy data type for bitmaps John Snow
2015-06-05 2:57 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 5/9] qmp: add qmp cmd block-dirty-bitmap-copy John Snow
2015-06-05 3:04 ` Eric Blake
2015-06-05 0:20 ` [Qemu-devel] [PATCH 6/9] qmp: add block-dirty-bitmap-copy transaction John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 7/9] block: add differential backup mode John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 8/9] iotests: 124: support differential backups John Snow
2015-06-05 0:20 ` [Qemu-devel] [PATCH 9/9] iotests: add differential backup test John Snow
2015-06-23 17:00 ` [Qemu-devel] [PATCH 0/9] block: add differential backup support John Snow
2015-06-24 14:33 ` 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=1433463642-21840-3-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@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).