|
|
7711c0 |
From 489118db0f6952e55e05792d9ee53ecd80ef08ea Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Wed, 6 Feb 2019 22:12:31 +0100
|
|
|
7711c0 |
Subject: [PATCH 21/33] block/dirty-bitmaps: add user_locked status checker
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190206221243.7407-12-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 84272
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v2 11/23] block/dirty-bitmaps: add user_locked status checker
|
|
|
7711c0 |
Bugzilla: 1658343
|
|
|
7711c0 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Instead of both frozen and qmp_locked checks, wrap it into one check.
|
|
|
7711c0 |
frozen implies the bitmap is split in two (for backup), and shouldn't
|
|
|
7711c0 |
be modified. qmp_locked implies it's being used by another operation,
|
|
|
7711c0 |
like being exported over NBD. In both cases it means we shouldn't allow
|
|
|
7711c0 |
the user to modify it in any meaningful way.
|
|
|
7711c0 |
|
|
|
7711c0 |
Replace any usages where we check both frozen and qmp_locked with the
|
|
|
7711c0 |
new check.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Message-id: 20181002230218.13949-2-jsnow@redhat.com
|
|
|
7711c0 |
[w/edits Suggested-By: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>]
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 993edc0ce0c6f44deb8272a7a857e419417f5f84)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
block/dirty-bitmap.c | 6 ++++++
|
|
|
7711c0 |
blockdev.c | 29 ++++++++---------------------
|
|
|
7711c0 |
include/block/dirty-bitmap.h | 1 +
|
|
|
7711c0 |
migration/block-dirty-bitmap.c | 10 ++--------
|
|
|
7711c0 |
4 files changed, 17 insertions(+), 29 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
|
|
|
7711c0 |
index a9421cd..8cc7b71 100644
|
|
|
7711c0 |
--- a/block/dirty-bitmap.c
|
|
|
7711c0 |
+++ b/block/dirty-bitmap.c
|
|
|
7711c0 |
@@ -176,6 +176,12 @@ bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap)
|
|
|
7711c0 |
return bitmap->successor;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
+/* Both conditions disallow user-modification via QMP. */
|
|
|
7711c0 |
+bool bdrv_dirty_bitmap_user_locked(BdrvDirtyBitmap *bitmap) {
|
|
|
7711c0 |
+ return bdrv_dirty_bitmap_frozen(bitmap) ||
|
|
|
7711c0 |
+ bdrv_dirty_bitmap_qmp_locked(bitmap);
|
|
|
7711c0 |
+}
|
|
|
7711c0 |
+
|
|
|
7711c0 |
void bdrv_dirty_bitmap_set_qmp_locked(BdrvDirtyBitmap *bitmap, bool qmp_locked)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
qemu_mutex_lock(bitmap->mutex);
|
|
|
7711c0 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
7711c0 |
index df0cbe2..6cf7654 100644
|
|
|
7711c0 |
--- a/blockdev.c
|
|
|
7711c0 |
+++ b/blockdev.c
|
|
|
7711c0 |
@@ -2161,11 +2161,8 @@ static void block_dirty_bitmap_clear_prepare(BlkActionState *common,
|
|
|
7711c0 |
return;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
- if (bdrv_dirty_bitmap_frozen(state->bitmap)) {
|
|
|
7711c0 |
- error_setg(errp, "Cannot modify a frozen bitmap");
|
|
|
7711c0 |
- return;
|
|
|
7711c0 |
- } else if (bdrv_dirty_bitmap_qmp_locked(state->bitmap)) {
|
|
|
7711c0 |
- error_setg(errp, "Cannot modify a locked bitmap");
|
|
|
7711c0 |
+ if (bdrv_dirty_bitmap_user_locked(state->bitmap)) {
|
|
|
7711c0 |
+ error_setg(errp, "Cannot modify a bitmap in use by another operation");
|
|
|
7711c0 |
return;
|
|
|
7711c0 |
} else if (!bdrv_dirty_bitmap_enabled(state->bitmap)) {
|
|
|
7711c0 |
error_setg(errp, "Cannot clear a disabled bitmap");
|
|
|
7711c0 |
@@ -3034,15 +3031,10 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
|
|
|
7711c0 |
return;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
- if (bdrv_dirty_bitmap_frozen(bitmap)) {
|
|
|
7711c0 |
- error_setg(errp,
|
|
|
7711c0 |
- "Bitmap '%s' is currently frozen and cannot be removed",
|
|
|
7711c0 |
- name);
|
|
|
7711c0 |
- return;
|
|
|
7711c0 |
- } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
|
|
|
7711c0 |
+ if (bdrv_dirty_bitmap_user_locked(bitmap)) {
|
|
|
7711c0 |
error_setg(errp,
|
|
|
7711c0 |
- "Bitmap '%s' is currently locked and cannot be removed",
|
|
|
7711c0 |
- name);
|
|
|
7711c0 |
+ "Bitmap '%s' is currently in use by another operation and"
|
|
|
7711c0 |
+ " cannot be removed", name);
|
|
|
7711c0 |
return;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
@@ -3072,15 +3064,10 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
|
|
|
7711c0 |
return;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
- if (bdrv_dirty_bitmap_frozen(bitmap)) {
|
|
|
7711c0 |
+ if (bdrv_dirty_bitmap_user_locked(bitmap)) {
|
|
|
7711c0 |
error_setg(errp,
|
|
|
7711c0 |
- "Bitmap '%s' is currently frozen and cannot be modified",
|
|
|
7711c0 |
- name);
|
|
|
7711c0 |
- return;
|
|
|
7711c0 |
- } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
|
|
|
7711c0 |
- error_setg(errp,
|
|
|
7711c0 |
- "Bitmap '%s' is currently locked and cannot be modified",
|
|
|
7711c0 |
- name);
|
|
|
7711c0 |
+ "Bitmap '%s' is currently in use by another operation"
|
|
|
7711c0 |
+ " and cannot be cleared", name);
|
|
|
7711c0 |
return;
|
|
|
7711c0 |
} else if (!bdrv_dirty_bitmap_enabled(bitmap)) {
|
|
|
7711c0 |
error_setg(errp,
|
|
|
7711c0 |
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
|
|
|
7711c0 |
index 201ff7f..1463943 100644
|
|
|
7711c0 |
--- a/include/block/dirty-bitmap.h
|
|
|
7711c0 |
+++ b/include/block/dirty-bitmap.h
|
|
|
7711c0 |
@@ -94,6 +94,7 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
|
|
|
7711c0 |
bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
|
|
|
7711c0 |
bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap);
|
|
|
7711c0 |
bool bdrv_dirty_bitmap_qmp_locked(BdrvDirtyBitmap *bitmap);
|
|
|
7711c0 |
+bool bdrv_dirty_bitmap_user_locked(BdrvDirtyBitmap *bitmap);
|
|
|
7711c0 |
bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
|
|
|
7711c0 |
BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
|
|
|
7711c0 |
BdrvDirtyBitmap *bitmap);
|
|
|
7711c0 |
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
|
|
|
7711c0 |
index fefbc6a..47251af 100644
|
|
|
7711c0 |
--- a/migration/block-dirty-bitmap.c
|
|
|
7711c0 |
+++ b/migration/block-dirty-bitmap.c
|
|
|
7711c0 |
@@ -301,14 +301,8 @@ static int init_dirty_bitmap_migration(void)
|
|
|
7711c0 |
goto fail;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
- if (bdrv_dirty_bitmap_frozen(bitmap)) {
|
|
|
7711c0 |
- error_report("Can't migrate frozen dirty bitmap: '%s",
|
|
|
7711c0 |
- bdrv_dirty_bitmap_name(bitmap));
|
|
|
7711c0 |
- goto fail;
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
-
|
|
|
7711c0 |
- if (bdrv_dirty_bitmap_qmp_locked(bitmap)) {
|
|
|
7711c0 |
- error_report("Can't migrate locked dirty bitmap: '%s",
|
|
|
7711c0 |
+ if (bdrv_dirty_bitmap_user_locked(bitmap)) {
|
|
|
7711c0 |
+ error_report("Can't migrate a bitmap that is in use by another operation: '%s'",
|
|
|
7711c0 |
bdrv_dirty_bitmap_name(bitmap));
|
|
|
7711c0 |
goto fail;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|