[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 12/19] block/qcow2-bitmap: get rid of bdrv_has_changed_persiste
From: |
John Snow |
Subject: |
[PULL v3 12/19] block/qcow2-bitmap: get rid of bdrv_has_changed_persistent_bitmaps |
Date: |
Thu, 17 Oct 2019 17:54:29 -0400 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Firstly, no reason to optimize failure path. Then, function name is
ambiguous: it checks for readonly and similar things, but someone may
think that it will ignore normal bitmaps which was just unchanged, and
this is in bad relation with the fact that we should drop IN_USE flag
for unchanged bitmaps in the image.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: John Snow <address@hidden>
Message-id: address@hidden
Signed-off-by: John Snow <address@hidden>
---
include/block/dirty-bitmap.h | 1 -
block/dirty-bitmap.c | 12 ------------
block/qcow2-bitmap.c | 23 +++++++++++++----------
3 files changed, 13 insertions(+), 23 deletions(-)
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index 257f0f6704..958e7474fb 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -95,7 +95,6 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
bool bdrv_dirty_bitmap_get_persistence(BdrvDirtyBitmap *bitmap);
bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap *bitmap);
-bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
BdrvDirtyBitmap *bdrv_dirty_bitmap_first(BlockDriverState *bs);
BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BdrvDirtyBitmap *bitmap);
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 6065db8094..4bbb251b2c 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -839,18 +839,6 @@ bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap
*bitmap)
return bitmap->inconsistent;
}
-bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs)
-{
- BdrvDirtyBitmap *bm;
- QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
- if (bm->persistent && !bm->readonly && !bm->skip_store) {
- return true;
- }
- }
-
- return false;
-}
-
BdrvDirtyBitmap *bdrv_dirty_bitmap_first(BlockDriverState *bs)
{
return QLIST_FIRST(&bs->dirty_bitmaps);
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 99812b418b..6dfc083548 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1464,16 +1464,7 @@ void
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
Qcow2Bitmap *bm;
QSIMPLEQ_HEAD(, Qcow2BitmapTable) drop_tables;
Qcow2BitmapTable *tb, *tb_next;
-
- if (!bdrv_has_changed_persistent_bitmaps(bs)) {
- /* nothing to do */
- return;
- }
-
- if (!can_write(bs)) {
- error_setg(errp, "No write access");
- return;
- }
+ bool need_write = false;
QSIMPLEQ_INIT(&drop_tables);
@@ -1499,6 +1490,8 @@ void
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
continue;
}
+ need_write = true;
+
if (check_constraints_on_bitmap(bs, name, granularity, errp) < 0) {
error_prepend(errp, "Bitmap '%s' doesn't satisfy the constraints:
",
name);
@@ -1537,6 +1530,15 @@ void
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
bm->dirty_bitmap = bitmap;
}
+ if (!need_write) {
+ goto success;
+ }
+
+ if (!can_write(bs)) {
+ error_setg(errp, "No write access");
+ goto fail;
+ }
+
/* allocate clusters and store bitmaps */
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
if (bm->dirty_bitmap == NULL) {
@@ -1578,6 +1580,7 @@ void
qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)
bdrv_release_dirty_bitmap(bm->dirty_bitmap);
}
+success:
bitmap_list_free(bm_list);
return;
--
2.21.0
- [PULL v3 01/19] util/hbitmap: strict hbitmap_reset, (continued)
- [PULL v3 01/19] util/hbitmap: strict hbitmap_reset, John Snow, 2019/10/17
- [PULL v3 02/19] block: move bdrv_can_store_new_dirty_bitmap to block/dirty-bitmap.c, John Snow, 2019/10/17
- [PULL v3 03/19] block/dirty-bitmap: return int from bdrv_remove_persistent_dirty_bitmap, John Snow, 2019/10/17
- [PULL v3 04/19] block/qcow2: proper locking on bitmap add/remove paths, John Snow, 2019/10/17
- [PULL v3 05/19] block/dirty-bitmap: drop meta, John Snow, 2019/10/17
- [PULL v3 07/19] block/dirty-bitmap: drop BdrvDirtyBitmap.mutex, John Snow, 2019/10/17
- [PULL v3 06/19] block/dirty-bitmap: add bs link, John Snow, 2019/10/17
- [PULL v3 08/19] block/dirty-bitmap: refactor bdrv_dirty_bitmap_next, John Snow, 2019/10/17
- [PULL v3 10/19] block: reverse order for reopen commits, John Snow, 2019/10/17
- [PULL v3 09/19] block: switch reopen queue from QSIMPLEQ to QTAILQ, John Snow, 2019/10/17
- [PULL v3 12/19] block/qcow2-bitmap: get rid of bdrv_has_changed_persistent_bitmaps,
John Snow <=
- [PULL v3 11/19] iotests: add test-case to 165 to test reopening qcow2 bitmaps to RW, John Snow, 2019/10/17
- [PULL v3 13/19] block/qcow2-bitmap: drop qcow2_reopen_bitmaps_rw_hint(), John Snow, 2019/10/17
- [PULL v3 15/19] iotests: add test 260 to check bitmap life after snapshot + commit, John Snow, 2019/10/17
- [PULL v3 14/19] block/qcow2-bitmap: do not remove bitmaps on reopen-ro, John Snow, 2019/10/17
- [PULL v3 16/19] block/qcow2-bitmap: fix and improve qcow2_reopen_bitmaps_rw, John Snow, 2019/10/17
- [PULL v3 17/19] qcow2-bitmap: move bitmap reopen-rw code to qcow2_reopen_commit, John Snow, 2019/10/17
- [PULL v3 18/19] MAINTAINERS: Add Vladimir as a reviewer for bitmaps, John Snow, 2019/10/17
- [PULL v3 19/19] dirty-bitmaps: remove deprecated autoload parameter, John Snow, 2019/10/17
- Re: [PULL v3 00/19] Bitmaps patches, Peter Maydell, 2019/10/18