Bug fixes from byte-based block status
cover Bug fixes from byte-based block status
Series 2-4 of my byte-based conversion missed soft freeze, so they are now 2.11 material. However, there are some bug fixes in those series that we should fix now in 2.10 (patch 1 from series two on dirty bitmaps, patch 2 extracted from "qcow2: Switch qcow2_measure() to byte-based iteration" from series three on block status).
I don't know if it is worth enhancing iotest 178 to probe the size of a 2T image. The test is simple, and fast when patched:
$ qemu-img create -f qcow2 -o cluster_size=2M huge 2T $ time ./qemu-img measure -O qcow2 -f qcow2 huge required size: 335806464 fully allocated size: 2199359062016
real 0m0.021s
user 0m0.017s
sys 0m0.004s
but the inf-loop when unpatched is annoying; meanwhile, 'huge' only occupies 6 megabytes on disk, so it's not that invasive.
Eric Blake (2):
dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
qcow2: Fix sector calculation in qcow2_measure()
block/dirty-bitmap.c | 2 +- block/qcow2.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.13.3
PATCH 1/2 dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
We've been documenting the value in bytes since its introduction in commit b9a9b3a4 (v1.3), where it was actually reported in bytes.
Commit e4654d2 (v2.0) then removed things from block/qapi.c, in preparation for a rewrite to a list of dirty sectors in the next commit 21b5683 in block.c, but the new code mistakenly started reporting in sectors.
---
Too late for 2.9, since the regression has been unnoticed for nine releases. But worth putting in 2.9.1 and 2.10.
v2-v4: no change
--- block/dirty-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/dirty-bitmap.c +1 -1
@@ -461,7 +461,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {BlockDirtyInfo *info =g_new0 (BlockDirtyInfo,1 );BlockDirtyInfoList *entry =g_new0 (BlockDirtyInfoList,1 ); - info->count =bdrv_get_dirty_count (bm); + info->count =bdrv_get_dirty_count (bm) <<BDRV_SECTOR_BITS ; info->granularity =bdrv_dirty_bitmap_granularity (bm); info->has_name = !!bm->name; info->name =g_strdup (bm->name);
Signature · 1 line
2.13.3
Re: [Qemu-devel] [PATCH 1/2] dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
Quoted 8 lines · Eric Blake
We've been documenting the value in bytes since its introduction in commit
b9a9b3a4(v1.3), where it was actually reported in bytes.Commit e4654d2 (v2.0) then removed things from
block/qapi.c, in preparation for a rewrite to a list of dirty sectors in the next commit 21b5683 inblock.c, but the new code mistakenly started reporting in sectors.
Quoted 6 lines
Signed-off-by Eric Blake <[email protected]>Reviewed-by John Snow <[email protected]>
I must have forgotten about this -- Didn't this get reviewed as part of your byte series? Is this a resend for a stable branch?
Quoted 23 lines
---
Too late for 2.9, since the regression has been unnoticed for nine releases. But worth putting in 2.9.1 and 2.10.v2-v4: no change
--- block/dirty-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/dirty-bitmap.c +1
-1@@ -461,7 +461,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {BlockDirtyInfo *info =g_new0 (BlockDirtyInfo,1 );BlockDirtyInfoList *entry =g_new0 (BlockDirtyInfoList,1 ); - info->count =bdrv_get_dirty_count (bm); + info->count =bdrv_get_dirty_count (bm) <<BDRV_SECTOR_BITS ; info->granularity =bdrv_dirty_bitmap_granularity (bm); info->has_name = !!bm->name; info->name =g_strdup (bm->name);
Signature · 1 line
—js
Re: [Qemu-devel] [PATCH 1/2] dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
Quoted 13 lines · John Snow
Quoted 10 lines · Eric Blake
We've been documenting the value in bytes since its introduction in commit
b9a9b3a4(v1.3), where it was actually reported in bytes.Commit e4654d2 (v2.0) then removed things from
block/qapi.c, in preparation for a rewrite to a list of dirty sectors in the next commit 21b5683 inblock.c, but the new code mistakenly started reporting in sectors.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Eric Blake <[email protected]>Reviewed-by John Snow <[email protected]>I must have forgotten about this -- Didn't this get reviewed as part of your byte series? Is this a resend for a stable branch?
Yes, it was reviewed during my part 2-of-4 series on byte-base block status (the dirty bitmap series). Series 1 made it into 2.10, but series 2-4 did not; ergo, I filtered out the true bug-fixes that were still worthy post-freeze.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 1/2] dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
Quoted 19 lines · Eric Blake
Quoted 18 lines · John Snow
Quoted 14 lines · Eric Blake
We've been documenting the value in bytes since its introduction in commit
b9a9b3a4(v1.3), where it was actually reported in bytes.Commit e4654d2 (v2.0) then removed things from
block/qapi.c, in preparation for a rewrite to a list of dirty sectors in the next commit 21b5683 inblock.c, but the new code mistakenly started reporting in sectors.Signed-off-by Eric Blake <[email protected]>Reviewed-by John Snow <[email protected]>
Quoted 8 lines
Quoted 2 lines
I must have forgotten about this -- Didn't this get reviewed as part of your byte series? Is this a resend for a stable branch?
Yes, it was reviewed during my part 2-of-4 series on byte-base block status (the dirty bitmap series). Series 1 made it into 2.10, but series 2-4 did not; ergo, I filtered out the true bug-fixes that were still worthy post-freeze.
Thanks for the clarification. Short term memory is a little strapped right now due to my move.
ACK
PATCH 2/2 qcow2: Fix sector calculation in qcow2_measure()
In reply to Eric BlakeWe used MAX() instead of the intended MIN() when computing how many sectors to view in the current loop iteration of qcow2_measure(), and passed in a value of INT_MAX sectors instead of our more usual limit of BDRV_REQUEST_MAX_SECTORS (the latter avoids 32-bit overflow on conversion to bytes). For small files, the bug is harmless:bdrv_get_block_status_above() clamps its *pnum answer to the BDS size, regardless of any insanely larger input request. However, for any file at least 2T in size, we can very easily end up going into an infinite loop (the maximum of 0x100000000 sectors and INT_MAX is a 64-bit quantity, which becomes 0 when assigned to int; once nb_sectors is 0, we never make progress).
--- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/qcow2.c +2 -2
@@ -3670,8 +3670,8 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,for (sector_num =0 ; sector_num < ssize /BDRV_SECTOR_SIZE ; sector_num += pnum) { -int nb_sectors =MAX (ssize /BDRV_SECTOR_SIZE - sector_num, -INT_MAX ); +int nb_sectors =MIN (ssize /BDRV_SECTOR_SIZE - sector_num, +BDRV_REQUEST_MAX_SECTORS );BlockDriverState *file;int64_t ret;
Signature · 1 line
2.13.3
Kevin Wolf
AppliedAm 21.07.2017 um 20:32 hat Eric Blake geschrieben:
Quoted 5 lines
Series 2-4 of my byte-based conversion missed soft freeze, so they are now 2.11 material. However, there are some bug fixes in those series that we should fix now in 2.10 (patch 1 from series two on dirty bitmaps, patch 2 extracted from "qcow2: Switch
qcow2_measure()to byte-based iteration" from series three on block status).
Thanks, applied to the block branch.
Quoted 8 lines
I don't know if it is worth enhancing iotest 178 to probe the size of a 2T image. The test is simple, and fast when patched:
$ qemu-img create -f qcow2 -o cluster_size=2M huge 2T $ time ./qemu-img measure -O qcow2 -f qcow2 huge required size: 335806464 fully allocated size: 2199359062016
Quoted 6 lines
real 0m0.021s
user 0m0.017s
sys 0m0.004sbut the inf-loop when unpatched is annoying; meanwhile, 'huge' only occupies 6 megabytes on disk, so it's not that invasive.
Yes, please follow up with qemu-iotests cases for both bugs. We're only adding the test after fixing the bug, so a hang in the buggy old code isn't a problem.
Kevin
Quoted 21 lines · Kevin Wolf
Am 21.07.2017 um 20:32 hat Eric Blake geschrieben:
Quoted 5 lines
Series 2-4 of my byte-based conversion missed soft freeze, so they are now 2.11 material. However, there are some bug fixes in those series that we should fix now in 2.10 (patch 1 from series two on dirty bitmaps, patch 2 extracted from "qcow2: Switch
qcow2_measure()to byte-based iteration" from series three on block status).Thanks, applied to the block branch.
Quoted 12 lines
I don't know if it is worth enhancing iotest 178 to probe the size of a 2T image. The test is simple, and fast when patched:
$ qemu-img create -f qcow2 -o cluster_size=2M huge 2T $ time ./qemu-img measure -O qcow2 -f qcow2 huge required size: 335806464 fully allocated size: 2199359062016real 0m0.021s
user 0m0.017s
sys 0m0.004s
Quoted 6 lines
Quoted 2 lines
but the inf-loop when unpatched is annoying; meanwhile, 'huge' only occupies 6 megabytes on disk, so it's not that invasive.
Yes, please follow up with qemu-iotests cases for both bugs. We're only adding the test after fixing the bug, so a hang in the buggy old code isn't a problem.
I've submitted as separate patches since you've already queued these; but since you haven't done a pull request yet, we could also merge them and submit the tests in the same patches as the fixes:
https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg07400.html
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 21 lines · Eric Blake
Series 2-4 of my byte-based conversion missed soft freeze, so they are now 2.11 material. However, there are some bug fixes in those series that we should fix now in 2.10 (patch 1 from series two on dirty bitmaps, patch 2 extracted from "qcow2: Switch
qcow2_measure()to byte-based iteration" from series three on block status).I don't know if it is worth enhancing iotest 178 to probe the size of a 2T image. The test is simple, and fast when patched:
$ qemu-img create -f qcow2 -o cluster_size=2M huge 2T $ time ./qemu-img measure -O qcow2 -f qcow2 huge required size: 335806464 fully allocated size: 2199359062016real 0m0.021s
user 0m0.017s
sys 0m0.004sbut the inf-loop when unpatched is annoying; meanwhile, 'huge' only occupies 6 megabytes on disk, so it's not that invasive.
Quoted 11 lines
Eric Blake (2):
dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
qcow2: Fix sector calculation inqcow2_measure()block/dirty-bitmap.c | 2 +- block/qcow2.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)Signature · 1 line
2.13.3
Quoted 18 lines · Eric Blake
Series 2-4 of my byte-based conversion missed soft freeze, so they are now 2.11 material. However, there are some bug fixes in those series that we should fix now in 2.10 (patch 1 from series two on dirty bitmaps, patch 2 extracted from "qcow2: Switch
qcow2_measure()to byte-based iteration" from series three on block status).I don't know if it is worth enhancing iotest 178 to probe the size of a 2T image. The test is simple, and fast when patched:
$ qemu-img create -f qcow2 -o cluster_size=2M huge 2T $ time ./qemu-img measure -O qcow2 -f qcow2 huge required size: 335806464 fully allocated size: 2199359062016real 0m0.021s
user 0m0.017s
sys 0m0.004s
Quoted 6 lines
but the inf-loop when unpatched is annoying; meanwhile, 'huge' only occupies 6 megabytes on disk, so it's not that invasive.
Eric Blake (2):
dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
qcow2: Fix sector calculation inqcow2_measure()
Thanks; queued on my NBD branch:git://repo.or.cz/qemu/ericb.git nbd
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 22 lines · Eric Blake
Quoted 21 lines · Eric Blake
Series 2-4 of my byte-based conversion missed soft freeze, so they are now 2.11 material. However, there are some bug fixes in those series that we should fix now in 2.10 (patch 1 from series two on dirty bitmaps, patch 2 extracted from "qcow2: Switch
qcow2_measure()to byte-based iteration" from series three on block status).I don't know if it is worth enhancing iotest 178 to probe the size of a 2T image. The test is simple, and fast when patched:
$ qemu-img create -f qcow2 -o cluster_size=2M huge 2T $ time ./qemu-img measure -O qcow2 -f qcow2 huge required size: 335806464 fully allocated size: 2199359062016real 0m0.021s
user 0m0.017s
sys 0m0.004sbut the inf-loop when unpatched is annoying; meanwhile, 'huge' only occupies 6 megabytes on disk, so it's not that invasive.
Quoted 6 lines
Quoted 3 lines
Eric Blake (2):
dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented
qcow2: Fix sector calculation inqcow2_measure()Thanks; queued on my NBD branch:
git://repo.or.cz/qemu/ericb.gitnbd
Sorry, replied to the wrong thread.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org