diff mbox series

[RFC,v2,2/6] bitmaps: allow clear on disabled bitmaps

Message ID 20180921222847.1012-3-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show
Series dirty-bitmaps: fix QMP command permissions | expand

Commit Message

John Snow Sept. 21, 2018, 10:28 p.m. UTC
Similarly to merge, it's OK to allow clear operations on disabled
bitmaps, as this condition only means that they are not recording
new writes. We are free to clear it if the user requests it.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 block/dirty-bitmap.c | 1 -
 blockdev.c           | 8 --------
 2 files changed, 9 deletions(-)
diff mbox series

Patch

diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index fa7e75e0af..5c8a7bbf6f 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -619,7 +619,6 @@  void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
 
 void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out)
 {
-    assert(bdrv_dirty_bitmap_enabled(bitmap));
     assert(!bdrv_dirty_bitmap_readonly(bitmap));
     bdrv_dirty_bitmap_lock(bitmap);
     if (!out) {
diff --git a/blockdev.c b/blockdev.c
index 72f5347df5..bb8d75c832 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2015,9 +2015,6 @@  static void block_dirty_bitmap_clear_prepare(BlkActionState *common,
     } else if (bdrv_dirty_bitmap_qmp_locked(state->bitmap)) {
         error_setg(errp, "Cannot modify a locked bitmap");
         return;
-    } else if (!bdrv_dirty_bitmap_enabled(state->bitmap)) {
-        error_setg(errp, "Cannot clear a disabled bitmap");
-        return;
     } else if (bdrv_dirty_bitmap_readonly(state->bitmap)) {
         error_setg(errp, "Cannot clear a readonly bitmap");
         return;
@@ -2889,11 +2886,6 @@  void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
                    "Bitmap '%s' is currently locked and cannot be modified",
                    name);
         return;
-    } else if (!bdrv_dirty_bitmap_enabled(bitmap)) {
-        error_setg(errp,
-                   "Bitmap '%s' is currently disabled and cannot be cleared",
-                   name);
-        return;
     } else if (bdrv_dirty_bitmap_readonly(bitmap)) {
         error_setg(errp, "Bitmap '%s' is readonly and cannot be cleared", name);
         return;