Skip to contentSkip to conversation

block: record new size in bdrv_dirty_bitmap_truncate

PATCH In review John Snow 3 participants 5 messages Jun 8, 2015 – Jun 10, 2015

lore
Share & tools
lore

John Snow

author
#0 lore raw

PATCH 1/1 block: record new size in bdrv_dirty_bitmap_truncate

ce1ffea8 neglected to update the BdrvDirtyBitmap structure itself for internal consistency. It's currently not an issue, but for migration and persistence series this will cause headaches.

---
 block.c | 1 +
 1 file changed, 1 insertion(+)
block.c +1 -0
index 2b9ceae..2786e47 100644
@@ -3224,6 +3224,7 @@ static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
             continue;
         }
         hbitmap_truncate(bitmap->bitmap, size);
+        bitmap->size = size;
     }
 }
 
Signature · 1 line
2.1.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · John Snow

ce1ffea8 neglected to update the BdrvDirtyBitmap structure itself for internal consistency. It's currently not an issue, but for migration and persistence series this will cause headaches.

---
 block.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines
block.c +1 -0
index 2b9ceae..2786e47 100644
@@ -3224,6 +3224,7 @@ static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
             continue;
         }
         hbitmap_truncate(bitmap->bitmap, size);
+        bitmap->size = size;
     }
 }
 
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to John Snow

Am 08.06.2015 um 22:49 hat John Snow geschrieben:

Quoted 5 lines

ce1ffea8 neglected to update the BdrvDirtyBitmap structure itself for internal consistency. It's currently not an issue, but for migration and persistence series this will cause headaches.

I know nothing about dirty bitmaps, but this one looks obvious enough, I'll apply it.

block.c static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs) · line 3229

Quoted 11 lines
block.c +1 -0
index 2b9ceae..2786e47 100644
@@ -3224,6 +3224,7 @@ static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
             continue;
         }
         hbitmap_truncate(bitmap->bitmap, size);
+        bitmap->size = size;
     }
 }

However, I'm left wondering whether that 'continue' in the context of that hunk is right. More context:

    QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
        if (bdrv_dirty_bitmap_frozen(bitmap)) {
            continue;
        }
        hbitmap_truncate(bitmap->bitmap, size);
    }

If the image just shrunk, the frozen bitmap covers parts of the image that don't exist any more. When they are read out for the backup, that request would fail.

If the image was extended, the frozen bitmap covers only part of the image. There are a few bitmap functions that don't check the size and would just work beyond the end of the bitmap if called with a now valid sector number that is outside the image.

In practice, I don't think any of these happen because of op blockers that prevent resizing while a backup is in progress, but should !bdrv_dirty_bitmap_frozen(bitmap) be asserted then rather than just skipping the bitmap?

Kevin

author
#3 lore raw
Quoted 41 lines · Kevin Wolf

Am 08.06.2015 um 22:49 hat John Snow geschrieben:

Quoted 5 lines

ce1ffea8 neglected to update the BdrvDirtyBitmap structure itself for internal consistency. It's currently not an issue, but for migration and persistence series this will cause headaches.

I know nothing about dirty bitmaps, but this one looks obvious enough, I'll apply it.

block.c static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs) · line 3229

Quoted 11 lines
block.c +1 -0
index 2b9ceae..2786e47 100644
@@ -3224,6 +3224,7 @@ static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
             continue;
         }
         hbitmap_truncate(bitmap->bitmap, size);
+        bitmap->size = size;
     }
 }

However, I'm left wondering whether that 'continue' in the context of that hunk is right. More context:

    QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
        if (bdrv_dirty_bitmap_frozen(bitmap)) {
            continue;
        }
        hbitmap_truncate(bitmap->bitmap, size);
    }

If the image just shrunk, the frozen bitmap covers parts of the image that don't exist any more. When they are read out for the backup, that request would fail.

If the image was extended, the frozen bitmap covers only part of the image. There are a few bitmap functions that don't check the size and would just work beyond the end of the bitmap if called with a now valid sector number that is outside the image.

Quoted 7 lines

In practice, I don't think any of these happen because of op blockers that prevent resizing while a backup is in progress, but should !bdrv_dirty_bitmap_frozen(bitmap) be asserted then rather than just skipping the bitmap?

Kevin

Yeah, that won't hurt anything and will read cleaner. I'll just v2 this patch, thanks.

--js

#4 lore raw

Am 09.06.2015 um 17:46 hat John Snow geschrieben:

Quoted 49 lines · Kevin Wolf
Quoted 46 lines

Am 08.06.2015 um 22:49 hat John Snow geschrieben:

Quoted 5 lines

ce1ffea8 neglected to update the BdrvDirtyBitmap structure itself for internal consistency. It's currently not an issue, but for migration and persistence series this will cause headaches.

I know nothing about dirty bitmaps, but this one looks obvious enough, I'll apply it.

block.c static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs) · line 3229

Quoted 11 lines
block.c +1 -0
index 2b9ceae..2786e47 100644
@@ -3224,6 +3224,7 @@ static void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
             continue;
         }
         hbitmap_truncate(bitmap->bitmap, size);
+        bitmap->size = size;
     }
 }

However, I'm left wondering whether that 'continue' in the context of that hunk is right. More context:

    QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
        if (bdrv_dirty_bitmap_frozen(bitmap)) {
            continue;
        }
        hbitmap_truncate(bitmap->bitmap, size);
    }

If the image just shrunk, the frozen bitmap covers parts of the image that don't exist any more. When they are read out for the backup, that request would fail.

If the image was extended, the frozen bitmap covers only part of the image. There are a few bitmap functions that don't check the size and would just work beyond the end of the bitmap if called with a now valid sector number that is outside the image.

In practice, I don't think any of these happen because of op blockers that prevent resizing while a backup is in progress, but should !bdrv_dirty_bitmap_frozen(bitmap) be asserted then rather than just skipping the bitmap?

Quoted 5 lines
Quoted 2 lines

Kevin

Yeah, that won't hurt anything and will read cleaner. I'll just v2 this patch, thanks.

It's unrelated to this patch (except for touching the same function), so I'd suggest to make it a separate patch.

Kevin