2016-03-08 07:44:55 +03:00
|
|
|
#ifndef BLOCK_DIRTY_BITMAP_H
|
|
|
|
#define BLOCK_DIRTY_BITMAP_H
|
|
|
|
|
|
|
|
#include "qemu-common.h"
|
2018-02-11 12:36:01 +03:00
|
|
|
#include "qapi/qapi-types-block-core.h"
|
2016-03-08 07:44:55 +03:00
|
|
|
#include "qemu/hbitmap.h"
|
|
|
|
|
2019-03-12 19:05:49 +03:00
|
|
|
typedef enum BitmapCheckFlags {
|
|
|
|
BDRV_BITMAP_BUSY = 1,
|
|
|
|
BDRV_BITMAP_RO = 2,
|
|
|
|
BDRV_BITMAP_INCONSISTENT = 4,
|
|
|
|
} BitmapCheckFlags;
|
|
|
|
|
|
|
|
#define BDRV_BITMAP_DEFAULT (BDRV_BITMAP_BUSY | BDRV_BITMAP_RO | \
|
|
|
|
BDRV_BITMAP_INCONSISTENT)
|
|
|
|
#define BDRV_BITMAP_ALLOW_RO (BDRV_BITMAP_BUSY | BDRV_BITMAP_INCONSISTENT)
|
|
|
|
|
2016-03-08 07:44:55 +03:00
|
|
|
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
|
|
|
|
uint32_t granularity,
|
|
|
|
const char *name,
|
|
|
|
Error **errp);
|
2016-10-14 00:58:24 +03:00
|
|
|
void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap,
|
|
|
|
int chunk_size);
|
|
|
|
void bdrv_release_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap);
|
2016-03-08 07:44:55 +03:00
|
|
|
int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs,
|
|
|
|
BdrvDirtyBitmap *bitmap,
|
|
|
|
Error **errp);
|
|
|
|
BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,
|
|
|
|
BdrvDirtyBitmap *bitmap,
|
|
|
|
Error **errp);
|
|
|
|
BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,
|
|
|
|
BdrvDirtyBitmap *bitmap,
|
|
|
|
Error **errp);
|
2018-03-13 22:33:59 +03:00
|
|
|
void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap);
|
2016-03-08 07:44:55 +03:00
|
|
|
BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs,
|
|
|
|
const char *name);
|
2019-03-12 19:05:49 +03:00
|
|
|
int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap *bitmap, uint32_t flags,
|
|
|
|
Error **errp);
|
2016-03-08 07:44:55 +03:00
|
|
|
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
|
|
|
|
void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs);
|
2017-06-28 15:05:27 +03:00
|
|
|
void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
|
|
|
|
const char *name,
|
|
|
|
Error **errp);
|
2016-03-08 07:44:55 +03:00
|
|
|
void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
|
|
|
|
void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);
|
2018-07-04 09:12:49 +03:00
|
|
|
void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap);
|
2016-03-08 07:44:55 +03:00
|
|
|
BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs);
|
|
|
|
uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs);
|
2017-06-28 15:05:05 +03:00
|
|
|
uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap);
|
2016-03-08 07:44:55 +03:00
|
|
|
bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap);
|
2019-03-12 19:05:48 +03:00
|
|
|
bool bdrv_dirty_bitmap_has_successor(BdrvDirtyBitmap *bitmap);
|
2016-10-14 00:58:25 +03:00
|
|
|
const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap *bitmap);
|
|
|
|
int64_t bdrv_dirty_bitmap_size(const BdrvDirtyBitmap *bitmap);
|
2016-03-08 07:44:55 +03:00
|
|
|
DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap);
|
|
|
|
void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:20 +03:00
|
|
|
int64_t offset, int64_t bytes);
|
2016-03-08 07:44:55 +03:00
|
|
|
void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:20 +03:00
|
|
|
int64_t offset, int64_t bytes);
|
2016-10-14 00:58:30 +03:00
|
|
|
BdrvDirtyBitmapIter *bdrv_dirty_meta_iter_new(BdrvDirtyBitmap *bitmap);
|
2017-09-25 17:55:16 +03:00
|
|
|
BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap *bitmap);
|
2016-10-14 00:58:21 +03:00
|
|
|
void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter);
|
2016-03-08 07:44:55 +03:00
|
|
|
|
2016-10-14 00:58:28 +03:00
|
|
|
uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:14 +03:00
|
|
|
uint64_t offset, uint64_t bytes);
|
2016-10-14 00:58:28 +03:00
|
|
|
uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap);
|
|
|
|
void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:14 +03:00
|
|
|
uint8_t *buf, uint64_t offset,
|
|
|
|
uint64_t bytes);
|
2016-10-14 00:58:28 +03:00
|
|
|
void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:14 +03:00
|
|
|
uint8_t *buf, uint64_t offset,
|
|
|
|
uint64_t bytes, bool finish);
|
2016-10-14 00:58:28 +03:00
|
|
|
void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:14 +03:00
|
|
|
uint64_t offset, uint64_t bytes,
|
2016-10-14 00:58:28 +03:00
|
|
|
bool finish);
|
2017-06-28 15:05:06 +03:00
|
|
|
void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:14 +03:00
|
|
|
uint64_t offset, uint64_t bytes,
|
2017-06-28 15:05:06 +03:00
|
|
|
bool finish);
|
2016-10-14 00:58:28 +03:00
|
|
|
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
|
|
|
|
|
2017-06-28 15:05:10 +03:00
|
|
|
void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value);
|
2019-03-12 19:05:49 +03:00
|
|
|
void bdrv_dirty_bitmap_set_persistence(BdrvDirtyBitmap *bitmap,
|
2017-06-28 15:05:17 +03:00
|
|
|
bool persistent);
|
2019-03-12 19:05:49 +03:00
|
|
|
void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap *bitmap);
|
2019-03-12 19:05:48 +03:00
|
|
|
void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap *bitmap, bool busy);
|
2018-06-11 21:53:32 +03:00
|
|
|
void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src,
|
2018-10-29 23:23:15 +03:00
|
|
|
HBitmap **backup, Error **errp);
|
dirty-bitmaps: clean-up bitmaps loading and migration logic
This patch aims to bring the following behavior:
1. We don't load bitmaps, when started in inactive mode. It's the case
of incoming migration. In this case we wait for bitmaps migration
through migration channel (if 'dirty-bitmaps' capability is enabled) or
for invalidation (to load bitmaps from the image).
2. We don't remove persistent bitmaps on inactivation. Instead, we only
remove bitmaps after storing. This is the only way to restore bitmaps,
if we decided to resume source after [failed] migration with
'dirty-bitmaps' capability enabled (which means, that bitmaps were not
stored).
3. We load bitmaps on open and any invalidation, it's ok for all cases:
- normal open
- migration target invalidation with dirty-bitmaps capability
(bitmaps are migrating through migration channel, the are not
stored, so they should have IN_USE flag set and will be skipped
when loading. However, it would fail if bitmaps are read-only[1])
- migration target invalidation without dirty-bitmaps capability
(normal load of the bitmaps, if migrated with shared storage)
- source invalidation with dirty-bitmaps capability
(skip because IN_USE)
- source invalidation without dirty-bitmaps capability
(bitmaps were dropped, reload them)
[1]: to accurately handle this, migration of read-only bitmaps is
explicitly forbidden in this patch.
New mechanism for not storing bitmaps when migrate with dirty-bitmaps
capability is introduced: migration filed in BdrvDirtyBitmap.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2018-10-29 23:23:17 +03:00
|
|
|
void bdrv_dirty_bitmap_set_migration(BdrvDirtyBitmap *bitmap, bool migration);
|
2017-06-28 15:05:10 +03:00
|
|
|
|
2017-06-05 15:39:05 +03:00
|
|
|
/* Functions that require manual locking. */
|
|
|
|
void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap);
|
|
|
|
void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap);
|
2017-09-25 17:55:19 +03:00
|
|
|
bool bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
|
|
|
|
int64_t offset);
|
2017-06-05 15:39:05 +03:00
|
|
|
void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:20 +03:00
|
|
|
int64_t offset, int64_t bytes);
|
2017-06-05 15:39:05 +03:00
|
|
|
void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
|
2017-09-25 17:55:20 +03:00
|
|
|
int64_t offset, int64_t bytes);
|
2017-06-05 15:39:05 +03:00
|
|
|
int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter);
|
2017-09-25 17:55:16 +03:00
|
|
|
void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t offset);
|
2017-06-05 15:39:05 +03:00
|
|
|
int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);
|
|
|
|
int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap);
|
2017-09-25 17:55:11 +03:00
|
|
|
void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes);
|
2017-06-28 15:05:10 +03:00
|
|
|
bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);
|
|
|
|
bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);
|
2017-06-28 15:05:15 +03:00
|
|
|
bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);
|
2019-03-12 19:05:49 +03:00
|
|
|
bool bdrv_dirty_bitmap_get_persistence(BdrvDirtyBitmap *bitmap);
|
2019-03-12 19:05:49 +03:00
|
|
|
bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap *bitmap);
|
2017-06-28 15:05:17 +03:00
|
|
|
bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
|
2017-06-28 15:05:18 +03:00
|
|
|
BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
|
|
|
|
BdrvDirtyBitmap *bitmap);
|
2017-06-28 15:05:25 +03:00
|
|
|
char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp);
|
2019-01-16 02:26:49 +03:00
|
|
|
int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t offset,
|
|
|
|
uint64_t bytes);
|
2019-01-16 02:26:50 +03:00
|
|
|
bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap,
|
|
|
|
uint64_t *offset, uint64_t *bytes);
|
2018-03-13 22:34:00 +03:00
|
|
|
BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BlockDriverState *bs,
|
|
|
|
BdrvDirtyBitmap *bitmap,
|
|
|
|
Error **errp);
|
2017-06-05 15:39:05 +03:00
|
|
|
|
2016-03-08 07:44:55 +03:00
|
|
|
#endif
|