From: Liran Schour <lirans@il.ibm.com>
To: qemu-devel@nongnu.org
Cc: Liran Schour <lirans@il.ibm.com>
Subject: [Qemu-devel] [PATCH 3/4] Count dirty blocks and expose an API to get dirty count
Date: Tue, 12 Jan 2010 10:27:12 +0200 [thread overview]
Message-ID: <12632848351489-git-send-email-lirans@il.ibm.com> (raw)
In-Reply-To: <12632848343008-git-send-email-lirans@il.ibm.com>
This will manage dirty counter for each device and will allow to get the
dirty counter from above.
Signed-off-by: Liran Schour <lirans@il.ibm.com>
---
block.c | 20 ++++++++++++++++----
block.h | 1 +
block_int.h | 1 +
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 853f025..ecfcba4 100644
--- a/block.c
+++ b/block.c
@@ -652,9 +652,15 @@ static void set_dirty_bitmap(BlockDriverState *bs, int64_t sector_num,
bit = start % (sizeof(unsigned long) * 8);
val = bs->dirty_bitmap[idx];
if (dirty) {
- val |= 1 << bit;
+ if (!(val & (1 << bit))) {
+ bs->dirty_count++;
+ val |= 1 << bit;
+ }
} else {
- val &= ~(1 << bit);
+ if (val & (1 << bit)) {
+ bs->dirty_count--;
+ val &= ~(1 << bit);
+ }
}
bs->dirty_bitmap[idx] = val;
}
@@ -1972,14 +1978,15 @@ void *qemu_blockalign(BlockDriverState *bs, size_t size)
void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable)
{
int64_t bitmap_size;
-
+
+ bs->dirty_count = 0;
if (enable) {
if (!bs->dirty_bitmap) {
bitmap_size = (bdrv_getlength(bs) >> BDRV_SECTOR_BITS) +
BDRV_SECTORS_PER_DIRTY_CHUNK * 8 - 1;
bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK * 8;
- bs->dirty_bitmap = qemu_mallocz(bitmap_size);
+ bs->dirty_bitmap = qemu_mallocz(bitmap_size);
}
} else {
if (bs->dirty_bitmap) {
@@ -2007,3 +2014,8 @@ void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector,
{
set_dirty_bitmap(bs, cur_sector, nr_sectors, 0);
}
+
+int64_t bdrv_get_dirty_count(BlockDriverState *bs)
+{
+ return bs->dirty_count;
+}
diff --git a/block.h b/block.h
index 4a8b628..bf489d0 100644
--- a/block.h
+++ b/block.h
@@ -198,4 +198,5 @@ void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable);
int bdrv_get_dirty(BlockDriverState *bs, int64_t sector);
void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector,
int nr_sectors);
+int64_t bdrv_get_dirty_count(BlockDriverState *bs);
#endif
diff --git a/block_int.h b/block_int.h
index 9a3b2e0..8d5d9bc 100644
--- a/block_int.h
+++ b/block_int.h
@@ -172,6 +172,7 @@ struct BlockDriverState {
int type;
char device_name[32];
unsigned long *dirty_bitmap;
+ int64_t dirty_count;
BlockDriverState *next;
void *private;
};
--
1.5.2.4
next prev parent reply other threads:[~2010-01-12 7:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-12 8:27 [Qemu-devel] [PATCH 0/4] Reduce down time during migration without shared storage Liran Schour
2010-01-12 8:27 ` [Qemu-devel] [PATCH 1/4] Remove unused code Liran Schour
2010-01-12 8:27 ` [Qemu-devel] [PATCH 2/4] Tranfer dirty blocks during iterative phase Liran Schour
2010-01-12 8:27 ` Liran Schour [this message]
2010-01-12 8:27 ` [Qemu-devel] [PATCH 4/4] Try not to exceed max downtime on stage3 Liran Schour
2010-01-12 9:52 ` Pierre Riteau
2010-01-12 11:56 ` Liran Schour
2010-01-12 11:51 ` [Qemu-devel] " Jan Kiszka
2010-01-12 15:07 ` Anthony Liguori
2010-01-12 15:07 ` Liran Schour
2010-01-12 11:50 ` [Qemu-devel] Re: [PATCH 3/4] Count dirty blocks and expose an API to get dirty count Jan Kiszka
2010-01-12 11:50 ` [Qemu-devel] Re: [PATCH 2/4] Tranfer dirty blocks during iterative phase Jan Kiszka
2010-01-12 11:50 ` [Qemu-devel] Re: [PATCH 1/4] Remove unused code Jan Kiszka
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=12632848351489-git-send-email-lirans@il.ibm.com \
--to=lirans@il.ibm.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 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).