block: release persistent bitmaps on inactivate
We should release them here to reload on invalidate cache. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20170628120530.31251-31-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
5c36c1af27
commit
615b5dcf2d
4
block.c
4
block.c
@ -4082,6 +4082,10 @@ static int bdrv_inactivate_recurse(BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* At this point persistent bitmaps should be already stored by the format
|
||||||
|
* driver */
|
||||||
|
bdrv_release_persistent_dirty_bitmaps(bs);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,15 +356,20 @@ void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
|
|||||||
bdrv_dirty_bitmaps_unlock(bs);
|
bdrv_dirty_bitmaps_unlock(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool bdrv_dirty_bitmap_has_name(BdrvDirtyBitmap *bitmap)
|
||||||
|
{
|
||||||
|
return !!bdrv_dirty_bitmap_name(bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
/* Called with BQL taken. */
|
/* Called with BQL taken. */
|
||||||
static void bdrv_do_release_matching_dirty_bitmap(BlockDriverState *bs,
|
static void bdrv_do_release_matching_dirty_bitmap(
|
||||||
BdrvDirtyBitmap *bitmap,
|
BlockDriverState *bs, BdrvDirtyBitmap *bitmap,
|
||||||
bool only_named)
|
bool (*cond)(BdrvDirtyBitmap *bitmap))
|
||||||
{
|
{
|
||||||
BdrvDirtyBitmap *bm, *next;
|
BdrvDirtyBitmap *bm, *next;
|
||||||
bdrv_dirty_bitmaps_lock(bs);
|
bdrv_dirty_bitmaps_lock(bs);
|
||||||
QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) {
|
QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) {
|
||||||
if ((!bitmap || bm == bitmap) && (!only_named || bm->name)) {
|
if ((!bitmap || bm == bitmap) && (!cond || cond(bm))) {
|
||||||
assert(!bm->active_iterators);
|
assert(!bm->active_iterators);
|
||||||
assert(!bdrv_dirty_bitmap_frozen(bm));
|
assert(!bdrv_dirty_bitmap_frozen(bm));
|
||||||
assert(!bm->meta);
|
assert(!bm->meta);
|
||||||
@ -389,7 +394,7 @@ out:
|
|||||||
/* Called with BQL taken. */
|
/* Called with BQL taken. */
|
||||||
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
|
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
|
||||||
{
|
{
|
||||||
bdrv_do_release_matching_dirty_bitmap(bs, bitmap, false);
|
bdrv_do_release_matching_dirty_bitmap(bs, bitmap, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -400,7 +405,19 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
|
|||||||
*/
|
*/
|
||||||
void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs)
|
void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
bdrv_do_release_matching_dirty_bitmap(bs, NULL, true);
|
bdrv_do_release_matching_dirty_bitmap(bs, NULL, bdrv_dirty_bitmap_has_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release all persistent dirty bitmaps attached to a BDS (for use in
|
||||||
|
* bdrv_inactivate_recurse()).
|
||||||
|
* There must not be any frozen bitmaps attached.
|
||||||
|
* This function does not remove persistent bitmaps from the storage.
|
||||||
|
*/
|
||||||
|
void bdrv_release_persistent_dirty_bitmaps(BlockDriverState *bs)
|
||||||
|
{
|
||||||
|
bdrv_do_release_matching_dirty_bitmap(bs, NULL,
|
||||||
|
bdrv_dirty_bitmap_get_persistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +25,7 @@ BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs,
|
|||||||
void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap);
|
void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap);
|
||||||
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
|
void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap);
|
||||||
void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs);
|
void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs);
|
||||||
|
void bdrv_release_persistent_dirty_bitmaps(BlockDriverState *bs);
|
||||||
void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
|
void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
|
||||||
const char *name,
|
const char *name,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
Loading…
Reference in New Issue
Block a user