On 2017-06-28 14:05, Vladimir Sementsov-Ogievskiy wrote: > It will be needed in following commits for persistent bitmaps. > If bitmap is loaded from read-only storage (and we can't mark it > "in use" in this storage) corresponding BdrvDirtyBitmap should be > read-only. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> > --- > block/dirty-bitmap.c | 36 ++++++++++++++++++++++++++++++++++++ > block/io.c | 8 ++++++++ > blockdev.c | 6 ++++++ > include/block/dirty-bitmap.h | 4 ++++ > 4 files changed, 54 insertions(+) > > diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c > index a8fe149c4a..17d3068336 100644 > --- a/block/dirty-bitmap.c > +++ b/block/dirty-bitmap.c
[...]
> @@ -635,3 +646,28 @@ int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap
> *bitmap)
> {
> return hbitmap_count(bitmap->meta);
> }
> +
> +bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap)
> +{
> + return bitmap->readonly;
> +}
> +
> +/* Called with BQL taken. */
> +void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value)
> +{
> + qemu_mutex_lock(bitmap->mutex);
> + bitmap->readonly = value;
> + qemu_mutex_unlock(bitmap->mutex);
> +}
I find it a bit strange to acquire the mutex if this function is called
with the BQL taken (which I agree it should be) -- but Paolo has given
his OK and I don't think it does harm to acquire the mutex even under BQL.
Max
> +
> +bool bdrv_has_readonly_bitmaps(BlockDriverState *bs)
> +{
> + BdrvDirtyBitmap *bm;
> + QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
> + if (bm->readonly) {
> + return true;
> + }
> + }
> +
> + return false;
> +}
signature.asc
Description: OpenPGP digital signature
