[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 07/16] block: Only swap non-persistent dirty bit
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [RFC PATCH 07/16] block: Only swap non-persistent dirty bitmaps |
Date: |
Tue, 26 Jan 2016 18:38:16 +0800 |
Persistent dirty bitmaps are special because they're tightly associated
with, or even belonging to the driver, swapping them doesn't make much
sense. Because this has nothing to do with backward compatibility, it's
okay to just let them stay with the old BDS.
Signed-off-by: Fam Zheng <address@hidden>
---
block.c | 11 +++++------
block/dirty-bitmap.c | 25 +++++++++++++++++++++++++
include/block/dirty-bitmap.h | 1 +
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 78db342..3a29de2 100644
--- a/block.c
+++ b/block.c
@@ -2274,9 +2274,6 @@ static void bdrv_move_feature_fields(BlockDriverState
*bs_dest,
bs_dest->copy_on_read = bs_src->copy_on_read;
bs_dest->enable_write_cache = bs_src->enable_write_cache;
-
- /* dirty bitmap */
- bs_dest->dirty_bitmaps = bs_src->dirty_bitmaps;
}
static void change_parent_backing_link(BlockDriverState *from,
@@ -2302,10 +2299,12 @@ static void change_parent_backing_link(BlockDriverState
*from,
}
static void swap_feature_fields(BlockDriverState *bs_top,
- BlockDriverState *bs_new)
+ BlockDriverState *bs_new,
+ Error **errp)
{
BlockDriverState tmp;
+ bdrv_dirty_bitmap_swap(bs_top, bs_new);
bdrv_move_feature_fields(&tmp, bs_top);
bdrv_move_feature_fields(bs_top, bs_new);
bdrv_move_feature_fields(bs_new, &tmp);
@@ -2343,7 +2342,7 @@ void bdrv_append(BlockDriverState *bs_new,
BlockDriverState *bs_top)
change_parent_backing_link(bs_top, bs_new);
/* Some fields always stay on top of the backing file chain */
- swap_feature_fields(bs_top, bs_new);
+ swap_feature_fields(bs_top, bs_new, NULL);
bdrv_set_backing_hd(bs_new, bs_top);
bdrv_unref(bs_top);
@@ -2368,7 +2367,7 @@ void bdrv_replace_in_backing_chain(BlockDriverState *old,
BlockDriverState *new)
* swap instead so that pointers aren't duplicated and cause trouble.
* (Also, bdrv_swap() used to do the same.) */
assert(!new->blk);
- swap_feature_fields(old, new);
+ swap_feature_fields(old, new, NULL);
}
change_parent_backing_link(old, new);
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 882a0db..a3a401f 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -65,6 +65,31 @@ BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState
*bs, const char *name)
return NULL;
}
+/* Swap non-persistent dirty bitmaps. */
+void bdrv_dirty_bitmap_swap(BlockDriverState *bs1, BlockDriverState *bs2)
+{
+ BdrvDirtyBitmap *bm, *next;
+ QLIST_HEAD(, BdrvDirtyBitmap) tmp = QLIST_HEAD_INITIALIZER(&tmp);
+
+ QLIST_FOREACH_SAFE(bm, &bs1->dirty_bitmaps, list, next) {
+ if (bm->persistent) {
+ continue;
+ }
+ QLIST_REMOVE(bm, list);
+ QLIST_INSERT_HEAD(&tmp, bm, list);
+ }
+ QLIST_FOREACH_SAFE(bm, &bs2->dirty_bitmaps, list, next) {
+ if (bm->persistent) {
+ continue;
+ }
+ QLIST_REMOVE(bm, list);
+ QLIST_INSERT_HEAD(&bs1->dirty_bitmaps, bm, list);
+ }
+ QLIST_FOREACH_SAFE(bm, &tmp, list, next) {
+ QLIST_INSERT_HEAD(&bs2->dirty_bitmaps, bm, list);
+ }
+}
+
void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap)
{
assert(!bdrv_dirty_bitmap_frozen(bitmap));
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 5885720..a4de9c7 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -23,6 +23,7 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState
*bs,
Error **errp);
BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs,
const char *name);
+void bdrv_dirty_bitmap_swap(BlockDriverState *bs1, BlockDriverState *bs2);
void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap);
int bdrv_dirty_bitmap_set_persistent(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap,
--
2.4.3
- [Qemu-devel] [RFC PATCH 00/16] Qemu Bit Map (QBM) - an overlay format for persistent dirty bitmap, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 01/16] doc: Add QBM format specification, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 02/16] block: Set dirty before doing write, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 03/16] block: Allow .bdrv_close callback to release dirty bitmaps, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 04/16] block: Move filename_decompose to block.c, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 05/16] block: Make bdrv_get_cluster_size public, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 06/16] block: Introduce bdrv_dirty_bitmap_set_persistent, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 07/16] block: Only swap non-persistent dirty bitmaps,
Fam Zheng <=
- [Qemu-devel] [RFC PATCH 08/16] qmp: Add optional parameter "persistent" in block-dirty-bitmap-add, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 09/16] qmp: Add block-dirty-bitmap-set-persistent, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 11/16] qapi: Add "qbm" as a generic cow format driver, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 10/16] qbm: Implement format driver, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 12/16] iotests: Add qbm format to 041, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 13/16] iotests: Add qbm to case 097, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 14/16] iotests: Add qbm to applicable test cases, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 15/16] iotests: Add qbm specific test case 140, Fam Zheng, 2016/01/26
- [Qemu-devel] [RFC PATCH 16/16] iotests: Add persistent bitmap test case 141, Fam Zheng, 2016/01/26