Like other setters here these functions should take a lock.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/dirty-bitmap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index bd04e991b1..2a0bcd9e51 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -397,15 +397,19 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
/* Called with BQL taken. */
void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
{
+ bdrv_dirty_bitmap_lock(bitmap);
assert(!bdrv_dirty_bitmap_frozen(bitmap));
bitmap->disabled = true;
+ bdrv_dirty_bitmap_unlock(bitmap);
}
/* Called with BQL taken. */
void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
{
+ bdrv_dirty_bitmap_lock(bitmap);
assert(!bdrv_dirty_bitmap_frozen(bitmap));
bitmap->disabled = false;
+ bdrv_dirty_bitmap_unlock(bitmap);
}
BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
--
2.11.1
On 11/13/2017 10:20 AM, Vladimir Sementsov-Ogievskiy wrote:
> Like other setters here these functions should take a lock.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/dirty-bitmap.c | 4 ++++
> 1 file changed, 4 insertions(+)
Should this patch be in 2.11?
>
> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
> index bd04e991b1..2a0bcd9e51 100644
> --- a/block/dirty-bitmap.c
> +++ b/block/dirty-bitmap.c
> @@ -397,15 +397,19 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> /* Called with BQL taken. */
> void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
> {
> + bdrv_dirty_bitmap_lock(bitmap);
> assert(!bdrv_dirty_bitmap_frozen(bitmap));
> bitmap->disabled = true;
> + bdrv_dirty_bitmap_unlock(bitmap);
Why do we need this lock in addition to BQL?
> }
>
> /* Called with BQL taken. */
> void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
> {
> + bdrv_dirty_bitmap_lock(bitmap);
> assert(!bdrv_dirty_bitmap_frozen(bitmap));
> bitmap->disabled = false;
> + bdrv_dirty_bitmap_unlock(bitmap);
Again, why do we need this in addition to BQL?
The commit message needs more details about a scenario where our
existing BQL lock is insufficient to prevent misuse of bitmap->disabled.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
13.11.2017 20:50, Eric Blake wrote:
> On 11/13/2017 10:20 AM, Vladimir Sementsov-Ogievskiy wrote:
>> Like other setters here these functions should take a lock.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>> block/dirty-bitmap.c | 4 ++++
>> 1 file changed, 4 insertions(+)
> Should this patch be in 2.11?
>
>> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
>> index bd04e991b1..2a0bcd9e51 100644
>> --- a/block/dirty-bitmap.c
>> +++ b/block/dirty-bitmap.c
>> @@ -397,15 +397,19 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
>> /* Called with BQL taken. */
>> void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
>> {
>> + bdrv_dirty_bitmap_lock(bitmap);
>> assert(!bdrv_dirty_bitmap_frozen(bitmap));
>> bitmap->disabled = true;
>> + bdrv_dirty_bitmap_unlock(bitmap);
> Why do we need this lock in addition to BQL?
in fact, comment about BQL should be dropped.
block_int.h:
/* Writing to the list requires the BQL _and_ the dirty_bitmap_mutex.
* Reading from the list can be done with either the BQL or the
* dirty_bitmap_mutex. Modifying a bitmap only requires
* dirty_bitmap_mutex. */
QemuMutex dirty_bitmap_mutex;
>
>> }
>>
>> /* Called with BQL taken. */
>> void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
>> {
>> + bdrv_dirty_bitmap_lock(bitmap);
>> assert(!bdrv_dirty_bitmap_frozen(bitmap));
>> bitmap->disabled = false;
>> + bdrv_dirty_bitmap_unlock(bitmap);
> Again, why do we need this in addition to BQL?
and here.
>
> The commit message needs more details about a scenario where our
> existing BQL lock is insufficient to prevent misuse of bitmap->disabled.
>
--
Best regards,
Vladimir
13.11.2017 20:50, Eric Blake wrote:
> On 11/13/2017 10:20 AM, Vladimir Sementsov-Ogievskiy wrote:
>> Like other setters here these functions should take a lock.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>> block/dirty-bitmap.c | 4 ++++
>> 1 file changed, 4 insertions(+)
> Should this patch be in 2.11?
these functions are unused now, so, no, it's not necessary
>
>> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
>> index bd04e991b1..2a0bcd9e51 100644
>> --- a/block/dirty-bitmap.c
>> +++ b/block/dirty-bitmap.c
>> @@ -397,15 +397,19 @@ void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs,
>> /* Called with BQL taken. */
>> void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
>> {
>> + bdrv_dirty_bitmap_lock(bitmap);
>> assert(!bdrv_dirty_bitmap_frozen(bitmap));
>> bitmap->disabled = true;
>> + bdrv_dirty_bitmap_unlock(bitmap);
> Why do we need this lock in addition to BQL?
>
>> }
>>
>> /* Called with BQL taken. */
>> void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap)
>> {
>> + bdrv_dirty_bitmap_lock(bitmap);
>> assert(!bdrv_dirty_bitmap_frozen(bitmap));
>> bitmap->disabled = false;
>> + bdrv_dirty_bitmap_unlock(bitmap);
> Again, why do we need this in addition to BQL?
>
> The commit message needs more details about a scenario where our
> existing BQL lock is insufficient to prevent misuse of bitmap->disabled.
>
--
Best regards,
Vladimir
© 2016 - 2026 Red Hat, Inc.