1 | The following changes since commit ae49fbbcd8e4e9d8bf7131add34773f579e1aff7: | 1 | The following changes since commit ec11dc41eec5142b4776db1296972c6323ba5847: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20171025' into staging (2017-10-25 16:38:57 +0100) | 3 | Merge tag 'pull-misc-2022-05-11' of git://repo.or.cz/qemu/armbru into staging (2022-05-11 09:00:26 -0700) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://repo.or.cz/qemu/kevin.git tags/for-upstream | 7 | git://repo.or.cz/qemu/kevin.git tags/for-upstream |
8 | 8 | ||
9 | for you to fetch changes up to 4254d01ce4eec9a3ccf320d14e2da132b8ad4a51: | 9 | for you to fetch changes up to f70625299ecc9ba577c87f3d1d75012c747c7d88: |
10 | 10 | ||
11 | Merge remote-tracking branch 'mreitz/tags/pull-block-2017-10-26' into queue-block (2017-10-26 15:02:40 +0200) | 11 | qemu-iotests: inline common.config into common.rc (2022-05-12 15:42:49 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block layer patches | 14 | Block layer patches |
15 | 15 | ||
16 | - coroutine: Fix crashes due to too large pool batch size | ||
17 | - fdc: Prevent end-of-track overrun | ||
18 | - nbd: MULTI_CONN for shared writable exports | ||
19 | - iotests test runner improvements | ||
20 | |||
16 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
17 | Alberto Garcia (1): | 22 | Daniel P. Berrangé (2): |
18 | qcow2: Use BDRV_SECTOR_BITS instead of its literal value | 23 | tests/qemu-iotests: print intent to run a test in TAP mode |
24 | .gitlab-ci.d: export meson testlog.txt as an artifact | ||
19 | 25 | ||
20 | Eric Blake (24): | 26 | Eric Blake (2): |
21 | block: Allow NULL file for bdrv_get_block_status() | 27 | qemu-nbd: Pass max connections to blockdev layer |
22 | block: Add flag to avoid wasted work in bdrv_is_allocated() | 28 | nbd/server: Allow MULTI_CONN for shared writable exports |
23 | block: Make bdrv_round_to_clusters() signature more useful | 29 | |
24 | qcow2: Switch is_zero_sectors() to byte-based | 30 | Hanna Reitz (1): |
25 | block: Switch bdrv_make_zero() to byte-based | 31 | iotests/testrunner: Flush after run_test() |
26 | qemu-img: Switch get_block_status() to byte-based | ||
27 | block: Convert bdrv_get_block_status() to bytes | ||
28 | block: Switch bdrv_co_get_block_status() to byte-based | ||
29 | block: Switch BdrvCoGetBlockStatusData to byte-based | ||
30 | block: Switch bdrv_common_block_status_above() to byte-based | ||
31 | block: Switch bdrv_co_get_block_status_above() to byte-based | ||
32 | block: Convert bdrv_get_block_status_above() to bytes | ||
33 | qemu-img: Simplify logic in img_compare() | ||
34 | qemu-img: Speed up compare on pre-allocated larger file | ||
35 | qemu-img: Add find_nonzero() | ||
36 | qemu-img: Drop redundant error message in compare | ||
37 | qemu-img: Change check_empty_sectors() to byte-based | ||
38 | qemu-img: Change compare_sectors() to be byte-based | ||
39 | qemu-img: Change img_rebase() to be byte-based | ||
40 | qemu-img: Change img_compare() to be byte-based | ||
41 | block: Align block status requests | ||
42 | block: Reduce bdrv_aligned_preadv() rounding | ||
43 | qcow2: Reduce is_zero() rounding | ||
44 | qemu-io: Relax 'alloc' now that block-status doesn't assert | ||
45 | 32 | ||
46 | Kevin Wolf (2): | 33 | Kevin Wolf (2): |
47 | qemu-iotests: Test backing_fmt with backing node reference | 34 | coroutine: Rename qemu_coroutine_inc/dec_pool_size() |
48 | Merge remote-tracking branch 'mreitz/tags/pull-block-2017-10-26' into queue-block | 35 | coroutine: Revert to constant batch size |
49 | 36 | ||
50 | Max Reitz (8): | 37 | Paolo Bonzini (1): |
51 | qemu-img.1: Image invalidation on qemu-img commit | 38 | qemu-iotests: inline common.config into common.rc |
52 | iotests: Add test for dataplane mirroring | ||
53 | iotests: Pull _filter_actual_image_size from 67/87 | ||
54 | iotests: Filter actual image size in 184 and 191 | ||
55 | qcow2: Emit errp when truncating the image tail | ||
56 | qcow2: Fix unaligned preallocated truncation | ||
57 | qcow2: Always execute preallocate() in a coroutine | ||
58 | iotests: Add cluster_size=64k to 125 | ||
59 | 39 | ||
60 | Peter Krempa (1): | 40 | Philippe Mathieu-Daudé (2): |
61 | block: don't add 'driver' to options when referring to backing via node name | 41 | hw/block/fdc: Prevent end-of-track overrun (CVE-2021-3507) |
42 | tests/qtest/fdc-test: Add a regression test for CVE-2021-3507 | ||
62 | 43 | ||
63 | include/block/block.h | 29 ++- | 44 | qapi/block-export.json | 8 +- |
64 | include/block/block_int.h | 11 +- | 45 | docs/interop/nbd.txt | 1 + |
65 | block.c | 3 +- | 46 | docs/tools/qemu-nbd.rst | 3 +- |
66 | block/blkdebug.c | 13 +- | 47 | include/block/nbd.h | 5 +- |
67 | block/io.c | 334 ++++++++++++++++----------- | 48 | include/qemu/coroutine.h | 6 +- |
68 | block/mirror.c | 26 +-- | 49 | blockdev-nbd.c | 13 +- |
69 | block/qcow2-cluster.c | 2 +- | 50 | hw/block/fdc.c | 8 ++ |
70 | block/qcow2.c | 116 ++++++---- | 51 | hw/block/virtio-blk.c | 6 +- |
71 | qemu-img.c | 381 ++++++++++++++----------------- | 52 | nbd/server.c | 10 +- |
72 | qemu-io-cmds.c | 13 -- | 53 | qemu-nbd.c | 2 +- |
73 | block/trace-events | 2 +- | 54 | tests/qtest/fdc-test.c | 21 ++++ |
74 | qemu-img.texi | 9 +- | 55 | util/qemu-coroutine.c | 26 ++-- |
75 | tests/qemu-iotests/067 | 2 +- | 56 | tests/qemu-iotests/testrunner.py | 4 + |
76 | tests/qemu-iotests/074.out | 2 - | 57 | .gitlab-ci.d/buildtest-template.yml | 12 +- |
77 | tests/qemu-iotests/087 | 2 +- | 58 | MAINTAINERS | 1 + |
78 | tests/qemu-iotests/125 | 7 +- | 59 | tests/qemu-iotests/common.config | 41 ------- |
79 | tests/qemu-iotests/125.out | 480 +++++++++++++++++++++++++++++++++++---- | 60 | tests/qemu-iotests/common.rc | 31 +++-- |
80 | tests/qemu-iotests/127 | 97 ++++++++ | 61 | tests/qemu-iotests/tests/nbd-multiconn | 145 +++++++++++++++++++++++ |
81 | tests/qemu-iotests/127.out | 14 ++ | 62 | tests/qemu-iotests/tests/nbd-multiconn.out | 5 + |
82 | tests/qemu-iotests/177 | 12 +- | 63 | tests/qemu-iotests/tests/nbd-qemu-allocation.out | 2 +- |
83 | tests/qemu-iotests/177.out | 19 +- | 64 | 20 files changed, 261 insertions(+), 89 deletions(-) |
84 | tests/qemu-iotests/184 | 3 +- | 65 | delete mode 100644 tests/qemu-iotests/common.config |
85 | tests/qemu-iotests/184.out | 6 +- | 66 | create mode 100755 tests/qemu-iotests/tests/nbd-multiconn |
86 | tests/qemu-iotests/191 | 7 +- | 67 | create mode 100644 tests/qemu-iotests/tests/nbd-multiconn.out |
87 | tests/qemu-iotests/191.out | 48 ++-- | ||
88 | tests/qemu-iotests/common.filter | 6 + | ||
89 | tests/qemu-iotests/group | 1 + | ||
90 | 27 files changed, 1102 insertions(+), 543 deletions(-) | ||
91 | create mode 100755 tests/qemu-iotests/127 | ||
92 | create mode 100644 tests/qemu-iotests/127.out | ||
93 | 68 | ||
69 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Peter Krempa <pkrempa@redhat.com> | ||
2 | 1 | ||
3 | When referring to a backing file of an image via node name | ||
4 | bdrv_open_backing_file would add the 'driver' option to the option list | ||
5 | filling it with the backing format driver. This breaks construction of | ||
6 | the backing chain via -blockdev, as bdrv_open_inherit reports an error | ||
7 | if both 'reference' and 'options' are provided. | ||
8 | |||
9 | $ qemu-img create -f raw /tmp/backing.raw 64M | ||
10 | $ qemu-img create -f qcow2 -F raw -b /tmp/backing.raw /tmp/test.qcow2 | ||
11 | $ qemu-system-x86_64 \ | ||
12 | -blockdev driver=file,filename=/tmp/backing.raw,node-name=backing \ | ||
13 | -blockdev driver=qcow2,file.driver=file,file.filename=/tmp/test.qcow2,node-name=root,backing=backing | ||
14 | qemu-system-x86_64: -blockdev driver=qcow2,file.driver=file,file.filename=/tmp/test.qcow2,node-name=root,backing=backing: Could not open backing file: Cannot reference an existing block device with additional options or a new filename | ||
15 | |||
16 | Signed-off-by: Peter Krempa <pkrempa@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
18 | --- | ||
19 | block.c | 3 ++- | ||
20 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
21 | |||
22 | diff --git a/block.c b/block.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/block.c | ||
25 | +++ b/block.c | ||
26 | @@ -XXX,XX +XXX,XX @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, | ||
27 | goto free_exit; | ||
28 | } | ||
29 | |||
30 | - if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { | ||
31 | + if (!reference && | ||
32 | + bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { | ||
33 | qdict_put_str(options, "driver", bs->backing_format); | ||
34 | } | ||
35 | |||
36 | -- | ||
37 | 2.13.6 | ||
38 | |||
39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | This changes test case 191 to include a backing image that has | ||
2 | backing_fmt set in the image file, but is referenced by node name in the | ||
3 | qemu command line. | ||
4 | 1 | ||
5 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | --- | ||
8 | tests/qemu-iotests/191 | 3 ++- | ||
9 | tests/qemu-iotests/191.out | 2 +- | ||
10 | 2 files changed, 3 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 | ||
13 | index XXXXXXX..XXXXXXX 100755 | ||
14 | --- a/tests/qemu-iotests/191 | ||
15 | +++ b/tests/qemu-iotests/191 | ||
16 | @@ -XXX,XX +XXX,XX @@ echo === Preparing and starting VM === | ||
17 | echo | ||
18 | |||
19 | TEST_IMG="${TEST_IMG}.base" _make_test_img $size | ||
20 | -TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" | ||
21 | +IMGOPTS=$(_optstr_add "$IMGOPTS" "backing_fmt=$IMGFMT") \ | ||
22 | + TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" | ||
23 | _make_test_img -b "${TEST_IMG}.mid" | ||
24 | TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" | ||
25 | |||
26 | diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/tests/qemu-iotests/191.out | ||
29 | +++ b/tests/qemu-iotests/191.out | ||
30 | @@ -XXX,XX +XXX,XX @@ QA output created by 191 | ||
31 | === Preparing and starting VM === | ||
32 | |||
33 | Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864 | ||
34 | -Formatting 'TEST_DIR/t.IMGFMT.mid', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base | ||
35 | +Formatting 'TEST_DIR/t.IMGFMT.mid', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT | ||
36 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.mid | ||
37 | Formatting 'TEST_DIR/t.IMGFMT.ovl2', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.mid | ||
38 | wrote 65536/65536 bytes at offset 1048576 | ||
39 | -- | ||
40 | 2.13.6 | ||
41 | |||
42 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | It's true that these functions currently affect the batch size in which |
---|---|---|---|
2 | coroutines are reused (i.e. moved from the global release pool to the | ||
3 | allocation pool of a specific thread), but this is a bug and will be | ||
4 | fixed in a separate patch. | ||
2 | 5 | ||
3 | We are gradually converting to byte-based interfaces, as they are | 6 | In fact, the comment in the header file already just promises that it |
4 | easier to reason about than sector-based. Convert another internal | 7 | influences the pool size, so reflect this in the name of the functions. |
5 | function (no semantic change), and rename it to is_zero() in the | 8 | As a nice side effect, the shorter function name makes some line |
6 | process. | 9 | wrapping unnecessary. |
7 | 10 | ||
8 | Signed-off-by: Eric Blake <eblake@redhat.com> | 11 | Cc: qemu-stable@nongnu.org |
9 | Reviewed-by: Fam Zheng <famz@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | Reviewed-by: John Snow <jsnow@redhat.com> | 13 | Message-Id: <20220510151020.105528-2-kwolf@redhat.com> |
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
12 | --- | 15 | --- |
13 | block/qcow2.c | 33 +++++++++++++++++++-------------- | 16 | include/qemu/coroutine.h | 6 +++--- |
14 | 1 file changed, 19 insertions(+), 14 deletions(-) | 17 | hw/block/virtio-blk.c | 6 ++---- |
18 | util/qemu-coroutine.c | 4 ++-- | ||
19 | 3 files changed, 7 insertions(+), 9 deletions(-) | ||
15 | 20 | ||
16 | diff --git a/block/qcow2.c b/block/qcow2.c | 21 | diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h |
17 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/block/qcow2.c | 23 | --- a/include/qemu/coroutine.h |
19 | +++ b/block/qcow2.c | 24 | +++ b/include/qemu/coroutine.h |
20 | @@ -XXX,XX +XXX,XX @@ finish: | 25 | @@ -XXX,XX +XXX,XX @@ void coroutine_fn yield_until_fd_readable(int fd); |
26 | /** | ||
27 | * Increase coroutine pool size | ||
28 | */ | ||
29 | -void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size); | ||
30 | +void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size); | ||
31 | |||
32 | /** | ||
33 | - * Devcrease coroutine pool size | ||
34 | + * Decrease coroutine pool size | ||
35 | */ | ||
36 | -void qemu_coroutine_decrease_pool_batch_size(unsigned int additional_pool_size); | ||
37 | +void qemu_coroutine_dec_pool_size(unsigned int additional_pool_size); | ||
38 | |||
39 | #include "qemu/lockable.h" | ||
40 | |||
41 | diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/block/virtio-blk.c | ||
44 | +++ b/hw/block/virtio-blk.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) | ||
46 | for (i = 0; i < conf->num_queues; i++) { | ||
47 | virtio_add_queue(vdev, conf->queue_size, virtio_blk_handle_output); | ||
48 | } | ||
49 | - qemu_coroutine_increase_pool_batch_size(conf->num_queues * conf->queue_size | ||
50 | - / 2); | ||
51 | + qemu_coroutine_inc_pool_size(conf->num_queues * conf->queue_size / 2); | ||
52 | virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err); | ||
53 | if (err != NULL) { | ||
54 | error_propagate(errp, err); | ||
55 | @@ -XXX,XX +XXX,XX @@ static void virtio_blk_device_unrealize(DeviceState *dev) | ||
56 | for (i = 0; i < conf->num_queues; i++) { | ||
57 | virtio_del_queue(vdev, i); | ||
58 | } | ||
59 | - qemu_coroutine_decrease_pool_batch_size(conf->num_queues * conf->queue_size | ||
60 | - / 2); | ||
61 | + qemu_coroutine_dec_pool_size(conf->num_queues * conf->queue_size / 2); | ||
62 | qemu_del_vm_change_state_handler(s->change); | ||
63 | blockdev_mark_auto_del(s->blk); | ||
64 | virtio_cleanup(vdev); | ||
65 | diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/util/qemu-coroutine.c | ||
68 | +++ b/util/qemu-coroutine.c | ||
69 | @@ -XXX,XX +XXX,XX @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co) | ||
70 | return co->ctx; | ||
21 | } | 71 | } |
22 | 72 | ||
23 | 73 | -void qemu_coroutine_increase_pool_batch_size(unsigned int additional_pool_size) | |
24 | -static bool is_zero_sectors(BlockDriverState *bs, int64_t start, | 74 | +void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size) |
25 | - uint32_t count) | ||
26 | +static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) | ||
27 | { | 75 | { |
28 | int nr; | 76 | qatomic_add(&pool_batch_size, additional_pool_size); |
29 | int64_t res; | ||
30 | + int64_t start; | ||
31 | |||
32 | - if (start + count > bs->total_sectors) { | ||
33 | - count = bs->total_sectors - start; | ||
34 | + /* TODO: Widening to sector boundaries should only be needed as | ||
35 | + * long as we can't query finer granularity. */ | ||
36 | + start = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); | ||
37 | + bytes = QEMU_ALIGN_UP(offset + bytes, BDRV_SECTOR_SIZE) - start; | ||
38 | + | ||
39 | + /* Clamp to image length, before checking status of underlying sectors */ | ||
40 | + if (start + bytes > bs->total_sectors * BDRV_SECTOR_SIZE) { | ||
41 | + bytes = bs->total_sectors * BDRV_SECTOR_SIZE - start; | ||
42 | } | ||
43 | |||
44 | - if (!count) { | ||
45 | + if (!bytes) { | ||
46 | return true; | ||
47 | } | ||
48 | - res = bdrv_get_block_status_above(bs, NULL, start, count, &nr, NULL); | ||
49 | - return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count; | ||
50 | + res = bdrv_get_block_status_above(bs, NULL, start >> BDRV_SECTOR_BITS, | ||
51 | + bytes >> BDRV_SECTOR_BITS, &nr, NULL); | ||
52 | + return res >= 0 && (res & BDRV_BLOCK_ZERO) && | ||
53 | + nr * BDRV_SECTOR_SIZE == bytes; | ||
54 | } | 77 | } |
55 | 78 | ||
56 | static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, | 79 | -void qemu_coroutine_decrease_pool_batch_size(unsigned int removing_pool_size) |
57 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, | 80 | +void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size) |
58 | } | 81 | { |
59 | 82 | qatomic_sub(&pool_batch_size, removing_pool_size); | |
60 | if (head || tail) { | 83 | } |
61 | - int64_t cl_start = (offset - head) >> BDRV_SECTOR_BITS; | ||
62 | uint64_t off; | ||
63 | unsigned int nr; | ||
64 | |||
65 | assert(head + bytes <= s->cluster_size); | ||
66 | |||
67 | /* check whether remainder of cluster already reads as zero */ | ||
68 | - if (!(is_zero_sectors(bs, cl_start, | ||
69 | - DIV_ROUND_UP(head, BDRV_SECTOR_SIZE)) && | ||
70 | - is_zero_sectors(bs, (offset + bytes) >> BDRV_SECTOR_BITS, | ||
71 | - DIV_ROUND_UP(-tail & (s->cluster_size - 1), | ||
72 | - BDRV_SECTOR_SIZE)))) { | ||
73 | + if (!(is_zero(bs, offset - head, head) && | ||
74 | + is_zero(bs, offset + bytes, | ||
75 | + tail ? s->cluster_size - tail : 0))) { | ||
76 | return -ENOTSUP; | ||
77 | } | ||
78 | |||
79 | qemu_co_mutex_lock(&s->lock); | ||
80 | /* We can have new write after previous check */ | ||
81 | - offset = cl_start << BDRV_SECTOR_BITS; | ||
82 | + offset = QEMU_ALIGN_DOWN(offset, s->cluster_size); | ||
83 | bytes = s->cluster_size; | ||
84 | nr = s->cluster_size; | ||
85 | ret = qcow2_get_cluster_offset(bs, offset, &nr, &off); | ||
86 | -- | 84 | -- |
87 | 2.13.6 | 85 | 2.35.3 |
88 | |||
89 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | Commit 4c41c69e changed the way the coroutine pool is sized because for |
---|---|---|---|
2 | virtio-blk devices with a large queue size and heavy I/O, it was just | ||
3 | too small and caused coroutines to be deleted and reallocated soon | ||
4 | afterwards. The change made the size dynamic based on the number of | ||
5 | queues and the queue size of virtio-blk devices. | ||
2 | 6 | ||
3 | Not all callers care about which BDS owns the mapping for a given | 7 | There are two important numbers here: Slightly simplified, when a |
4 | range of the file, or where the zeroes lie within that mapping. In | 8 | coroutine terminates, it is generally stored in the global release pool |
5 | particular, bdrv_is_allocated() cares more about finding the | 9 | up to a certain pool size, and if the pool is full, it is freed. |
6 | largest run of allocated data from the guest perspective, whether | 10 | Conversely, when allocating a new coroutine, the coroutines in the |
7 | or not that data is consecutive from the host perspective, and | 11 | release pool are reused if the pool already has reached a certain |
8 | whether or not the data reads as zero. Therefore, doing subsequent | 12 | minimum size (the batch size), otherwise we allocate new coroutines. |
9 | refinements such as checking how much of the format-layer | ||
10 | allocation also satisfies BDRV_BLOCK_ZERO at the protocol layer is | ||
11 | wasted work - in the best case, it just costs extra CPU cycles | ||
12 | during a single bdrv_is_allocated(), but in the worst case, it | ||
13 | results in a smaller *pnum, and forces callers to iterate through | ||
14 | more status probes when visiting the entire file for even more | ||
15 | extra CPU cycles. | ||
16 | 13 | ||
17 | This patch only optimizes the block layer (no behavior change when | 14 | The problem after commit 4c41c69e is that it not only increases the |
18 | want_zero is true, but skip unnecessary effort when it is false). | 15 | maximum pool size (which is the intended effect), but also the batch |
19 | Then when subsequent patches tweak the driver callback to be | 16 | size for reusing coroutines (which is a bug). It means that in cases |
20 | byte-based, we can also pass this hint through to the driver. | 17 | with many devices and/or a large queue size (which defaults to the |
18 | number of vcpus for virtio-blk-pci), many thousand coroutines could be | ||
19 | sitting in the release pool without being reused. | ||
21 | 20 | ||
22 | Tweak BdrvCoGetBlockStatusData to declare arguments in parameter | 21 | This is not only a waste of memory and allocations, but it actually |
23 | order, rather than mixing things up (minimizing padding is not | 22 | makes the QEMU process likely to hit the vm.max_map_count limit on Linux |
24 | necessary here). | 23 | because each coroutine requires two mappings (its stack and the guard |
24 | page for the stack), causing it to abort() in qemu_alloc_stack() because | ||
25 | when the limit is hit, mprotect() starts to fail with ENOMEM. | ||
25 | 26 | ||
26 | Signed-off-by: Eric Blake <eblake@redhat.com> | 27 | In order to fix the problem, change the batch size back to 64 to avoid |
28 | uselessly accumulating coroutines in the release pool, but keep the | ||
29 | dynamic maximum pool size so that coroutines aren't freed too early | ||
30 | in heavy I/O scenarios. | ||
31 | |||
32 | Note that this fix doesn't strictly make it impossible to hit the limit, | ||
33 | but this would only happen if most of the coroutines are actually in use | ||
34 | at the same time, not just sitting in a pool. This is the same behaviour | ||
35 | as we already had before commit 4c41c69e. Fully preventing this would | ||
36 | require allowing qemu_coroutine_create() to return an error, but it | ||
37 | doesn't seem to be a scenario that people hit in practice. | ||
38 | |||
39 | Cc: qemu-stable@nongnu.org | ||
40 | Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2079938 | ||
41 | Fixes: 4c41c69e05fe28c0f95f8abd2ebf407e95a4f04b | ||
42 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
43 | Message-Id: <20220510151020.105528-3-kwolf@redhat.com> | ||
44 | Tested-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp> | ||
27 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 45 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
28 | --- | 46 | --- |
29 | block/io.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- | 47 | util/qemu-coroutine.c | 22 ++++++++++++++-------- |
30 | 1 file changed, 41 insertions(+), 16 deletions(-) | 48 | 1 file changed, 14 insertions(+), 8 deletions(-) |
31 | 49 | ||
32 | diff --git a/block/io.c b/block/io.c | 50 | diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c |
33 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/block/io.c | 52 | --- a/util/qemu-coroutine.c |
35 | +++ b/block/io.c | 53 | +++ b/util/qemu-coroutine.c |
36 | @@ -XXX,XX +XXX,XX @@ int bdrv_flush_all(void) | 54 | @@ -XXX,XX +XXX,XX @@ |
37 | typedef struct BdrvCoGetBlockStatusData { | 55 | #include "qemu/coroutine-tls.h" |
38 | BlockDriverState *bs; | 56 | #include "block/aio.h" |
39 | BlockDriverState *base; | 57 | |
40 | - BlockDriverState **file; | 58 | -/** Initial batch size is 64, and is increased on demand */ |
41 | + bool want_zero; | 59 | +/** |
42 | int64_t sector_num; | 60 | + * The minimal batch size is always 64, coroutines from the release_pool are |
43 | int nb_sectors; | 61 | + * reused as soon as there are 64 coroutines in it. The maximum pool size starts |
44 | int *pnum; | 62 | + * with 64 and is increased on demand so that coroutines are not deleted even if |
45 | + BlockDriverState **file; | 63 | + * they are not immediately reused. |
46 | int64_t ret; | 64 | + */ |
47 | bool done; | 65 | enum { |
48 | } BdrvCoGetBlockStatusData; | 66 | - POOL_INITIAL_BATCH_SIZE = 64, |
49 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs, | 67 | + POOL_MIN_BATCH_SIZE = 64, |
50 | * Drivers not implementing the functionality are assumed to not support | 68 | + POOL_INITIAL_MAX_SIZE = 64, |
51 | * backing files, hence all their sectors are reported as allocated. | 69 | }; |
52 | * | 70 | |
53 | + * If 'want_zero' is true, the caller is querying for mapping purposes, | 71 | /** Free list to speed up creation */ |
54 | + * and the result should include BDRV_BLOCK_OFFSET_VALID and | 72 | static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool); |
55 | + * BDRV_BLOCK_ZERO where possible; otherwise, the result may omit those | 73 | -static unsigned int pool_batch_size = POOL_INITIAL_BATCH_SIZE; |
56 | + * bits particularly if it allows for a larger value in 'pnum'. | 74 | +static unsigned int pool_max_size = POOL_INITIAL_MAX_SIZE; |
57 | + * | 75 | static unsigned int release_pool_size; |
58 | * If 'sector_num' is beyond the end of the disk image the return value is | 76 | |
59 | * BDRV_BLOCK_EOF and 'pnum' is set to 0. | 77 | typedef QSLIST_HEAD(, Coroutine) CoroutineQSList; |
60 | * | 78 | @@ -XXX,XX +XXX,XX @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque) |
61 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs, | 79 | |
62 | * is allocated in. | 80 | co = QSLIST_FIRST(alloc_pool); |
63 | */ | 81 | if (!co) { |
64 | static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | 82 | - if (release_pool_size > qatomic_read(&pool_batch_size)) { |
65 | + bool want_zero, | 83 | + if (release_pool_size > POOL_MIN_BATCH_SIZE) { |
66 | int64_t sector_num, | 84 | /* Slow path; a good place to register the destructor, too. */ |
67 | int nb_sectors, int *pnum, | 85 | Notifier *notifier = get_ptr_coroutine_pool_cleanup_notifier(); |
68 | BlockDriverState **file) | 86 | if (!notifier->notify) { |
69 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | 87 | @@ -XXX,XX +XXX,XX @@ static void coroutine_delete(Coroutine *co) |
70 | 88 | co->caller = NULL; | |
71 | if (ret & BDRV_BLOCK_RAW) { | 89 | |
72 | assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file); | 90 | if (CONFIG_COROUTINE_POOL) { |
73 | - ret = bdrv_co_get_block_status(local_file, ret >> BDRV_SECTOR_BITS, | 91 | - if (release_pool_size < qatomic_read(&pool_batch_size) * 2) { |
74 | + ret = bdrv_co_get_block_status(local_file, want_zero, | 92 | + if (release_pool_size < qatomic_read(&pool_max_size) * 2) { |
75 | + ret >> BDRV_SECTOR_BITS, | 93 | QSLIST_INSERT_HEAD_ATOMIC(&release_pool, co, pool_next); |
76 | *pnum, pnum, &local_file); | 94 | qatomic_inc(&release_pool_size); |
77 | goto out; | 95 | return; |
78 | } | ||
79 | |||
80 | if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { | ||
81 | ret |= BDRV_BLOCK_ALLOCATED; | ||
82 | - } else { | ||
83 | + } else if (want_zero) { | ||
84 | if (bdrv_unallocated_blocks_are_zero(bs)) { | ||
85 | ret |= BDRV_BLOCK_ZERO; | ||
86 | } else if (bs->backing) { | ||
87 | BlockDriverState *bs2 = bs->backing->bs; | ||
88 | int64_t nb_sectors2 = bdrv_nb_sectors(bs2); | ||
89 | + | ||
90 | if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) { | ||
91 | ret |= BDRV_BLOCK_ZERO; | ||
92 | } | ||
93 | } | 96 | } |
94 | } | 97 | - if (get_alloc_pool_size() < qatomic_read(&pool_batch_size)) { |
95 | 98 | + if (get_alloc_pool_size() < qatomic_read(&pool_max_size)) { | |
96 | - if (local_file && local_file != bs && | 99 | QSLIST_INSERT_HEAD(get_ptr_alloc_pool(), co, pool_next); |
97 | + if (want_zero && local_file && local_file != bs && | 100 | set_alloc_pool_size(get_alloc_pool_size() + 1); |
98 | (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && | 101 | return; |
99 | (ret & BDRV_BLOCK_OFFSET_VALID)) { | 102 | @@ -XXX,XX +XXX,XX @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co) |
100 | int file_pnum; | 103 | |
101 | 104 | void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size) | |
102 | - ret2 = bdrv_co_get_block_status(local_file, ret >> BDRV_SECTOR_BITS, | ||
103 | + ret2 = bdrv_co_get_block_status(local_file, want_zero, | ||
104 | + ret >> BDRV_SECTOR_BITS, | ||
105 | *pnum, &file_pnum, NULL); | ||
106 | if (ret2 >= 0) { | ||
107 | /* Ignore errors. This is just providing extra information, it | ||
108 | @@ -XXX,XX +XXX,XX @@ early_out: | ||
109 | |||
110 | static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | ||
111 | BlockDriverState *base, | ||
112 | + bool want_zero, | ||
113 | int64_t sector_num, | ||
114 | int nb_sectors, | ||
115 | int *pnum, | ||
116 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | ||
117 | |||
118 | assert(bs != base); | ||
119 | for (p = bs; p != base; p = backing_bs(p)) { | ||
120 | - ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum, file); | ||
121 | + ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors, | ||
122 | + pnum, file); | ||
123 | if (ret < 0) { | ||
124 | break; | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) | ||
127 | BdrvCoGetBlockStatusData *data = opaque; | ||
128 | |||
129 | data->ret = bdrv_co_get_block_status_above(data->bs, data->base, | ||
130 | + data->want_zero, | ||
131 | data->sector_num, | ||
132 | data->nb_sectors, | ||
133 | data->pnum, | ||
134 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) | ||
135 | * | ||
136 | * See bdrv_co_get_block_status_above() for details. | ||
137 | */ | ||
138 | -int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
139 | - BlockDriverState *base, | ||
140 | - int64_t sector_num, | ||
141 | - int nb_sectors, int *pnum, | ||
142 | - BlockDriverState **file) | ||
143 | +static int64_t bdrv_common_block_status_above(BlockDriverState *bs, | ||
144 | + BlockDriverState *base, | ||
145 | + bool want_zero, | ||
146 | + int64_t sector_num, | ||
147 | + int nb_sectors, int *pnum, | ||
148 | + BlockDriverState **file) | ||
149 | { | 105 | { |
150 | Coroutine *co; | 106 | - qatomic_add(&pool_batch_size, additional_pool_size); |
151 | BdrvCoGetBlockStatusData data = { | 107 | + qatomic_add(&pool_max_size, additional_pool_size); |
152 | .bs = bs, | ||
153 | .base = base, | ||
154 | - .file = file, | ||
155 | + .want_zero = want_zero, | ||
156 | .sector_num = sector_num, | ||
157 | .nb_sectors = nb_sectors, | ||
158 | .pnum = pnum, | ||
159 | + .file = file, | ||
160 | .done = false, | ||
161 | }; | ||
162 | |||
163 | @@ -XXX,XX +XXX,XX @@ int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
164 | return data.ret; | ||
165 | } | 108 | } |
166 | 109 | ||
167 | +int64_t bdrv_get_block_status_above(BlockDriverState *bs, | 110 | void qemu_coroutine_dec_pool_size(unsigned int removing_pool_size) |
168 | + BlockDriverState *base, | ||
169 | + int64_t sector_num, | ||
170 | + int nb_sectors, int *pnum, | ||
171 | + BlockDriverState **file) | ||
172 | +{ | ||
173 | + return bdrv_common_block_status_above(bs, base, true, sector_num, | ||
174 | + nb_sectors, pnum, file); | ||
175 | +} | ||
176 | + | ||
177 | int64_t bdrv_get_block_status(BlockDriverState *bs, | ||
178 | int64_t sector_num, | ||
179 | int nb_sectors, int *pnum, | ||
180 | @@ -XXX,XX +XXX,XX @@ int64_t bdrv_get_block_status(BlockDriverState *bs, | ||
181 | int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | ||
182 | int64_t bytes, int64_t *pnum) | ||
183 | { | 111 | { |
184 | - int64_t sector_num = offset >> BDRV_SECTOR_BITS; | 112 | - qatomic_sub(&pool_batch_size, removing_pool_size); |
185 | - int nb_sectors = bytes >> BDRV_SECTOR_BITS; | 113 | + qatomic_sub(&pool_max_size, removing_pool_size); |
186 | int64_t ret; | 114 | } |
187 | int psectors; | ||
188 | |||
189 | assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); | ||
190 | assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE) && bytes < INT_MAX); | ||
191 | - ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &psectors, | ||
192 | - NULL); | ||
193 | + ret = bdrv_common_block_status_above(bs, backing_bs(bs), false, | ||
194 | + offset >> BDRV_SECTOR_BITS, | ||
195 | + bytes >> BDRV_SECTOR_BITS, &psectors, | ||
196 | + NULL); | ||
197 | if (ret < 0) { | ||
198 | return ret; | ||
199 | } | ||
200 | -- | 115 | -- |
201 | 2.13.6 | 116 | 2.35.3 |
202 | |||
203 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Hanna Reitz <hreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | A qcow2 image file's length is not required to have a length that is a | 3 | When stdout is not a terminal, the buffer may not be flushed at each end |
4 | multiple of the cluster size. However, qcow2_refcount_area() expects an | 4 | of line, so we should flush after each test is done. This is especially |
5 | aligned value for its @start_offset parameter, so we need to round | 5 | apparent when run by check-block, in two ways: |
6 | @old_file_size up to the next cluster boundary. | ||
7 | 6 | ||
8 | Reported-by: Ping Li <pingl@redhat.com> | 7 | First, when running make check-block -jX with X > 1, progress indication |
9 | Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1414049 | 8 | was missing, even though testrunner.py does theoretically print each |
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | test's status once it has been run, even in multi-processing mode. |
11 | Message-id: 20171009215533.12530-2-mreitz@redhat.com | 10 | Flushing after each test restores this progress indication. |
12 | Cc: qemu-stable@nongnu.org | 11 | |
12 | Second, sometimes make check-block failed altogether, with an error | ||
13 | message that "too few tests [were] run". I presume that's because one | ||
14 | worker process in the job pool did not get to flush its stdout before | ||
15 | the main process exited, and so meson did not get to see that worker's | ||
16 | test results. In any case, by flushing at the end of run_test(), the | ||
17 | problem has disappeared for me. | ||
18 | |||
19 | Signed-off-by: Hanna Reitz <hreitz@redhat.com> | ||
20 | Message-Id: <20220506134215.10086-1-hreitz@redhat.com> | ||
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | 21 | Reviewed-by: Eric Blake <eblake@redhat.com> |
14 | Reviewed-by: Jeff Cody <jcody@redhat.com> | 22 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
15 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | 23 | --- |
18 | block/qcow2.c | 1 + | 24 | tests/qemu-iotests/testrunner.py | 1 + |
19 | 1 file changed, 1 insertion(+) | 25 | 1 file changed, 1 insertion(+) |
20 | 26 | ||
21 | diff --git a/block/qcow2.c b/block/qcow2.c | 27 | diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py |
22 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/block/qcow2.c | 29 | --- a/tests/qemu-iotests/testrunner.py |
24 | +++ b/block/qcow2.c | 30 | +++ b/tests/qemu-iotests/testrunner.py |
25 | @@ -XXX,XX +XXX,XX @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset, | 31 | @@ -XXX,XX +XXX,XX @@ def run_test(self, test: str, |
26 | "Failed to inquire current file length"); | 32 | else: |
27 | return old_file_size; | 33 | print(res.casenotrun) |
28 | } | 34 | |
29 | + old_file_size = ROUND_UP(old_file_size, s->cluster_size); | 35 | + sys.stdout.flush() |
30 | 36 | return res | |
31 | nb_new_data_clusters = DIV_ROUND_UP(offset - old_length, | 37 | |
32 | s->cluster_size); | 38 | def run_tests(self, tests: List[str], jobs: int = 1) -> bool: |
33 | -- | 39 | -- |
34 | 2.13.6 | 40 | 2.35.3 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Daniel P. Berrangé <berrange@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | qemu-img commit invalidates all images between base and top. This | 3 | When running I/O tests using TAP output mode, we get a single TAP test |
4 | should be mentioned in the man page. | 4 | with a sub-test reported for each I/O test that is run. The output looks |
5 | something like this: | ||
5 | 6 | ||
6 | Suggested-by: Ping Li <pingl@redhat.com> | 7 | 1..123 |
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | ok qcow2 011 |
8 | Reviewed-by: Jeff Cody <jcody@redhat.com> | 9 | ok qcow2 012 |
10 | ok qcow2 013 | ||
11 | ok qcow2 217 | ||
12 | ... | ||
13 | |||
14 | If everything runs or fails normally this is fine, but periodically we | ||
15 | have been seeing the test harness abort early before all 123 tests have | ||
16 | been run, just leaving a fairly useless message like | ||
17 | |||
18 | TAP parsing error: Too few tests run (expected 123, got 107) | ||
19 | |||
20 | we have no idea which tests were running at the time the test harness | ||
21 | abruptly exited. This change causes us to print a message about our | ||
22 | intent to run each test, so we have a record of what is active at the | ||
23 | time the harness exits abnormally. | ||
24 | |||
25 | 1..123 | ||
26 | # running qcow2 011 | ||
27 | ok qcow2 011 | ||
28 | # running qcow2 012 | ||
29 | ok qcow2 012 | ||
30 | # running qcow2 013 | ||
31 | ok qcow2 013 | ||
32 | # running qcow2 217 | ||
33 | ok qcow2 217 | ||
34 | ... | ||
35 | |||
36 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | ||
37 | Message-Id: <20220509124134.867431-2-berrange@redhat.com> | ||
38 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 39 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | --- | 40 | --- |
11 | qemu-img.texi | 9 ++++----- | 41 | tests/qemu-iotests/testrunner.py | 3 +++ |
12 | 1 file changed, 4 insertions(+), 5 deletions(-) | 42 | 1 file changed, 3 insertions(+) |
13 | 43 | ||
14 | diff --git a/qemu-img.texi b/qemu-img.texi | 44 | diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py |
15 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/qemu-img.texi | 46 | --- a/tests/qemu-iotests/testrunner.py |
17 | +++ b/qemu-img.texi | 47 | +++ b/tests/qemu-iotests/testrunner.py |
18 | @@ -XXX,XX +XXX,XX @@ If the backing chain of the given image file @var{filename} has more than one | 48 | @@ -XXX,XX +XXX,XX @@ def run_test(self, test: str, |
19 | layer, the backing file into which the changes will be committed may be | 49 | starttime=start, |
20 | specified as @var{base} (which has to be part of @var{filename}'s backing | 50 | lasttime=last_el, |
21 | chain). If @var{base} is not specified, the immediate backing file of the top | 51 | end = '\n' if mp else '\r') |
22 | -image (which is @var{filename}) will be used. For reasons of consistency, | 52 | + else: |
23 | -explicitly specifying @var{base} will always imply @code{-d} (since emptying an | 53 | + testname = os.path.basename(test) |
24 | -image after committing to an indirect backing file would lead to different data | 54 | + print(f'# running {self.env.imgfmt} {testname}') |
25 | -being read from the image due to content in the intermediate backing chain | 55 | |
26 | -overruling the commit target). | 56 | res = self.do_run_test(test, mp) |
27 | +image (which is @var{filename}) will be used. Note that after a commit operation | ||
28 | +all images between @var{base} and the top image will be invalid and may return | ||
29 | +garbage data when read. For this reason, @code{-b} implies @code{-d} (so that | ||
30 | +the top image stays valid). | ||
31 | |||
32 | @item compare [-f @var{fmt}] [-F @var{fmt}] [-T @var{src_cache}] [-p] [-s] [-q] @var{filename1} @var{filename2} | ||
33 | 57 | ||
34 | -- | 58 | -- |
35 | 2.13.6 | 59 | 2.35.3 |
36 | 60 | ||
37 | 61 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Daniel P. Berrangé <berrange@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Previously, the alloc command required that input parameters be | 3 | When running 'make check' we only get a summary of progress on the |
4 | sector-aligned and clamped to 32 bits, because the underlying | 4 | console. Fortunately meson/ninja have saved the raw test output to a |
5 | bdrv_is_allocated used a 32-bit parameter and asserted aligned | 5 | logfile. Exposing this log will make it easier to debug failures that |
6 | inputs. But now that we have fixed block status to report a | 6 | happen in CI. |
7 | 64-bit bytes value, and to properly round requests on behalf of | ||
8 | guests, we can pass any values, and can use qemu-io to add | ||
9 | coverage that our rounding is correct regardless of the guest | ||
10 | alignment constraints. | ||
11 | 7 | ||
12 | Update iotest 177 to intentionally probe block status at | 8 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> |
13 | unaligned boundaries as well as with a bytes value that does not | 9 | Message-Id: <20220509124134.867431-3-berrange@redhat.com> |
14 | map to 32-bit sectors, which also required tweaking the image | 10 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
15 | prep to leave an unallocated portion to the image under test. | 11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
16 | |||
17 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
18 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
19 | --- | 13 | --- |
20 | qemu-io-cmds.c | 13 ------------- | 14 | .gitlab-ci.d/buildtest-template.yml | 12 ++++++++++-- |
21 | tests/qemu-iotests/177 | 12 ++++++++++-- | 15 | 1 file changed, 10 insertions(+), 2 deletions(-) |
22 | tests/qemu-iotests/177.out | 19 ++++++++++++++----- | ||
23 | 3 files changed, 24 insertions(+), 20 deletions(-) | ||
24 | 16 | ||
25 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | 17 | diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml |
26 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/qemu-io-cmds.c | 19 | --- a/.gitlab-ci.d/buildtest-template.yml |
28 | +++ b/qemu-io-cmds.c | 20 | +++ b/.gitlab-ci.d/buildtest-template.yml |
29 | @@ -XXX,XX +XXX,XX @@ static int alloc_f(BlockBackend *blk, int argc, char **argv) | 21 | @@ -XXX,XX +XXX,XX @@ |
30 | if (offset < 0) { | 22 | make -j"$JOBS" $MAKE_CHECK_ARGS ; |
31 | print_cvtnum_err(offset, argv[1]); | 23 | fi |
32 | return 0; | 24 | |
33 | - } else if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { | 25 | -.native_test_job_template: |
34 | - printf("%" PRId64 " is not a sector-aligned value for 'offset'\n", | 26 | +.common_test_job_template: |
35 | - offset); | 27 | stage: test |
36 | - return 0; | 28 | image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:latest |
37 | } | 29 | script: |
38 | 30 | @@ -XXX,XX +XXX,XX @@ | |
39 | if (argc == 3) { | 31 | # Avoid recompiling by hiding ninja with NINJA=":" |
40 | @@ -XXX,XX +XXX,XX @@ static int alloc_f(BlockBackend *blk, int argc, char **argv) | 32 | - make NINJA=":" $MAKE_CHECK_ARGS |
41 | if (count < 0) { | 33 | |
42 | print_cvtnum_err(count, argv[2]); | 34 | +.native_test_job_template: |
43 | return 0; | 35 | + extends: .common_test_job_template |
44 | - } else if (count > INT_MAX * BDRV_SECTOR_SIZE) { | 36 | + artifacts: |
45 | - printf("length argument cannot exceed %llu, given %s\n", | 37 | + name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" |
46 | - INT_MAX * BDRV_SECTOR_SIZE, argv[2]); | 38 | + expire_in: 7 days |
47 | - return 0; | 39 | + paths: |
48 | } | 40 | + - build/meson-logs/testlog.txt |
49 | } else { | ||
50 | count = BDRV_SECTOR_SIZE; | ||
51 | } | ||
52 | - if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) { | ||
53 | - printf("%" PRId64 " is not a sector-aligned value for 'count'\n", | ||
54 | - count); | ||
55 | - return 0; | ||
56 | - } | ||
57 | |||
58 | remaining = count; | ||
59 | sum_alloc = 0; | ||
60 | diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177 | ||
61 | index XXXXXXX..XXXXXXX 100755 | ||
62 | --- a/tests/qemu-iotests/177 | ||
63 | +++ b/tests/qemu-iotests/177 | ||
64 | @@ -XXX,XX +XXX,XX @@ echo "== setting up files ==" | ||
65 | TEST_IMG="$TEST_IMG.base" _make_test_img $size | ||
66 | $QEMU_IO -c "write -P 11 0 $size" "$TEST_IMG.base" | _filter_qemu_io | ||
67 | _make_test_img -b "$TEST_IMG.base" | ||
68 | -$QEMU_IO -c "write -P 22 0 $size" "$TEST_IMG" | _filter_qemu_io | ||
69 | +$QEMU_IO -c "write -P 22 0 110M" "$TEST_IMG" | _filter_qemu_io | ||
70 | |||
71 | # Limited to 64k max-transfer | ||
72 | echo | ||
73 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ | ||
74 | -c "discard 80000001 30M" | _filter_qemu_io | ||
75 | |||
76 | echo | ||
77 | +echo "== block status smaller than alignment ==" | ||
78 | +limits=align=4k | ||
79 | +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ | ||
80 | + -c "alloc 1 1" -c "alloc 0x6dffff0 1000" -c "alloc 127m 5P" \ | ||
81 | + -c map | _filter_qemu_io | ||
82 | + | 41 | + |
83 | +echo | 42 | .avocado_test_job_template: |
84 | echo "== verify image content ==" | 43 | - extends: .native_test_job_template |
85 | 44 | + extends: .common_test_job_template | |
86 | function verify_io() | 45 | cache: |
87 | @@ -XXX,XX +XXX,XX @@ function verify_io() | 46 | key: "${CI_JOB_NAME}-cache" |
88 | echo read -P 0 32M 32M | 47 | paths: |
89 | echo read -P 22 64M 13M | ||
90 | echo read -P $discarded 77M 29M | ||
91 | - echo read -P 22 106M 22M | ||
92 | + echo read -P 22 106M 4M | ||
93 | + echo read -P 11 110M 18M | ||
94 | } | ||
95 | |||
96 | verify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io | ||
97 | diff --git a/tests/qemu-iotests/177.out b/tests/qemu-iotests/177.out | ||
98 | index XXXXXXX..XXXXXXX 100644 | ||
99 | --- a/tests/qemu-iotests/177.out | ||
100 | +++ b/tests/qemu-iotests/177.out | ||
101 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 | ||
102 | wrote 134217728/134217728 bytes at offset 0 | ||
103 | 128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
104 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base | ||
105 | -wrote 134217728/134217728 bytes at offset 0 | ||
106 | -128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
107 | +wrote 115343360/115343360 bytes at offset 0 | ||
108 | +110 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
109 | |||
110 | == constrained alignment and max-transfer == | ||
111 | wrote 131072/131072 bytes at offset 1000 | ||
112 | @@ -XXX,XX +XXX,XX @@ wrote 33554432/33554432 bytes at offset 33554432 | ||
113 | discard 31457280/31457280 bytes at offset 80000001 | ||
114 | 30 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
115 | |||
116 | +== block status smaller than alignment == | ||
117 | +1/1 bytes allocated at offset 1 bytes | ||
118 | +16/1000 bytes allocated at offset 110 MiB | ||
119 | +0/1048576 bytes allocated at offset 127 MiB | ||
120 | +110 MiB (0x6e00000) bytes allocated at offset 0 bytes (0x0) | ||
121 | +18 MiB (0x1200000) bytes not allocated at offset 110 MiB (0x6e00000) | ||
122 | + | ||
123 | == verify image content == | ||
124 | read 1000/1000 bytes at offset 0 | ||
125 | 1000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
126 | @@ -XXX,XX +XXX,XX @@ read 13631488/13631488 bytes at offset 67108864 | ||
127 | 13 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
128 | read 30408704/30408704 bytes at offset 80740352 | ||
129 | 29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
130 | -read 23068672/23068672 bytes at offset 111149056 | ||
131 | -22 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
132 | +read 4194304/4194304 bytes at offset 111149056 | ||
133 | +4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
134 | +read 18874368/18874368 bytes at offset 115343360 | ||
135 | +18 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
136 | Offset Length File | ||
137 | 0 0x800000 TEST_DIR/t.IMGFMT | ||
138 | 0x900000 0x2400000 TEST_DIR/t.IMGFMT | ||
139 | 0x3c00000 0x1100000 TEST_DIR/t.IMGFMT | ||
140 | -0x6a00000 0x1600000 TEST_DIR/t.IMGFMT | ||
141 | +0x6a00000 0x400000 TEST_DIR/t.IMGFMT | ||
142 | No errors were found on the image. | ||
143 | *** done | ||
144 | -- | 48 | -- |
145 | 2.13.6 | 49 | 2.35.3 |
146 | 50 | ||
147 | 51 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | In the process of converting sector-based interfaces to bytes, | 3 | Per the 82078 datasheet, if the end-of-track (EOT byte in |
4 | I'm finding it easier to represent a byte count as a 64-bit | 4 | the FIFO) is more than the number of sectors per side, the |
5 | integer at the block layer (even if we are internally capped | 5 | command is terminated unsuccessfully: |
6 | by SIZE_MAX or even INT_MAX for individual transactions, it's | ||
7 | still nicer to not have to worry about truncation/overflow | ||
8 | issues on as many variables). Update the signature of | ||
9 | bdrv_round_to_clusters() to uniformly use int64_t, matching | ||
10 | the signature already chosen for bdrv_is_allocated and the | ||
11 | fact that off_t is also a signed type, then adjust clients | ||
12 | according to the required fallout (even where the result could | ||
13 | now exceed 32 bits, no client is directly assigning the result | ||
14 | into a 32-bit value without breaking things into a loop first). | ||
15 | 6 | ||
16 | Signed-off-by: Eric Blake <eblake@redhat.com> | 7 | * 5.2.5 DATA TRANSFER TERMINATION |
8 | |||
9 | The 82078 supports terminal count explicitly through | ||
10 | the TC pin and implicitly through the underrun/over- | ||
11 | run and end-of-track (EOT) functions. For full sector | ||
12 | transfers, the EOT parameter can define the last | ||
13 | sector to be transferred in a single or multisector | ||
14 | transfer. If the last sector to be transferred is a par- | ||
15 | tial sector, the host can stop transferring the data in | ||
16 | mid-sector, and the 82078 will continue to complete | ||
17 | the sector as if a hardware TC was received. The | ||
18 | only difference between these implicit functions and | ||
19 | TC is that they return "abnormal termination" result | ||
20 | status. Such status indications can be ignored if they | ||
21 | were expected. | ||
22 | |||
23 | * 6.1.3 READ TRACK | ||
24 | |||
25 | This command terminates when the EOT specified | ||
26 | number of sectors have been read. If the 82078 | ||
27 | does not find an I D Address Mark on the diskette | ||
28 | after the second· occurrence of a pulse on the | ||
29 | INDX# pin, then it sets the IC code in Status Regis- | ||
30 | ter 0 to "01" (Abnormal termination), sets the MA bit | ||
31 | in Status Register 1 to "1", and terminates the com- | ||
32 | mand. | ||
33 | |||
34 | * 6.1.6 VERIFY | ||
35 | |||
36 | Refer to Table 6-6 and Table 6-7 for information | ||
37 | concerning the values of MT and EC versus SC and | ||
38 | EOT value. | ||
39 | |||
40 | * Table 6·6. Result Phase Table | ||
41 | |||
42 | * Table 6-7. Verify Command Result Phase Table | ||
43 | |||
44 | Fix by aborting the transfer when EOT > # Sectors Per Side. | ||
45 | |||
46 | Cc: qemu-stable@nongnu.org | ||
47 | Cc: Hervé Poussineau <hpoussin@reactos.org> | ||
48 | Fixes: baca51faff0 ("floppy driver: disk geometry auto detect") | ||
49 | Reported-by: Alexander Bulekov <alxndr@bu.edu> | ||
50 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/339 | ||
51 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
52 | Message-Id: <20211118115733.4038610-2-philmd@redhat.com> | ||
53 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 54 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
18 | --- | 55 | --- |
19 | include/block/block.h | 4 ++-- | 56 | hw/block/fdc.c | 8 ++++++++ |
20 | block/io.c | 6 +++--- | 57 | 1 file changed, 8 insertions(+) |
21 | block/mirror.c | 7 +++---- | ||
22 | block/trace-events | 2 +- | ||
23 | 4 files changed, 9 insertions(+), 10 deletions(-) | ||
24 | 58 | ||
25 | diff --git a/include/block/block.h b/include/block/block.h | 59 | diff --git a/hw/block/fdc.c b/hw/block/fdc.c |
26 | index XXXXXXX..XXXXXXX 100644 | 60 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/block/block.h | 61 | --- a/hw/block/fdc.c |
28 | +++ b/include/block/block.h | 62 | +++ b/hw/block/fdc.c |
29 | @@ -XXX,XX +XXX,XX @@ int bdrv_get_flags(BlockDriverState *bs); | 63 | @@ -XXX,XX +XXX,XX @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction) |
30 | int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); | 64 | int tmp; |
31 | ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs); | 65 | fdctrl->data_len = 128 << (fdctrl->fifo[5] > 7 ? 7 : fdctrl->fifo[5]); |
32 | void bdrv_round_to_clusters(BlockDriverState *bs, | 66 | tmp = (fdctrl->fifo[6] - ks + 1); |
33 | - int64_t offset, unsigned int bytes, | 67 | + if (tmp < 0) { |
34 | + int64_t offset, int64_t bytes, | 68 | + FLOPPY_DPRINTF("invalid EOT: %d\n", tmp); |
35 | int64_t *cluster_offset, | 69 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, FD_SR1_MA, 0x00); |
36 | - unsigned int *cluster_bytes); | 70 | + fdctrl->fifo[3] = kt; |
37 | + int64_t *cluster_bytes); | 71 | + fdctrl->fifo[4] = kh; |
38 | 72 | + fdctrl->fifo[5] = ks; | |
39 | const char *bdrv_get_encrypted_filename(BlockDriverState *bs); | 73 | + return; |
40 | void bdrv_get_backing_filename(BlockDriverState *bs, | 74 | + } |
41 | diff --git a/block/io.c b/block/io.c | 75 | if (fdctrl->fifo[0] & 0x80) |
42 | index XXXXXXX..XXXXXXX 100644 | 76 | tmp += fdctrl->fifo[6]; |
43 | --- a/block/io.c | 77 | fdctrl->data_len *= tmp; |
44 | +++ b/block/io.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) | ||
46 | * Round a region to cluster boundaries | ||
47 | */ | ||
48 | void bdrv_round_to_clusters(BlockDriverState *bs, | ||
49 | - int64_t offset, unsigned int bytes, | ||
50 | + int64_t offset, int64_t bytes, | ||
51 | int64_t *cluster_offset, | ||
52 | - unsigned int *cluster_bytes) | ||
53 | + int64_t *cluster_bytes) | ||
54 | { | ||
55 | BlockDriverInfo bdi; | ||
56 | |||
57 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
58 | struct iovec iov; | ||
59 | QEMUIOVector local_qiov; | ||
60 | int64_t cluster_offset; | ||
61 | - unsigned int cluster_bytes; | ||
62 | + int64_t cluster_bytes; | ||
63 | size_t skip_bytes; | ||
64 | int ret; | ||
65 | int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, | ||
66 | diff --git a/block/mirror.c b/block/mirror.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/block/mirror.c | ||
69 | +++ b/block/mirror.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int mirror_cow_align(MirrorBlockJob *s, int64_t *offset, | ||
71 | bool need_cow; | ||
72 | int ret = 0; | ||
73 | int64_t align_offset = *offset; | ||
74 | - unsigned int align_bytes = *bytes; | ||
75 | + int64_t align_bytes = *bytes; | ||
76 | int max_bytes = s->granularity * s->max_iov; | ||
77 | |||
78 | - assert(*bytes < INT_MAX); | ||
79 | need_cow = !test_bit(*offset / s->granularity, s->cow_bitmap); | ||
80 | need_cow |= !test_bit((*offset + *bytes - 1) / s->granularity, | ||
81 | s->cow_bitmap); | ||
82 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
83 | while (nb_chunks > 0 && offset < s->bdev_length) { | ||
84 | int64_t ret; | ||
85 | int io_sectors; | ||
86 | - unsigned int io_bytes; | ||
87 | + int64_t io_bytes; | ||
88 | int64_t io_bytes_acct; | ||
89 | enum MirrorMethod { | ||
90 | MIRROR_METHOD_COPY, | ||
91 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
92 | io_bytes = s->granularity; | ||
93 | } else if (ret >= 0 && !(ret & BDRV_BLOCK_DATA)) { | ||
94 | int64_t target_offset; | ||
95 | - unsigned int target_bytes; | ||
96 | + int64_t target_bytes; | ||
97 | bdrv_round_to_clusters(blk_bs(s->target), offset, io_bytes, | ||
98 | &target_offset, &target_bytes); | ||
99 | if (target_offset == offset && | ||
100 | diff --git a/block/trace-events b/block/trace-events | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/block/trace-events | ||
103 | +++ b/block/trace-events | ||
104 | @@ -XXX,XX +XXX,XX @@ blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int flag | ||
105 | bdrv_co_preadv(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" | ||
106 | bdrv_co_pwritev(void *bs, int64_t offset, int64_t nbytes, unsigned int flags) "bs %p offset %"PRId64" nbytes %"PRId64" flags 0x%x" | ||
107 | bdrv_co_pwrite_zeroes(void *bs, int64_t offset, int count, int flags) "bs %p offset %"PRId64" count %d flags 0x%x" | ||
108 | -bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int64_t cluster_offset, unsigned int cluster_bytes) "bs %p offset %"PRId64" bytes %u cluster_offset %"PRId64" cluster_bytes %u" | ||
109 | +bdrv_co_do_copy_on_readv(void *bs, int64_t offset, unsigned int bytes, int64_t cluster_offset, int64_t cluster_bytes) "bs %p offset %"PRId64" bytes %u cluster_offset %"PRId64" cluster_bytes %"PRId64 | ||
110 | |||
111 | # block/stream.c | ||
112 | stream_one_iteration(void *s, int64_t offset, uint64_t bytes, int is_allocated) "s %p offset %" PRId64 " bytes %" PRIu64 " is_allocated %d" | ||
113 | -- | 78 | -- |
114 | 2.13.6 | 79 | 2.35.3 |
115 | 80 | ||
116 | 81 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | During 'qemu-img compare', when we are checking that an allocated | 3 | Add the reproducer from https://gitlab.com/qemu-project/qemu/-/issues/339 |
4 | portion of one file is all zeros, we don't need to waste time | ||
5 | computing how many additional sectors after the first non-zero | ||
6 | byte are also non-zero. Create a new helper find_nonzero() to do | ||
7 | the check for a first non-zero sector, and rebase | ||
8 | check_empty_sectors() to use it. | ||
9 | 4 | ||
10 | The new interface intentionally uses bytes in its interface, even | 5 | Without the previous commit, when running 'make check-qtest-i386' |
11 | though it still crawls the buffer a sector at a time; it is robust | 6 | with QEMU configured with '--enable-sanitizers' we get: |
12 | to a partial sector at the end of the buffer. | ||
13 | 7 | ||
14 | Signed-off-by: Eric Blake <eblake@redhat.com> | 8 | ==4028352==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x619000062a00 at pc 0x5626d03c491a bp 0x7ffdb4199410 sp 0x7ffdb4198bc0 |
15 | Reviewed-by: John Snow <jsnow@redhat.com> | 9 | READ of size 786432 at 0x619000062a00 thread T0 |
10 | #0 0x5626d03c4919 in __asan_memcpy (qemu-system-i386+0x1e65919) | ||
11 | #1 0x5626d1c023cc in flatview_write_continue softmmu/physmem.c:2787:13 | ||
12 | #2 0x5626d1bf0c0f in flatview_write softmmu/physmem.c:2822:14 | ||
13 | #3 0x5626d1bf0798 in address_space_write softmmu/physmem.c:2914:18 | ||
14 | #4 0x5626d1bf0f37 in address_space_rw softmmu/physmem.c:2924:16 | ||
15 | #5 0x5626d1bf14c8 in cpu_physical_memory_rw softmmu/physmem.c:2933:5 | ||
16 | #6 0x5626d0bd5649 in cpu_physical_memory_write include/exec/cpu-common.h:82:5 | ||
17 | #7 0x5626d0bd0a07 in i8257_dma_write_memory hw/dma/i8257.c:452:9 | ||
18 | #8 0x5626d09f825d in fdctrl_transfer_handler hw/block/fdc.c:1616:13 | ||
19 | #9 0x5626d0a048b4 in fdctrl_start_transfer hw/block/fdc.c:1539:13 | ||
20 | #10 0x5626d09f4c3e in fdctrl_write_data hw/block/fdc.c:2266:13 | ||
21 | #11 0x5626d09f22f7 in fdctrl_write hw/block/fdc.c:829:9 | ||
22 | #12 0x5626d1c20bc5 in portio_write softmmu/ioport.c:207:17 | ||
23 | |||
24 | 0x619000062a00 is located 0 bytes to the right of 512-byte region [0x619000062800,0x619000062a00) | ||
25 | allocated by thread T0 here: | ||
26 | #0 0x5626d03c66ec in posix_memalign (qemu-system-i386+0x1e676ec) | ||
27 | #1 0x5626d2b988d4 in qemu_try_memalign util/oslib-posix.c:210:11 | ||
28 | #2 0x5626d2b98b0c in qemu_memalign util/oslib-posix.c:226:27 | ||
29 | #3 0x5626d09fbaf0 in fdctrl_realize_common hw/block/fdc.c:2341:20 | ||
30 | #4 0x5626d0a150ed in isabus_fdc_realize hw/block/fdc-isa.c:113:5 | ||
31 | #5 0x5626d2367935 in device_set_realized hw/core/qdev.c:531:13 | ||
32 | |||
33 | SUMMARY: AddressSanitizer: heap-buffer-overflow (qemu-system-i386+0x1e65919) in __asan_memcpy | ||
34 | Shadow bytes around the buggy address: | ||
35 | 0x0c32800044f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa | ||
36 | 0x0c3280004500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ||
37 | 0x0c3280004510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ||
38 | 0x0c3280004520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ||
39 | 0x0c3280004530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ||
40 | =>0x0c3280004540:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa | ||
41 | 0x0c3280004550: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa | ||
42 | 0x0c3280004560: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa | ||
43 | 0x0c3280004570: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa | ||
44 | 0x0c3280004580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa | ||
45 | 0x0c3280004590: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd | ||
46 | Shadow byte legend (one shadow byte represents 8 application bytes): | ||
47 | Addressable: 00 | ||
48 | Heap left redzone: fa | ||
49 | Freed heap region: fd | ||
50 | ==4028352==ABORTING | ||
51 | |||
52 | [ kwolf: Added snapshot=on to prevent write file lock failure ] | ||
53 | |||
54 | Reported-by: Alexander Bulekov <alxndr@bu.edu> | ||
55 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
56 | Reviewed-by: Alexander Bulekov <alxndr@bu.edu> | ||
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 57 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
17 | --- | 58 | --- |
18 | qemu-img.c | 32 ++++++++++++++++++++++++++++---- | 59 | tests/qtest/fdc-test.c | 21 +++++++++++++++++++++ |
19 | 1 file changed, 28 insertions(+), 4 deletions(-) | 60 | 1 file changed, 21 insertions(+) |
20 | 61 | ||
21 | diff --git a/qemu-img.c b/qemu-img.c | 62 | diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c |
22 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/qemu-img.c | 64 | --- a/tests/qtest/fdc-test.c |
24 | +++ b/qemu-img.c | 65 | +++ b/tests/qtest/fdc-test.c |
25 | @@ -XXX,XX +XXX,XX @@ done: | 66 | @@ -XXX,XX +XXX,XX @@ static void test_cve_2021_20196(void) |
67 | qtest_quit(s); | ||
26 | } | 68 | } |
27 | 69 | ||
28 | /* | 70 | +static void test_cve_2021_3507(void) |
29 | + * Returns -1 if 'buf' contains only zeroes, otherwise the byte index | ||
30 | + * of the first sector boundary within buf where the sector contains a | ||
31 | + * non-zero byte. This function is robust to a buffer that is not | ||
32 | + * sector-aligned. | ||
33 | + */ | ||
34 | +static int64_t find_nonzero(const uint8_t *buf, int64_t n) | ||
35 | +{ | 71 | +{ |
36 | + int64_t i; | 72 | + QTestState *s; |
37 | + int64_t end = QEMU_ALIGN_DOWN(n, BDRV_SECTOR_SIZE); | ||
38 | + | 73 | + |
39 | + for (i = 0; i < end; i += BDRV_SECTOR_SIZE) { | 74 | + s = qtest_initf("-nographic -m 32M -nodefaults " |
40 | + if (!buffer_is_zero(buf + i, BDRV_SECTOR_SIZE)) { | 75 | + "-drive file=%s,format=raw,if=floppy,snapshot=on", |
41 | + return i; | 76 | + test_image); |
42 | + } | 77 | + qtest_outl(s, 0x9, 0x0a0206); |
43 | + } | 78 | + qtest_outw(s, 0x3f4, 0x1600); |
44 | + if (i < n && !buffer_is_zero(buf + i, n - end)) { | 79 | + qtest_outw(s, 0x3f4, 0x0000); |
45 | + return i; | 80 | + qtest_outw(s, 0x3f4, 0x0000); |
46 | + } | 81 | + qtest_outw(s, 0x3f4, 0x0000); |
47 | + return -1; | 82 | + qtest_outw(s, 0x3f4, 0x0200); |
83 | + qtest_outw(s, 0x3f4, 0x0200); | ||
84 | + qtest_outw(s, 0x3f4, 0x0000); | ||
85 | + qtest_outw(s, 0x3f4, 0x0000); | ||
86 | + qtest_outw(s, 0x3f4, 0x0000); | ||
87 | + qtest_quit(s); | ||
48 | +} | 88 | +} |
49 | + | 89 | + |
50 | +/* | 90 | int main(int argc, char **argv) |
51 | * Returns true iff the first sector pointed to by 'buf' contains at least | ||
52 | * a non-NUL byte. | ||
53 | * | ||
54 | @@ -XXX,XX +XXX,XX @@ static int check_empty_sectors(BlockBackend *blk, int64_t sect_num, | ||
55 | int sect_count, const char *filename, | ||
56 | uint8_t *buffer, bool quiet) | ||
57 | { | 91 | { |
58 | - int pnum, ret = 0; | 92 | int fd; |
59 | + int ret = 0; | 93 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) |
60 | + int64_t idx; | 94 | qtest_add_func("/fdc/read_no_dma_19", test_read_no_dma_19); |
61 | + | 95 | qtest_add_func("/fdc/fuzz-registers", fuzz_registers); |
62 | ret = blk_pread(blk, sect_num << BDRV_SECTOR_BITS, buffer, | 96 | qtest_add_func("/fdc/fuzz/cve_2021_20196", test_cve_2021_20196); |
63 | sect_count << BDRV_SECTOR_BITS); | 97 | + qtest_add_func("/fdc/fuzz/cve_2021_3507", test_cve_2021_3507); |
64 | if (ret < 0) { | 98 | |
65 | @@ -XXX,XX +XXX,XX @@ static int check_empty_sectors(BlockBackend *blk, int64_t sect_num, | 99 | ret = g_test_run(); |
66 | sectors_to_bytes(sect_num), filename, strerror(-ret)); | ||
67 | return ret; | ||
68 | } | ||
69 | - ret = is_allocated_sectors(buffer, sect_count, &pnum); | ||
70 | - if (ret || pnum != sect_count) { | ||
71 | + idx = find_nonzero(buffer, sect_count * BDRV_SECTOR_SIZE); | ||
72 | + if (idx >= 0) { | ||
73 | qprintf(quiet, "Content mismatch at offset %" PRId64 "!\n", | ||
74 | - sectors_to_bytes(ret ? sect_num : sect_num + pnum)); | ||
75 | + sectors_to_bytes(sect_num) + idx); | ||
76 | return 1; | ||
77 | } | ||
78 | 100 | ||
79 | -- | 101 | -- |
80 | 2.13.6 | 102 | 2.35.3 |
81 | 103 | ||
82 | 104 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Eric Blake <eblake@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | We are gradually moving away from sector-based interfaces, towards | 3 | The next patch wants to adjust whether the NBD server code advertises |
4 | byte-based. In the common case, allocation is unlikely to ever use | 4 | MULTI_CONN based on whether it is known if the server limits to |
5 | values that are not naturally sector-aligned, but it is possible | 5 | exactly one client. For a server started by QMP, this information is |
6 | that byte-based values will let us be more precise about allocation | 6 | obtained through nbd_server_start (which can support more than one |
7 | at the end of an unaligned file that can do byte-based access. | 7 | export); but for qemu-nbd (which supports exactly one export), it is |
8 | 8 | controlled only by the command-line option -e/--shared. Since we | |
9 | Changing the name of the function from bdrv_get_block_status() to | 9 | already have a hook function used by qemu-nbd, it's easiest to just |
10 | bdrv_block_status() ensures that the compiler enforces that all | 10 | alter its signature to fit our needs. |
11 | callers are updated. For now, the io.c layer still assert()s that | ||
12 | all callers are sector-aligned, but that can be relaxed when a later | ||
13 | patch implements byte-based block status in the drivers. | ||
14 | |||
15 | There was an inherent limitation in returning the offset via the | ||
16 | return value: we only have room for BDRV_BLOCK_OFFSET_MASK bits, which | ||
17 | means an offset can only be mapped for sector-aligned queries (or, | ||
18 | if we declare that non-aligned input is at the same relative position | ||
19 | modulo 512 of the answer), so the new interface also changes things to | ||
20 | return the offset via output through a parameter by reference rather | ||
21 | than mashed into the return value. We'll have some glue code that | ||
22 | munges between the two styles until we finish converting all uses. | ||
23 | |||
24 | For the most part this patch is just the addition of scaling at the | ||
25 | callers followed by inverse scaling at bdrv_block_status(), coupled | ||
26 | with the tweak in calling convention. But some code, particularly | ||
27 | bdrv_is_allocated(), gets a lot simpler because it no longer has to | ||
28 | mess with sectors. | ||
29 | |||
30 | For ease of review, bdrv_get_block_status_above() will be tackled | ||
31 | separately. | ||
32 | 11 | ||
33 | Signed-off-by: Eric Blake <eblake@redhat.com> | 12 | Signed-off-by: Eric Blake <eblake@redhat.com> |
13 | Message-Id: <20220512004924.417153-2-eblake@redhat.com> | ||
34 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 14 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
35 | --- | 15 | --- |
36 | include/block/block.h | 17 +++++++++-------- | 16 | include/block/nbd.h | 2 +- |
37 | block/io.c | 47 ++++++++++++++++++++++++++++++++++------------- | 17 | blockdev-nbd.c | 8 ++++---- |
38 | block/qcow2-cluster.c | 2 +- | 18 | qemu-nbd.c | 2 +- |
39 | qemu-img.c | 25 ++++++++++++++----------- | 19 | 3 files changed, 6 insertions(+), 6 deletions(-) |
40 | 4 files changed, 58 insertions(+), 33 deletions(-) | ||
41 | 20 | ||
42 | diff --git a/include/block/block.h b/include/block/block.h | 21 | diff --git a/include/block/nbd.h b/include/block/nbd.h |
43 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/include/block/block.h | 23 | --- a/include/block/nbd.h |
45 | +++ b/include/block/block.h | 24 | +++ b/include/block/nbd.h |
46 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | 25 | @@ -XXX,XX +XXX,XX @@ void nbd_client_new(QIOChannelSocket *sioc, |
47 | #define BDRV_REQUEST_MAX_BYTES (BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS) | 26 | void nbd_client_get(NBDClient *client); |
48 | 27 | void nbd_client_put(NBDClient *client); | |
49 | /* | 28 | |
50 | - * Allocation status flags for bdrv_get_block_status() and friends. | 29 | -void nbd_server_is_qemu_nbd(bool value); |
51 | + * Allocation status flags for bdrv_block_status() and friends. | 30 | +void nbd_server_is_qemu_nbd(int max_connections); |
52 | * | 31 | bool nbd_server_is_running(void); |
53 | * Public flags: | 32 | void nbd_server_start(SocketAddress *addr, const char *tls_creds, |
54 | * BDRV_BLOCK_DATA: allocation for data at offset is tied to this layer | 33 | const char *tls_authz, uint32_t max_connections, |
55 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | 34 | diff --git a/blockdev-nbd.c b/blockdev-nbd.c |
56 | * that the block layer recompute the answer from the returned | ||
57 | * BDS; must be accompanied by just BDRV_BLOCK_OFFSET_VALID. | ||
58 | * | ||
59 | - * If BDRV_BLOCK_OFFSET_VALID is set, bits 9-62 (BDRV_BLOCK_OFFSET_MASK) | ||
60 | - * represent the offset in the returned BDS that is allocated for the | ||
61 | - * corresponding raw data; however, whether that offset actually contains | ||
62 | - * data also depends on BDRV_BLOCK_DATA and BDRV_BLOCK_ZERO, as follows: | ||
63 | + * If BDRV_BLOCK_OFFSET_VALID is set, bits 9-62 (BDRV_BLOCK_OFFSET_MASK) of | ||
64 | + * the return value (old interface) or the entire map parameter (new | ||
65 | + * interface) represent the offset in the returned BDS that is allocated for | ||
66 | + * the corresponding raw data. However, whether that offset actually | ||
67 | + * contains data also depends on BDRV_BLOCK_DATA, as follows: | ||
68 | * | ||
69 | * DATA ZERO OFFSET_VALID | ||
70 | * t t t sectors read as zero, returned file is zero at offset | ||
71 | @@ -XXX,XX +XXX,XX @@ int bdrv_has_zero_init_1(BlockDriverState *bs); | ||
72 | int bdrv_has_zero_init(BlockDriverState *bs); | ||
73 | bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs); | ||
74 | bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs); | ||
75 | -int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num, | ||
76 | - int nb_sectors, int *pnum, | ||
77 | - BlockDriverState **file); | ||
78 | +int bdrv_block_status(BlockDriverState *bs, int64_t offset, | ||
79 | + int64_t bytes, int64_t *pnum, int64_t *map, | ||
80 | + BlockDriverState **file); | ||
81 | int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
82 | BlockDriverState *base, | ||
83 | int64_t sector_num, | ||
84 | diff --git a/block/io.c b/block/io.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
86 | --- a/block/io.c | 36 | --- a/blockdev-nbd.c |
87 | +++ b/block/io.c | 37 | +++ b/blockdev-nbd.c |
88 | @@ -XXX,XX +XXX,XX @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, | 38 | @@ -XXX,XX +XXX,XX @@ typedef struct NBDServerData { |
89 | */ | 39 | } NBDServerData; |
90 | int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags) | 40 | |
41 | static NBDServerData *nbd_server; | ||
42 | -static bool is_qemu_nbd; | ||
43 | +static int qemu_nbd_connections = -1; /* Non-negative if this is qemu-nbd */ | ||
44 | |||
45 | static void nbd_update_server_watch(NBDServerData *s); | ||
46 | |||
47 | -void nbd_server_is_qemu_nbd(bool value) | ||
48 | +void nbd_server_is_qemu_nbd(int max_connections) | ||
91 | { | 49 | { |
92 | - int64_t target_size, ret, bytes, offset = 0; | 50 | - is_qemu_nbd = value; |
93 | + int ret; | 51 | + qemu_nbd_connections = max_connections; |
94 | + int64_t target_size, bytes, offset = 0; | ||
95 | BlockDriverState *bs = child->bs; | ||
96 | - int n; /* sectors */ | ||
97 | |||
98 | target_size = bdrv_getlength(bs); | ||
99 | if (target_size < 0) { | ||
100 | @@ -XXX,XX +XXX,XX @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags) | ||
101 | if (bytes <= 0) { | ||
102 | return 0; | ||
103 | } | ||
104 | - ret = bdrv_get_block_status(bs, offset >> BDRV_SECTOR_BITS, | ||
105 | - bytes >> BDRV_SECTOR_BITS, &n, NULL); | ||
106 | + ret = bdrv_block_status(bs, offset, bytes, &bytes, NULL, NULL); | ||
107 | if (ret < 0) { | ||
108 | error_report("error getting block status at offset %" PRId64 ": %s", | ||
109 | offset, strerror(-ret)); | ||
110 | return ret; | ||
111 | } | ||
112 | if (ret & BDRV_BLOCK_ZERO) { | ||
113 | - offset += n * BDRV_SECTOR_BITS; | ||
114 | + offset += bytes; | ||
115 | continue; | ||
116 | } | ||
117 | - ret = bdrv_pwrite_zeroes(child, offset, n * BDRV_SECTOR_SIZE, flags); | ||
118 | + ret = bdrv_pwrite_zeroes(child, offset, bytes, flags); | ||
119 | if (ret < 0) { | ||
120 | error_report("error writing zeroes at offset %" PRId64 ": %s", | ||
121 | offset, strerror(-ret)); | ||
122 | return ret; | ||
123 | } | ||
124 | - offset += n * BDRV_SECTOR_SIZE; | ||
125 | + offset += bytes; | ||
126 | } | ||
127 | } | 52 | } |
128 | 53 | ||
129 | @@ -XXX,XX +XXX,XX @@ int64_t bdrv_get_block_status_above(BlockDriverState *bs, | 54 | bool nbd_server_is_running(void) |
130 | nb_sectors, pnum, file); | 55 | { |
56 | - return nbd_server || is_qemu_nbd; | ||
57 | + return nbd_server || qemu_nbd_connections >= 0; | ||
131 | } | 58 | } |
132 | 59 | ||
133 | -int64_t bdrv_get_block_status(BlockDriverState *bs, | 60 | static void nbd_blockdev_client_closed(NBDClient *client, bool ignored) |
134 | - int64_t sector_num, | 61 | diff --git a/qemu-nbd.c b/qemu-nbd.c |
135 | - int nb_sectors, int *pnum, | ||
136 | - BlockDriverState **file) | ||
137 | +int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
138 | + int64_t *pnum, int64_t *map, BlockDriverState **file) | ||
139 | { | ||
140 | - return bdrv_get_block_status_above(bs, backing_bs(bs), | ||
141 | - sector_num, nb_sectors, pnum, file); | ||
142 | + int64_t ret; | ||
143 | + int n; | ||
144 | + | ||
145 | + assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); | ||
146 | + assert(pnum); | ||
147 | + /* | ||
148 | + * The contract allows us to return pnum smaller than bytes, even | ||
149 | + * if the next query would see the same status; we truncate the | ||
150 | + * request to avoid overflowing the driver's 32-bit interface. | ||
151 | + */ | ||
152 | + bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES); | ||
153 | + ret = bdrv_get_block_status_above(bs, backing_bs(bs), | ||
154 | + offset >> BDRV_SECTOR_BITS, | ||
155 | + bytes >> BDRV_SECTOR_BITS, &n, file); | ||
156 | + if (ret < 0) { | ||
157 | + assert(INT_MIN <= ret); | ||
158 | + *pnum = 0; | ||
159 | + return ret; | ||
160 | + } | ||
161 | + *pnum = n * BDRV_SECTOR_SIZE; | ||
162 | + if (map) { | ||
163 | + *map = ret & BDRV_BLOCK_OFFSET_MASK; | ||
164 | + } else { | ||
165 | + ret &= ~BDRV_BLOCK_OFFSET_VALID; | ||
166 | + } | ||
167 | + return ret & ~BDRV_BLOCK_OFFSET_MASK; | ||
168 | } | ||
169 | |||
170 | int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | ||
171 | diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c | ||
172 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
173 | --- a/block/qcow2-cluster.c | 63 | --- a/qemu-nbd.c |
174 | +++ b/block/qcow2-cluster.c | 64 | +++ b/qemu-nbd.c |
175 | @@ -XXX,XX +XXX,XX @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, | 65 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) |
176 | * cluster is already marked as zero, or if it's unallocated and we | 66 | |
177 | * don't have a backing file. | 67 | bs->detect_zeroes = detect_zeroes; |
178 | * | 68 | |
179 | - * TODO We might want to use bdrv_get_block_status(bs) here, but we're | 69 | - nbd_server_is_qemu_nbd(true); |
180 | + * TODO We might want to use bdrv_block_status(bs) here, but we're | 70 | + nbd_server_is_qemu_nbd(shared); |
181 | * holding s->lock, so that doesn't work today. | 71 | |
182 | * | 72 | export_opts = g_new(BlockExportOptions, 1); |
183 | * If full_discard is true, the sector should not read back as zeroes, | 73 | *export_opts = (BlockExportOptions) { |
184 | diff --git a/qemu-img.c b/qemu-img.c | ||
185 | index XXXXXXX..XXXXXXX 100644 | ||
186 | --- a/qemu-img.c | ||
187 | +++ b/qemu-img.c | ||
188 | @@ -XXX,XX +XXX,XX @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) | ||
189 | |||
190 | if (s->sector_next_status <= sector_num) { | ||
191 | if (s->target_has_backing) { | ||
192 | - ret = bdrv_get_block_status(blk_bs(s->src[src_cur]), | ||
193 | - sector_num - src_cur_offset, | ||
194 | - n, &n, NULL); | ||
195 | + int64_t count = n * BDRV_SECTOR_SIZE; | ||
196 | + | ||
197 | + ret = bdrv_block_status(blk_bs(s->src[src_cur]), | ||
198 | + (sector_num - src_cur_offset) * | ||
199 | + BDRV_SECTOR_SIZE, | ||
200 | + count, &count, NULL, NULL); | ||
201 | + assert(ret < 0 || QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)); | ||
202 | + n = count >> BDRV_SECTOR_BITS; | ||
203 | } else { | ||
204 | ret = bdrv_get_block_status_above(blk_bs(s->src[src_cur]), NULL, | ||
205 | sector_num - src_cur_offset, | ||
206 | @@ -XXX,XX +XXX,XX @@ static void dump_map_entry(OutputFormat output_format, MapEntry *e, | ||
207 | static int get_block_status(BlockDriverState *bs, int64_t offset, | ||
208 | int64_t bytes, MapEntry *e) | ||
209 | { | ||
210 | - int64_t ret; | ||
211 | + int ret; | ||
212 | int depth; | ||
213 | BlockDriverState *file; | ||
214 | bool has_offset; | ||
215 | - int nb_sectors = bytes >> BDRV_SECTOR_BITS; | ||
216 | + int64_t map; | ||
217 | |||
218 | - assert(bytes < INT_MAX); | ||
219 | /* As an optimization, we could cache the current range of unallocated | ||
220 | * clusters in each file of the chain, and avoid querying the same | ||
221 | * range repeatedly. | ||
222 | @@ -XXX,XX +XXX,XX @@ static int get_block_status(BlockDriverState *bs, int64_t offset, | ||
223 | |||
224 | depth = 0; | ||
225 | for (;;) { | ||
226 | - ret = bdrv_get_block_status(bs, offset >> BDRV_SECTOR_BITS, nb_sectors, | ||
227 | - &nb_sectors, &file); | ||
228 | + ret = bdrv_block_status(bs, offset, bytes, &bytes, &map, &file); | ||
229 | if (ret < 0) { | ||
230 | return ret; | ||
231 | } | ||
232 | - assert(nb_sectors); | ||
233 | + assert(bytes); | ||
234 | if (ret & (BDRV_BLOCK_ZERO|BDRV_BLOCK_DATA)) { | ||
235 | break; | ||
236 | } | ||
237 | @@ -XXX,XX +XXX,XX @@ static int get_block_status(BlockDriverState *bs, int64_t offset, | ||
238 | |||
239 | *e = (MapEntry) { | ||
240 | .start = offset, | ||
241 | - .length = nb_sectors * BDRV_SECTOR_SIZE, | ||
242 | + .length = bytes, | ||
243 | .data = !!(ret & BDRV_BLOCK_DATA), | ||
244 | .zero = !!(ret & BDRV_BLOCK_ZERO), | ||
245 | - .offset = ret & BDRV_BLOCK_OFFSET_MASK, | ||
246 | + .offset = map, | ||
247 | .has_offset = has_offset, | ||
248 | .depth = depth, | ||
249 | .has_filename = file && has_offset, | ||
250 | -- | 74 | -- |
251 | 2.13.6 | 75 | 2.35.3 |
252 | |||
253 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Eric Blake <eblake@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | According to the NBD spec, a server that advertises |
4 | Message-id: 20170929170843.3711-1-mreitz@redhat.com | 4 | NBD_FLAG_CAN_MULTI_CONN promises that multiple client connections will |
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | 5 | not see any cache inconsistencies: when properly separated by a single |
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | flush, actions performed by one client will be visible to another |
7 | client, regardless of which client did the flush. | ||
8 | |||
9 | We always satisfy these conditions in qemu - even when we support | ||
10 | multiple clients, ALL clients go through a single point of reference | ||
11 | into the block layer, with no local caching. The effect of one client | ||
12 | is instantly visible to the next client. Even if our backend were a | ||
13 | network device, we argue that any multi-path caching effects that | ||
14 | would cause inconsistencies in back-to-back actions not seeing the | ||
15 | effect of previous actions would be a bug in that backend, and not the | ||
16 | fault of caching in qemu. As such, it is safe to unconditionally | ||
17 | advertise CAN_MULTI_CONN for any qemu NBD server situation that | ||
18 | supports parallel clients. | ||
19 | |||
20 | Note, however, that we don't want to advertise CAN_MULTI_CONN when we | ||
21 | know that a second client cannot connect (for historical reasons, | ||
22 | qemu-nbd defaults to a single connection while nbd-server-add and QMP | ||
23 | commands default to unlimited connections; but we already have | ||
24 | existing means to let either style of NBD server creation alter those | ||
25 | defaults). This is visible by no longer advertising MULTI_CONN for | ||
26 | 'qemu-nbd -r' without -e, as in the iotest nbd-qemu-allocation. | ||
27 | |||
28 | The harder part of this patch is setting up an iotest to demonstrate | ||
29 | behavior of multiple NBD clients to a single server. It might be | ||
30 | possible with parallel qemu-io processes, but I found it easier to do | ||
31 | in python with the help of libnbd, and help from Nir and Vladimir in | ||
32 | writing the test. | ||
33 | |||
34 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
35 | Suggested-by: Nir Soffer <nsoffer@redhat.com> | ||
36 | Suggested-by: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru> | ||
37 | Message-Id: <20220512004924.417153-3-eblake@redhat.com> | ||
38 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
7 | --- | 39 | --- |
8 | tests/qemu-iotests/127 | 97 ++++++++++++++++++++++++++++++++++++++++++++++ | 40 | qapi/block-export.json | 8 +- |
9 | tests/qemu-iotests/127.out | 14 +++++++ | 41 | docs/interop/nbd.txt | 1 + |
10 | tests/qemu-iotests/group | 1 + | 42 | docs/tools/qemu-nbd.rst | 3 +- |
11 | 3 files changed, 112 insertions(+) | 43 | include/block/nbd.h | 3 +- |
12 | create mode 100755 tests/qemu-iotests/127 | 44 | blockdev-nbd.c | 5 + |
13 | create mode 100644 tests/qemu-iotests/127.out | 45 | nbd/server.c | 10 +- |
14 | 46 | MAINTAINERS | 1 + | |
15 | diff --git a/tests/qemu-iotests/127 b/tests/qemu-iotests/127 | 47 | tests/qemu-iotests/tests/nbd-multiconn | 145 ++++++++++++++++++ |
48 | tests/qemu-iotests/tests/nbd-multiconn.out | 5 + | ||
49 | .../tests/nbd-qemu-allocation.out | 2 +- | ||
50 | 10 files changed, 172 insertions(+), 11 deletions(-) | ||
51 | create mode 100755 tests/qemu-iotests/tests/nbd-multiconn | ||
52 | create mode 100644 tests/qemu-iotests/tests/nbd-multiconn.out | ||
53 | |||
54 | diff --git a/qapi/block-export.json b/qapi/block-export.json | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/qapi/block-export.json | ||
57 | +++ b/qapi/block-export.json | ||
58 | @@ -XXX,XX +XXX,XX @@ | ||
59 | # recreated on the fly while the NBD server is active. | ||
60 | # If missing, it will default to denying access (since 4.0). | ||
61 | # @max-connections: The maximum number of connections to allow at the same | ||
62 | -# time, 0 for unlimited. (since 5.2; default: 0) | ||
63 | +# time, 0 for unlimited. Setting this to 1 also stops | ||
64 | +# the server from advertising multiple client support | ||
65 | +# (since 5.2; default: 0) | ||
66 | # | ||
67 | # Since: 4.2 | ||
68 | ## | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | # recreated on the fly while the NBD server is active. | ||
71 | # If missing, it will default to denying access (since 4.0). | ||
72 | # @max-connections: The maximum number of connections to allow at the same | ||
73 | -# time, 0 for unlimited. (since 5.2; default: 0) | ||
74 | +# time, 0 for unlimited. Setting this to 1 also stops | ||
75 | +# the server from advertising multiple client support | ||
76 | +# (since 5.2; default: 0). | ||
77 | # | ||
78 | # Returns: error if the server is already running. | ||
79 | # | ||
80 | diff --git a/docs/interop/nbd.txt b/docs/interop/nbd.txt | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/docs/interop/nbd.txt | ||
83 | +++ b/docs/interop/nbd.txt | ||
84 | @@ -XXX,XX +XXX,XX @@ NBD_CMD_BLOCK_STATUS for "qemu:dirty-bitmap:", NBD_CMD_CACHE | ||
85 | * 4.2: NBD_FLAG_CAN_MULTI_CONN for shareable read-only exports, | ||
86 | NBD_CMD_FLAG_FAST_ZERO | ||
87 | * 5.2: NBD_CMD_BLOCK_STATUS for "qemu:allocation-depth" | ||
88 | +* 7.1: NBD_FLAG_CAN_MULTI_CONN for shareable writable exports | ||
89 | diff --git a/docs/tools/qemu-nbd.rst b/docs/tools/qemu-nbd.rst | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/docs/tools/qemu-nbd.rst | ||
92 | +++ b/docs/tools/qemu-nbd.rst | ||
93 | @@ -XXX,XX +XXX,XX @@ driver options if :option:`--image-opts` is specified. | ||
94 | .. option:: -e, --shared=NUM | ||
95 | |||
96 | Allow up to *NUM* clients to share the device (default | ||
97 | - ``1``), 0 for unlimited. Safe for readers, but for now, | ||
98 | - consistency is not guaranteed between multiple writers. | ||
99 | + ``1``), 0 for unlimited. | ||
100 | |||
101 | .. option:: -t, --persistent | ||
102 | |||
103 | diff --git a/include/block/nbd.h b/include/block/nbd.h | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/include/block/nbd.h | ||
106 | +++ b/include/block/nbd.h | ||
107 | @@ -XXX,XX +XXX,XX @@ | ||
108 | /* | ||
109 | - * Copyright (C) 2016-2020 Red Hat, Inc. | ||
110 | + * Copyright (C) 2016-2022 Red Hat, Inc. | ||
111 | * Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws> | ||
112 | * | ||
113 | * Network Block Device | ||
114 | @@ -XXX,XX +XXX,XX @@ void nbd_client_put(NBDClient *client); | ||
115 | |||
116 | void nbd_server_is_qemu_nbd(int max_connections); | ||
117 | bool nbd_server_is_running(void); | ||
118 | +int nbd_server_max_connections(void); | ||
119 | void nbd_server_start(SocketAddress *addr, const char *tls_creds, | ||
120 | const char *tls_authz, uint32_t max_connections, | ||
121 | Error **errp); | ||
122 | diff --git a/blockdev-nbd.c b/blockdev-nbd.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/blockdev-nbd.c | ||
125 | +++ b/blockdev-nbd.c | ||
126 | @@ -XXX,XX +XXX,XX @@ bool nbd_server_is_running(void) | ||
127 | return nbd_server || qemu_nbd_connections >= 0; | ||
128 | } | ||
129 | |||
130 | +int nbd_server_max_connections(void) | ||
131 | +{ | ||
132 | + return nbd_server ? nbd_server->max_connections : qemu_nbd_connections; | ||
133 | +} | ||
134 | + | ||
135 | static void nbd_blockdev_client_closed(NBDClient *client, bool ignored) | ||
136 | { | ||
137 | nbd_client_put(client); | ||
138 | diff --git a/nbd/server.c b/nbd/server.c | ||
139 | index XXXXXXX..XXXXXXX 100644 | ||
140 | --- a/nbd/server.c | ||
141 | +++ b/nbd/server.c | ||
142 | @@ -XXX,XX +XXX,XX @@ | ||
143 | /* | ||
144 | - * Copyright (C) 2016-2021 Red Hat, Inc. | ||
145 | + * Copyright (C) 2016-2022 Red Hat, Inc. | ||
146 | * Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws> | ||
147 | * | ||
148 | * Network Block Device Server Side | ||
149 | @@ -XXX,XX +XXX,XX @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args, | ||
150 | int64_t size; | ||
151 | uint64_t perm, shared_perm; | ||
152 | bool readonly = !exp_args->writable; | ||
153 | - bool shared = !exp_args->writable; | ||
154 | BlockDirtyBitmapOrStrList *bitmaps; | ||
155 | size_t i; | ||
156 | int ret; | ||
157 | @@ -XXX,XX +XXX,XX @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args, | ||
158 | exp->description = g_strdup(arg->description); | ||
159 | exp->nbdflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_FLUSH | | ||
160 | NBD_FLAG_SEND_FUA | NBD_FLAG_SEND_CACHE); | ||
161 | + | ||
162 | + if (nbd_server_max_connections() != 1) { | ||
163 | + exp->nbdflags |= NBD_FLAG_CAN_MULTI_CONN; | ||
164 | + } | ||
165 | if (readonly) { | ||
166 | exp->nbdflags |= NBD_FLAG_READ_ONLY; | ||
167 | - if (shared) { | ||
168 | - exp->nbdflags |= NBD_FLAG_CAN_MULTI_CONN; | ||
169 | - } | ||
170 | } else { | ||
171 | exp->nbdflags |= (NBD_FLAG_SEND_TRIM | NBD_FLAG_SEND_WRITE_ZEROES | | ||
172 | NBD_FLAG_SEND_FAST_ZERO); | ||
173 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/MAINTAINERS | ||
176 | +++ b/MAINTAINERS | ||
177 | @@ -XXX,XX +XXX,XX @@ F: qemu-nbd.* | ||
178 | F: blockdev-nbd.c | ||
179 | F: docs/interop/nbd.txt | ||
180 | F: docs/tools/qemu-nbd.rst | ||
181 | +F: tests/qemu-iotests/tests/*nbd* | ||
182 | T: git https://repo.or.cz/qemu/ericb.git nbd | ||
183 | T: git https://src.openvz.org/scm/~vsementsov/qemu.git nbd | ||
184 | |||
185 | diff --git a/tests/qemu-iotests/tests/nbd-multiconn b/tests/qemu-iotests/tests/nbd-multiconn | ||
16 | new file mode 100755 | 186 | new file mode 100755 |
17 | index XXXXXXX..XXXXXXX | 187 | index XXXXXXX..XXXXXXX |
18 | --- /dev/null | 188 | --- /dev/null |
19 | +++ b/tests/qemu-iotests/127 | 189 | +++ b/tests/qemu-iotests/tests/nbd-multiconn |
20 | @@ -XXX,XX +XXX,XX @@ | 190 | @@ -XXX,XX +XXX,XX @@ |
21 | +#!/bin/bash | 191 | +#!/usr/bin/env python3 |
22 | +# | 192 | +# group: rw auto quick |
23 | +# Test case for mirroring with dataplane | 193 | +# |
24 | +# | 194 | +# Test cases for NBD multi-conn advertisement |
25 | +# Copyright (C) 2017 Red Hat, Inc. | 195 | +# |
196 | +# Copyright (C) 2022 Red Hat, Inc. | ||
26 | +# | 197 | +# |
27 | +# This program is free software; you can redistribute it and/or modify | 198 | +# This program is free software; you can redistribute it and/or modify |
28 | +# it under the terms of the GNU General Public License as published by | 199 | +# it under the terms of the GNU General Public License as published by |
29 | +# the Free Software Foundation; either version 2 of the License, or | 200 | +# the Free Software Foundation; either version 2 of the License, or |
30 | +# (at your option) any later version. | 201 | +# (at your option) any later version. |
... | ... | ||
34 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 205 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
35 | +# GNU General Public License for more details. | 206 | +# GNU General Public License for more details. |
36 | +# | 207 | +# |
37 | +# You should have received a copy of the GNU General Public License | 208 | +# You should have received a copy of the GNU General Public License |
38 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | 209 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
39 | +# | 210 | + |
40 | + | 211 | +import os |
41 | +# creator | 212 | +from contextlib import contextmanager |
42 | +owner=mreitz@redhat.com | 213 | +import iotests |
43 | + | 214 | +from iotests import qemu_img_create, qemu_io |
44 | +seq=$(basename $0) | 215 | + |
45 | +echo "QA output created by $seq" | 216 | + |
46 | + | 217 | +disk = os.path.join(iotests.test_dir, 'disk') |
47 | +here=$PWD | 218 | +size = '4M' |
48 | +status=1 # failure is the default! | 219 | +nbd_sock = os.path.join(iotests.sock_dir, 'nbd_sock') |
49 | + | 220 | +nbd_uri = 'nbd+unix:///{}?socket=' + nbd_sock |
50 | +_cleanup() | 221 | + |
51 | +{ | 222 | + |
52 | + _cleanup_qemu | 223 | +@contextmanager |
53 | + _cleanup_test_img | 224 | +def open_nbd(export_name): |
54 | + _rm_test_img "$TEST_IMG.overlay0" | 225 | + h = nbd.NBD() |
55 | + _rm_test_img "$TEST_IMG.overlay1" | 226 | + try: |
56 | +} | 227 | + h.connect_uri(nbd_uri.format(export_name)) |
57 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | 228 | + yield h |
58 | + | 229 | + finally: |
59 | +# get standard environment, filters and qemu instance handling | 230 | + h.shutdown() |
60 | +. ./common.rc | 231 | + |
61 | +. ./common.filter | 232 | +class TestNbdMulticonn(iotests.QMPTestCase): |
62 | +. ./common.qemu | 233 | + def setUp(self): |
63 | + | 234 | + qemu_img_create('-f', iotests.imgfmt, disk, size) |
64 | +_supported_fmt qcow2 | 235 | + qemu_io('-c', 'w -P 1 0 2M', '-c', 'w -P 2 2M 2M', disk) |
65 | +_supported_proto file | 236 | + |
66 | +_supported_os Linux | 237 | + self.vm = iotests.VM() |
67 | + | 238 | + self.vm.launch() |
68 | +IMG_SIZE=64K | 239 | + result = self.vm.qmp('blockdev-add', { |
69 | + | 240 | + 'driver': 'qcow2', |
70 | +_make_test_img $IMG_SIZE | 241 | + 'node-name': 'n', |
71 | +TEST_IMG="$TEST_IMG.overlay0" _make_test_img -b "$TEST_IMG" $IMG_SIZE | 242 | + 'file': {'driver': 'file', 'filename': disk} |
72 | +TEST_IMG="$TEST_IMG.overlay1" _make_test_img -b "$TEST_IMG" $IMG_SIZE | 243 | + }) |
73 | + | 244 | + self.assert_qmp(result, 'return', {}) |
74 | +# So that we actually have something to mirror and the job does not return | 245 | + |
75 | +# immediately (which may be bad because then we cannot know whether the | 246 | + def tearDown(self): |
76 | +# 'return' or the 'BLOCK_JOB_READY' comes first). | 247 | + self.vm.shutdown() |
77 | +$QEMU_IO -c 'write 0 42' "$TEST_IMG.overlay0" | _filter_qemu_io | 248 | + os.remove(disk) |
78 | + | 249 | + try: |
79 | +# We cannot use virtio-blk here because that does not actually set the attached | 250 | + os.remove(nbd_sock) |
80 | +# BB's AioContext in qtest mode | 251 | + except OSError: |
81 | +_launch_qemu \ | 252 | + pass |
82 | + -object iothread,id=iothr \ | 253 | + |
83 | + -blockdev node-name=source,driver=$IMGFMT,file.driver=file,file.filename="$TEST_IMG.overlay0" \ | 254 | + @contextmanager |
84 | + -device virtio-scsi,id=scsi-bus,iothread=iothr \ | 255 | + def run_server(self, max_connections=None): |
85 | + -device scsi-hd,bus=scsi-bus.0,drive=source | 256 | + args = { |
86 | + | 257 | + 'addr': { |
87 | +_send_qemu_cmd $QEMU_HANDLE \ | 258 | + 'type': 'unix', |
88 | + "{ 'execute': 'qmp_capabilities' }" \ | 259 | + 'data': {'path': nbd_sock} |
89 | + 'return' | 260 | + } |
90 | + | 261 | + } |
91 | +_send_qemu_cmd $QEMU_HANDLE \ | 262 | + if max_connections is not None: |
92 | + "{ 'execute': 'drive-mirror', | 263 | + args['max-connections'] = max_connections |
93 | + 'arguments': { | 264 | + |
94 | + 'job-id': 'mirror', | 265 | + result = self.vm.qmp('nbd-server-start', args) |
95 | + 'device': 'source', | 266 | + self.assert_qmp(result, 'return', {}) |
96 | + 'target': '$TEST_IMG.overlay1', | 267 | + yield |
97 | + 'mode': 'existing', | 268 | + |
98 | + 'sync': 'top' | 269 | + result = self.vm.qmp('nbd-server-stop') |
99 | + } }" \ | 270 | + self.assert_qmp(result, 'return', {}) |
100 | + 'BLOCK_JOB_READY' | 271 | + |
101 | + | 272 | + def add_export(self, name, writable=None): |
102 | +# The backing BDS should be assigned the overlay's AioContext | 273 | + args = { |
103 | +_send_qemu_cmd $QEMU_HANDLE \ | 274 | + 'type': 'nbd', |
104 | + "{ 'execute': 'block-job-complete', | 275 | + 'id': name, |
105 | + 'arguments': { 'device': 'mirror' } }" \ | 276 | + 'node-name': 'n', |
106 | + 'BLOCK_JOB_COMPLETED' | 277 | + 'name': name, |
107 | + | 278 | + } |
108 | +_send_qemu_cmd $QEMU_HANDLE \ | 279 | + if writable is not None: |
109 | + "{ 'execute': 'quit' }" \ | 280 | + args['writable'] = writable |
110 | + 'return' | 281 | + |
111 | + | 282 | + result = self.vm.qmp('block-export-add', args) |
112 | +wait=yes _cleanup_qemu | 283 | + self.assert_qmp(result, 'return', {}) |
113 | + | 284 | + |
114 | +# success, all done | 285 | + def test_default_settings(self): |
115 | +echo '*** done' | 286 | + with self.run_server(): |
116 | +rm -f $seq.full | 287 | + self.add_export('r') |
117 | +status=0 | 288 | + self.add_export('w', writable=True) |
118 | diff --git a/tests/qemu-iotests/127.out b/tests/qemu-iotests/127.out | 289 | + with open_nbd('r') as h: |
290 | + self.assertTrue(h.can_multi_conn()) | ||
291 | + with open_nbd('w') as h: | ||
292 | + self.assertTrue(h.can_multi_conn()) | ||
293 | + | ||
294 | + def test_limited_connections(self): | ||
295 | + with self.run_server(max_connections=1): | ||
296 | + self.add_export('r') | ||
297 | + self.add_export('w', writable=True) | ||
298 | + with open_nbd('r') as h: | ||
299 | + self.assertFalse(h.can_multi_conn()) | ||
300 | + with open_nbd('w') as h: | ||
301 | + self.assertFalse(h.can_multi_conn()) | ||
302 | + | ||
303 | + def test_parallel_writes(self): | ||
304 | + with self.run_server(): | ||
305 | + self.add_export('w', writable=True) | ||
306 | + | ||
307 | + clients = [nbd.NBD() for _ in range(3)] | ||
308 | + for c in clients: | ||
309 | + c.connect_uri(nbd_uri.format('w')) | ||
310 | + self.assertTrue(c.can_multi_conn()) | ||
311 | + | ||
312 | + initial_data = clients[0].pread(1024 * 1024, 0) | ||
313 | + self.assertEqual(initial_data, b'\x01' * 1024 * 1024) | ||
314 | + | ||
315 | + updated_data = b'\x03' * 1024 * 1024 | ||
316 | + clients[1].pwrite(updated_data, 0) | ||
317 | + clients[2].flush() | ||
318 | + current_data = clients[0].pread(1024 * 1024, 0) | ||
319 | + | ||
320 | + self.assertEqual(updated_data, current_data) | ||
321 | + | ||
322 | + for i in range(3): | ||
323 | + clients[i].shutdown() | ||
324 | + | ||
325 | + | ||
326 | +if __name__ == '__main__': | ||
327 | + try: | ||
328 | + # Easier to use libnbd than to try and set up parallel | ||
329 | + # 'qemu-nbd --list' or 'qemu-io' processes, but not all systems | ||
330 | + # have libnbd installed. | ||
331 | + import nbd # type: ignore | ||
332 | + | ||
333 | + iotests.main(supported_fmts=['qcow2']) | ||
334 | + except ImportError: | ||
335 | + iotests.notrun('libnbd not installed') | ||
336 | diff --git a/tests/qemu-iotests/tests/nbd-multiconn.out b/tests/qemu-iotests/tests/nbd-multiconn.out | ||
119 | new file mode 100644 | 337 | new file mode 100644 |
120 | index XXXXXXX..XXXXXXX | 338 | index XXXXXXX..XXXXXXX |
121 | --- /dev/null | 339 | --- /dev/null |
122 | +++ b/tests/qemu-iotests/127.out | 340 | +++ b/tests/qemu-iotests/tests/nbd-multiconn.out |
123 | @@ -XXX,XX +XXX,XX @@ | 341 | @@ -XXX,XX +XXX,XX @@ |
124 | +QA output created by 127 | 342 | +... |
125 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536 | 343 | +---------------------------------------------------------------------- |
126 | +Formatting 'TEST_DIR/t.IMGFMT.overlay0', fmt=IMGFMT size=65536 backing_file=TEST_DIR/t.IMGFMT | 344 | +Ran 3 tests |
127 | +Formatting 'TEST_DIR/t.IMGFMT.overlay1', fmt=IMGFMT size=65536 backing_file=TEST_DIR/t.IMGFMT | 345 | + |
128 | +wrote 42/42 bytes at offset 0 | 346 | +OK |
129 | +42 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 347 | diff --git a/tests/qemu-iotests/tests/nbd-qemu-allocation.out b/tests/qemu-iotests/tests/nbd-qemu-allocation.out |
130 | +{"return": {}} | 348 | index XXXXXXX..XXXXXXX 100644 |
131 | +{"return": {}} | 349 | --- a/tests/qemu-iotests/tests/nbd-qemu-allocation.out |
132 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "mirror", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} | 350 | +++ b/tests/qemu-iotests/tests/nbd-qemu-allocation.out |
133 | +{"return": {}} | 351 | @@ -XXX,XX +XXX,XX @@ wrote 2097152/2097152 bytes at offset 1048576 |
134 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "mirror", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} | 352 | exports available: 1 |
135 | +{"return": {}} | 353 | export: '' |
136 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | 354 | size: 4194304 |
137 | +*** done | 355 | - flags: 0x58f ( readonly flush fua df multi cache ) |
138 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | 356 | + flags: 0x48f ( readonly flush fua df cache ) |
139 | index XXXXXXX..XXXXXXX 100644 | 357 | min block: 1 |
140 | --- a/tests/qemu-iotests/group | 358 | opt block: 4096 |
141 | +++ b/tests/qemu-iotests/group | 359 | max block: 33554432 |
142 | @@ -XXX,XX +XXX,XX @@ | ||
143 | 124 rw auto backing | ||
144 | 125 rw auto | ||
145 | 126 rw auto backing | ||
146 | +127 rw auto backing quick | ||
147 | 128 rw auto quick | ||
148 | 129 rw auto quick | ||
149 | 130 rw auto quick | ||
150 | -- | 360 | -- |
151 | 2.13.6 | 361 | 2.35.3 |
152 | |||
153 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Paolo Bonzini <pbonzini@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Not all callers care about which BDS owns the mapping for a given | 3 | common.rc has some complicated logic to find the common.config that |
4 | range of the file. This patch merely simplifies the callers by | 4 | dates back to xfstests and is completely unnecessary now. Just include |
5 | consolidating the logic in the common call point, while guaranteeing | 5 | the contents of the file. |
6 | a non-NULL file to all the driver callbacks, for no semantic change. | ||
7 | The only caller that does not care about pnum is bdrv_is_allocated, | ||
8 | as invoked by vvfat; we can likewise add assertions that the rest | ||
9 | of the stack does not have to worry about a NULL pnum. | ||
10 | 6 | ||
11 | Furthermore, this will also set the stage for a future cleanup: when | 7 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
12 | a caller does not care about which BDS owns an offset, it would be | 8 | Message-Id: <20220505094723.732116-1-pbonzini@redhat.com> |
13 | nice to allow the driver to optimize things to not have to return | ||
14 | BDRV_BLOCK_OFFSET_VALID in the first place. In the case of fragmented | ||
15 | allocation (for example, it's fairly easy to create a qcow2 image | ||
16 | where consecutive guest addresses are not at consecutive host | ||
17 | addresses), the current contract requires bdrv_get_block_status() | ||
18 | to clamp *pnum to the limit where host addresses are no longer | ||
19 | consecutive, but allowing a NULL file means that *pnum could be | ||
20 | set to the full length of known-allocated data. | ||
21 | |||
22 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
23 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
24 | --- | 10 | --- |
25 | include/block/block_int.h | 10 ++++++---- | 11 | tests/qemu-iotests/common.config | 41 -------------------------------- |
26 | block/io.c | 49 ++++++++++++++++++++++++++--------------------- | 12 | tests/qemu-iotests/common.rc | 31 ++++++++++++++---------- |
27 | block/mirror.c | 3 +-- | 13 | 2 files changed, 19 insertions(+), 53 deletions(-) |
28 | block/qcow2.c | 8 ++------ | 14 | delete mode 100644 tests/qemu-iotests/common.config |
29 | qemu-img.c | 10 ++++------ | ||
30 | 5 files changed, 40 insertions(+), 40 deletions(-) | ||
31 | 15 | ||
32 | diff --git a/include/block/block_int.h b/include/block/block_int.h | 16 | diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config |
17 | deleted file mode 100644 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- a/tests/qemu-iotests/common.config | ||
20 | +++ /dev/null | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | -#!/usr/bin/env bash | ||
23 | -# | ||
24 | -# Copyright (C) 2009 Red Hat, Inc. | ||
25 | -# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved. | ||
26 | -# | ||
27 | -# This program is free software; you can redistribute it and/or | ||
28 | -# modify it under the terms of the GNU General Public License as | ||
29 | -# published by the Free Software Foundation. | ||
30 | -# | ||
31 | -# This program is distributed in the hope that it would be useful, | ||
32 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
33 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
34 | -# GNU General Public License for more details. | ||
35 | -# | ||
36 | -# You should have received a copy of the GNU General Public License | ||
37 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
38 | -# | ||
39 | -# all tests should use a common language setting to prevent golden | ||
40 | -# output mismatches. | ||
41 | -export LANG=C | ||
42 | - | ||
43 | -PATH=".:$PATH" | ||
44 | - | ||
45 | -HOSTOS=$(uname -s) | ||
46 | -arch=$(uname -m) | ||
47 | -[[ "$arch" =~ "ppc64" ]] && qemu_arch=ppc64 || qemu_arch="$arch" | ||
48 | - | ||
49 | -# make sure we have a standard umask | ||
50 | -umask 022 | ||
51 | - | ||
52 | -_optstr_add() | ||
53 | -{ | ||
54 | - if [ -n "$1" ]; then | ||
55 | - echo "$1,$2" | ||
56 | - else | ||
57 | - echo "$2" | ||
58 | - fi | ||
59 | -} | ||
60 | - | ||
61 | -# make sure this script returns success | ||
62 | -true | ||
63 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
33 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/include/block/block_int.h | 65 | --- a/tests/qemu-iotests/common.rc |
35 | +++ b/include/block/block_int.h | 66 | +++ b/tests/qemu-iotests/common.rc |
36 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | 67 | @@ -XXX,XX +XXX,XX @@ |
37 | int64_t offset, int bytes); | 68 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
38 | 69 | # | |
39 | /* | 70 | |
40 | - * Building block for bdrv_block_status[_above]. The driver should | 71 | +export LANG=C |
41 | - * answer only according to the current layer, and should not | 72 | + |
42 | - * set BDRV_BLOCK_ALLOCATED, but may set BDRV_BLOCK_RAW. See block.h | 73 | +PATH=".:$PATH" |
43 | - * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. | 74 | + |
44 | + * Building block for bdrv_block_status[_above] and | 75 | +HOSTOS=$(uname -s) |
45 | + * bdrv_is_allocated[_above]. The driver should answer only | 76 | +arch=$(uname -m) |
46 | + * according to the current layer, and should not set | 77 | +[[ "$arch" =~ "ppc64" ]] && qemu_arch=ppc64 || qemu_arch="$arch" |
47 | + * BDRV_BLOCK_ALLOCATED, but may set BDRV_BLOCK_RAW. See block.h | 78 | + |
48 | + * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. The block | 79 | +# make sure we have a standard umask |
49 | + * layer guarantees non-NULL pnum and file. | 80 | +umask 022 |
50 | */ | 81 | + |
51 | int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs, | 82 | # bail out, setting up .notrun file |
52 | int64_t sector_num, int nb_sectors, int *pnum, | 83 | _notrun() |
53 | diff --git a/block/io.c b/block/io.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/block/io.c | ||
56 | +++ b/block/io.c | ||
57 | @@ -XXX,XX +XXX,XX @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags) | ||
58 | { | 84 | { |
59 | int64_t target_sectors, ret, nb_sectors, sector_num = 0; | 85 | @@ -XXX,XX +XXX,XX @@ peek_file_raw() |
60 | BlockDriverState *bs = child->bs; | 86 | dd if="$1" bs=1 skip="$2" count="$3" status=none |
61 | - BlockDriverState *file; | ||
62 | int n; | ||
63 | |||
64 | target_sectors = bdrv_nb_sectors(bs); | ||
65 | @@ -XXX,XX +XXX,XX @@ int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags) | ||
66 | if (nb_sectors <= 0) { | ||
67 | return 0; | ||
68 | } | ||
69 | - ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &n, &file); | ||
70 | + ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &n, NULL); | ||
71 | if (ret < 0) { | ||
72 | error_report("error getting block status at sector %" PRId64 ": %s", | ||
73 | sector_num, strerror(-ret)); | ||
74 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs, | ||
75 | * beyond the end of the disk image it will be clamped; if 'pnum' is set to | ||
76 | * the end of the image, then the returned value will include BDRV_BLOCK_EOF. | ||
77 | * | ||
78 | - * If returned value is positive and BDRV_BLOCK_OFFSET_VALID bit is set, 'file' | ||
79 | - * points to the BDS which the sector range is allocated in. | ||
80 | + * If returned value is positive, BDRV_BLOCK_OFFSET_VALID bit is set, and | ||
81 | + * 'file' is non-NULL, then '*file' points to the BDS which the sector range | ||
82 | + * is allocated in. | ||
83 | */ | ||
84 | static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
85 | int64_t sector_num, | ||
86 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
87 | int64_t total_sectors; | ||
88 | int64_t n; | ||
89 | int64_t ret, ret2; | ||
90 | + BlockDriverState *local_file = NULL; | ||
91 | |||
92 | - *file = NULL; | ||
93 | + assert(pnum); | ||
94 | + *pnum = 0; | ||
95 | total_sectors = bdrv_nb_sectors(bs); | ||
96 | if (total_sectors < 0) { | ||
97 | - return total_sectors; | ||
98 | + ret = total_sectors; | ||
99 | + goto early_out; | ||
100 | } | ||
101 | |||
102 | if (sector_num >= total_sectors) { | ||
103 | - *pnum = 0; | ||
104 | - return BDRV_BLOCK_EOF; | ||
105 | + ret = BDRV_BLOCK_EOF; | ||
106 | + goto early_out; | ||
107 | } | ||
108 | if (!nb_sectors) { | ||
109 | - *pnum = 0; | ||
110 | - return 0; | ||
111 | + ret = 0; | ||
112 | + goto early_out; | ||
113 | } | ||
114 | |||
115 | n = total_sectors - sector_num; | ||
116 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
117 | } | ||
118 | if (bs->drv->protocol_name) { | ||
119 | ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE); | ||
120 | - *file = bs; | ||
121 | + local_file = bs; | ||
122 | } | ||
123 | - return ret; | ||
124 | + goto early_out; | ||
125 | } | ||
126 | |||
127 | bdrv_inc_in_flight(bs); | ||
128 | ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum, | ||
129 | - file); | ||
130 | + &local_file); | ||
131 | if (ret < 0) { | ||
132 | *pnum = 0; | ||
133 | goto out; | ||
134 | } | ||
135 | |||
136 | if (ret & BDRV_BLOCK_RAW) { | ||
137 | - assert(ret & BDRV_BLOCK_OFFSET_VALID && *file); | ||
138 | - ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, | ||
139 | - *pnum, pnum, file); | ||
140 | + assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file); | ||
141 | + ret = bdrv_co_get_block_status(local_file, ret >> BDRV_SECTOR_BITS, | ||
142 | + *pnum, pnum, &local_file); | ||
143 | goto out; | ||
144 | } | ||
145 | |||
146 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
147 | } | ||
148 | } | ||
149 | |||
150 | - if (*file && *file != bs && | ||
151 | + if (local_file && local_file != bs && | ||
152 | (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && | ||
153 | (ret & BDRV_BLOCK_OFFSET_VALID)) { | ||
154 | - BlockDriverState *file2; | ||
155 | int file_pnum; | ||
156 | |||
157 | - ret2 = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, | ||
158 | - *pnum, &file_pnum, &file2); | ||
159 | + ret2 = bdrv_co_get_block_status(local_file, ret >> BDRV_SECTOR_BITS, | ||
160 | + *pnum, &file_pnum, NULL); | ||
161 | if (ret2 >= 0) { | ||
162 | /* Ignore errors. This is just providing extra information, it | ||
163 | * is useful but not necessary. | ||
164 | @@ -XXX,XX +XXX,XX @@ out: | ||
165 | if (ret >= 0 && sector_num + *pnum == total_sectors) { | ||
166 | ret |= BDRV_BLOCK_EOF; | ||
167 | } | ||
168 | +early_out: | ||
169 | + if (file) { | ||
170 | + *file = local_file; | ||
171 | + } | ||
172 | return ret; | ||
173 | } | 87 | } |
174 | 88 | ||
175 | @@ -XXX,XX +XXX,XX @@ int64_t bdrv_get_block_status(BlockDriverState *bs, | 89 | -config=common.config |
176 | int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | 90 | -test -f $config || config=../common.config |
177 | int64_t bytes, int64_t *pnum) | 91 | -if ! test -f $config |
178 | { | 92 | -then |
179 | - BlockDriverState *file; | 93 | - echo "$0: failed to find common.config" |
180 | int64_t sector_num = offset >> BDRV_SECTOR_BITS; | 94 | - exit 1 |
181 | int nb_sectors = bytes >> BDRV_SECTOR_BITS; | 95 | -fi |
182 | int64_t ret; | 96 | -if ! . $config |
183 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | 97 | - then |
184 | assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); | 98 | - echo "$0: failed to source common.config" |
185 | assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE) && bytes < INT_MAX); | 99 | - exit 1 |
186 | ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &psectors, | 100 | -fi |
187 | - &file); | 101 | +_optstr_add() |
188 | + NULL); | 102 | +{ |
189 | if (ret < 0) { | 103 | + if [ -n "$1" ]; then |
190 | return ret; | 104 | + echo "$1,$2" |
191 | } | 105 | + else |
192 | diff --git a/block/mirror.c b/block/mirror.c | 106 | + echo "$2" |
193 | index XXXXXXX..XXXXXXX 100644 | 107 | + fi |
194 | --- a/block/mirror.c | 108 | +} |
195 | +++ b/block/mirror.c | 109 | |
196 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | 110 | # Set the variables to the empty string to turn Valgrind off |
197 | int io_sectors; | 111 | # for specific processes, e.g. |
198 | unsigned int io_bytes; | ||
199 | int64_t io_bytes_acct; | ||
200 | - BlockDriverState *file; | ||
201 | enum MirrorMethod { | ||
202 | MIRROR_METHOD_COPY, | ||
203 | MIRROR_METHOD_ZERO, | ||
204 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
205 | ret = bdrv_get_block_status_above(source, NULL, | ||
206 | offset >> BDRV_SECTOR_BITS, | ||
207 | nb_chunks * sectors_per_chunk, | ||
208 | - &io_sectors, &file); | ||
209 | + &io_sectors, NULL); | ||
210 | io_bytes = io_sectors * BDRV_SECTOR_SIZE; | ||
211 | if (ret < 0) { | ||
212 | io_bytes = MIN(nb_chunks * s->granularity, max_io_bytes); | ||
213 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
214 | index XXXXXXX..XXXXXXX 100644 | ||
215 | --- a/block/qcow2.c | ||
216 | +++ b/block/qcow2.c | ||
217 | @@ -XXX,XX +XXX,XX @@ static bool is_zero_sectors(BlockDriverState *bs, int64_t start, | ||
218 | uint32_t count) | ||
219 | { | ||
220 | int nr; | ||
221 | - BlockDriverState *file; | ||
222 | int64_t res; | ||
223 | |||
224 | if (start + count > bs->total_sectors) { | ||
225 | @@ -XXX,XX +XXX,XX @@ static bool is_zero_sectors(BlockDriverState *bs, int64_t start, | ||
226 | if (!count) { | ||
227 | return true; | ||
228 | } | ||
229 | - res = bdrv_get_block_status_above(bs, NULL, start, count, | ||
230 | - &nr, &file); | ||
231 | + res = bdrv_get_block_status_above(bs, NULL, start, count, &nr, NULL); | ||
232 | return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == count; | ||
233 | } | ||
234 | |||
235 | @@ -XXX,XX +XXX,XX @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs, | ||
236 | offset += pnum * BDRV_SECTOR_SIZE) { | ||
237 | int nb_sectors = MIN(ssize - offset, | ||
238 | BDRV_REQUEST_MAX_BYTES) / BDRV_SECTOR_SIZE; | ||
239 | - BlockDriverState *file; | ||
240 | int64_t ret; | ||
241 | |||
242 | ret = bdrv_get_block_status_above(in_bs, NULL, | ||
243 | offset >> BDRV_SECTOR_BITS, | ||
244 | - nb_sectors, | ||
245 | - &pnum, &file); | ||
246 | + nb_sectors, &pnum, NULL); | ||
247 | if (ret < 0) { | ||
248 | error_setg_errno(&local_err, -ret, | ||
249 | "Unable to get block status"); | ||
250 | diff --git a/qemu-img.c b/qemu-img.c | ||
251 | index XXXXXXX..XXXXXXX 100644 | ||
252 | --- a/qemu-img.c | ||
253 | +++ b/qemu-img.c | ||
254 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
255 | |||
256 | for (;;) { | ||
257 | int64_t status1, status2; | ||
258 | - BlockDriverState *file; | ||
259 | |||
260 | nb_sectors = sectors_to_process(total_sectors, sector_num); | ||
261 | if (nb_sectors <= 0) { | ||
262 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
263 | } | ||
264 | status1 = bdrv_get_block_status_above(bs1, NULL, sector_num, | ||
265 | total_sectors1 - sector_num, | ||
266 | - &pnum1, &file); | ||
267 | + &pnum1, NULL); | ||
268 | if (status1 < 0) { | ||
269 | ret = 3; | ||
270 | error_report("Sector allocation test failed for %s", filename1); | ||
271 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
272 | |||
273 | status2 = bdrv_get_block_status_above(bs2, NULL, sector_num, | ||
274 | total_sectors2 - sector_num, | ||
275 | - &pnum2, &file); | ||
276 | + &pnum2, NULL); | ||
277 | if (status2 < 0) { | ||
278 | ret = 3; | ||
279 | error_report("Sector allocation test failed for %s", filename2); | ||
280 | @@ -XXX,XX +XXX,XX @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) | ||
281 | n = MIN(s->total_sectors - sector_num, BDRV_REQUEST_MAX_SECTORS); | ||
282 | |||
283 | if (s->sector_next_status <= sector_num) { | ||
284 | - BlockDriverState *file; | ||
285 | if (s->target_has_backing) { | ||
286 | ret = bdrv_get_block_status(blk_bs(s->src[src_cur]), | ||
287 | sector_num - src_cur_offset, | ||
288 | - n, &n, &file); | ||
289 | + n, &n, NULL); | ||
290 | } else { | ||
291 | ret = bdrv_get_block_status_above(blk_bs(s->src[src_cur]), NULL, | ||
292 | sector_num - src_cur_offset, | ||
293 | - n, &n, &file); | ||
294 | + n, &n, NULL); | ||
295 | } | ||
296 | if (ret < 0) { | ||
297 | return ret; | ||
298 | -- | 112 | -- |
299 | 2.13.6 | 113 | 2.35.3 |
300 | |||
301 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | We are gradually converting to byte-based interfaces, as they are | ||
4 | easier to reason about than sector-based. Change the internal | ||
5 | loop iteration of zeroing a device to track by bytes instead of | ||
6 | sectors (although we are still guaranteed that we iterate by steps | ||
7 | that are sector-aligned). | ||
8 | |||
9 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
10 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
11 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
13 | --- | ||
14 | block/io.c | 32 ++++++++++++++++---------------- | ||
15 | 1 file changed, 16 insertions(+), 16 deletions(-) | ||
16 | |||
17 | diff --git a/block/io.c b/block/io.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/block/io.c | ||
20 | +++ b/block/io.c | ||
21 | @@ -XXX,XX +XXX,XX @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, | ||
22 | */ | ||
23 | int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags) | ||
24 | { | ||
25 | - int64_t target_sectors, ret, nb_sectors, sector_num = 0; | ||
26 | + int64_t target_size, ret, bytes, offset = 0; | ||
27 | BlockDriverState *bs = child->bs; | ||
28 | - int n; | ||
29 | + int n; /* sectors */ | ||
30 | |||
31 | - target_sectors = bdrv_nb_sectors(bs); | ||
32 | - if (target_sectors < 0) { | ||
33 | - return target_sectors; | ||
34 | + target_size = bdrv_getlength(bs); | ||
35 | + if (target_size < 0) { | ||
36 | + return target_size; | ||
37 | } | ||
38 | |||
39 | for (;;) { | ||
40 | - nb_sectors = MIN(target_sectors - sector_num, BDRV_REQUEST_MAX_SECTORS); | ||
41 | - if (nb_sectors <= 0) { | ||
42 | + bytes = MIN(target_size - offset, BDRV_REQUEST_MAX_BYTES); | ||
43 | + if (bytes <= 0) { | ||
44 | return 0; | ||
45 | } | ||
46 | - ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &n, NULL); | ||
47 | + ret = bdrv_get_block_status(bs, offset >> BDRV_SECTOR_BITS, | ||
48 | + bytes >> BDRV_SECTOR_BITS, &n, NULL); | ||
49 | if (ret < 0) { | ||
50 | - error_report("error getting block status at sector %" PRId64 ": %s", | ||
51 | - sector_num, strerror(-ret)); | ||
52 | + error_report("error getting block status at offset %" PRId64 ": %s", | ||
53 | + offset, strerror(-ret)); | ||
54 | return ret; | ||
55 | } | ||
56 | if (ret & BDRV_BLOCK_ZERO) { | ||
57 | - sector_num += n; | ||
58 | + offset += n * BDRV_SECTOR_BITS; | ||
59 | continue; | ||
60 | } | ||
61 | - ret = bdrv_pwrite_zeroes(child, sector_num << BDRV_SECTOR_BITS, | ||
62 | - n << BDRV_SECTOR_BITS, flags); | ||
63 | + ret = bdrv_pwrite_zeroes(child, offset, n * BDRV_SECTOR_SIZE, flags); | ||
64 | if (ret < 0) { | ||
65 | - error_report("error writing zeroes at sector %" PRId64 ": %s", | ||
66 | - sector_num, strerror(-ret)); | ||
67 | + error_report("error writing zeroes at offset %" PRId64 ": %s", | ||
68 | + offset, strerror(-ret)); | ||
69 | return ret; | ||
70 | } | ||
71 | - sector_num += n; | ||
72 | + offset += n * BDRV_SECTOR_SIZE; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | -- | ||
77 | 2.13.6 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | We are gradually converting to byte-based interfaces, as they are | ||
4 | easier to reason about than sector-based. Continue by converting | ||
5 | an internal function (no semantic change), and simplifying its | ||
6 | caller accordingly. | ||
7 | |||
8 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
9 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
10 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
11 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
12 | --- | ||
13 | qemu-img.c | 24 +++++++++++------------- | ||
14 | 1 file changed, 11 insertions(+), 13 deletions(-) | ||
15 | |||
16 | diff --git a/qemu-img.c b/qemu-img.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/qemu-img.c | ||
19 | +++ b/qemu-img.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void dump_map_entry(OutputFormat output_format, MapEntry *e, | ||
21 | } | ||
22 | } | ||
23 | |||
24 | -static int get_block_status(BlockDriverState *bs, int64_t sector_num, | ||
25 | - int nb_sectors, MapEntry *e) | ||
26 | +static int get_block_status(BlockDriverState *bs, int64_t offset, | ||
27 | + int64_t bytes, MapEntry *e) | ||
28 | { | ||
29 | int64_t ret; | ||
30 | int depth; | ||
31 | BlockDriverState *file; | ||
32 | bool has_offset; | ||
33 | + int nb_sectors = bytes >> BDRV_SECTOR_BITS; | ||
34 | |||
35 | + assert(bytes < INT_MAX); | ||
36 | /* As an optimization, we could cache the current range of unallocated | ||
37 | * clusters in each file of the chain, and avoid querying the same | ||
38 | * range repeatedly. | ||
39 | @@ -XXX,XX +XXX,XX @@ static int get_block_status(BlockDriverState *bs, int64_t sector_num, | ||
40 | |||
41 | depth = 0; | ||
42 | for (;;) { | ||
43 | - ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &nb_sectors, | ||
44 | - &file); | ||
45 | + ret = bdrv_get_block_status(bs, offset >> BDRV_SECTOR_BITS, nb_sectors, | ||
46 | + &nb_sectors, &file); | ||
47 | if (ret < 0) { | ||
48 | return ret; | ||
49 | } | ||
50 | @@ -XXX,XX +XXX,XX @@ static int get_block_status(BlockDriverState *bs, int64_t sector_num, | ||
51 | has_offset = !!(ret & BDRV_BLOCK_OFFSET_VALID); | ||
52 | |||
53 | *e = (MapEntry) { | ||
54 | - .start = sector_num * BDRV_SECTOR_SIZE, | ||
55 | + .start = offset, | ||
56 | .length = nb_sectors * BDRV_SECTOR_SIZE, | ||
57 | .data = !!(ret & BDRV_BLOCK_DATA), | ||
58 | .zero = !!(ret & BDRV_BLOCK_ZERO), | ||
59 | @@ -XXX,XX +XXX,XX @@ static int img_map(int argc, char **argv) | ||
60 | |||
61 | length = blk_getlength(blk); | ||
62 | while (curr.start + curr.length < length) { | ||
63 | - int64_t nsectors_left; | ||
64 | - int64_t sector_num; | ||
65 | - int n; | ||
66 | - | ||
67 | - sector_num = (curr.start + curr.length) >> BDRV_SECTOR_BITS; | ||
68 | + int64_t offset = curr.start + curr.length; | ||
69 | + int64_t n; | ||
70 | |||
71 | /* Probe up to 1 GiB at a time. */ | ||
72 | - nsectors_left = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE) - sector_num; | ||
73 | - n = MIN(1 << (30 - BDRV_SECTOR_BITS), nsectors_left); | ||
74 | - ret = get_block_status(bs, sector_num, n, &next); | ||
75 | + n = QEMU_ALIGN_DOWN(MIN(1 << 30, length - offset), BDRV_SECTOR_SIZE); | ||
76 | + ret = get_block_status(bs, offset, n, &next); | ||
77 | |||
78 | if (ret < 0) { | ||
79 | error_report("Could not read file metadata: %s", strerror(-ret)); | ||
80 | -- | ||
81 | 2.13.6 | ||
82 | |||
83 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | We are gradually converting to byte-based interfaces, as they are | ||
4 | easier to reason about than sector-based. Convert another internal | ||
5 | function (no semantic change); and as with its public counterpart, | ||
6 | rename to bdrv_co_block_status() and split the offset return, to | ||
7 | make the compiler enforce that we catch all uses. For now, we | ||
8 | assert that callers and the return value still use aligned data, | ||
9 | but ultimately, this will be the function where we hand off to a | ||
10 | byte-based driver callback, and will eventually need to add logic | ||
11 | to ensure we round calls according to the driver's | ||
12 | request_alignment then touch up the result handed back to the | ||
13 | caller, to start permitting a caller to pass unaligned offsets. | ||
14 | |||
15 | Note that we are now prepared to accepts 'bytes' larger than INT_MAX; | ||
16 | this is okay as long as we clamp things internally before violating | ||
17 | any 32-bit limits, and makes no difference to how a client will | ||
18 | use the information (clients looping over the entire file must | ||
19 | already be prepared for consecutive calls to return the same status, | ||
20 | as drivers are already free to return shorter-than-maximal status | ||
21 | due to any other convenient split points, such as when the L2 table | ||
22 | crosses cluster boundaries in qcow2). | ||
23 | |||
24 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
25 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
26 | --- | ||
27 | block/io.c | 124 ++++++++++++++++++++++++++++++++++++++++--------------------- | ||
28 | 1 file changed, 81 insertions(+), 43 deletions(-) | ||
29 | |||
30 | diff --git a/block/io.c b/block/io.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/block/io.c | ||
33 | +++ b/block/io.c | ||
34 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs, | ||
35 | * BDRV_BLOCK_ZERO where possible; otherwise, the result may omit those | ||
36 | * bits particularly if it allows for a larger value in 'pnum'. | ||
37 | * | ||
38 | - * If 'sector_num' is beyond the end of the disk image the return value is | ||
39 | + * If 'offset' is beyond the end of the disk image the return value is | ||
40 | * BDRV_BLOCK_EOF and 'pnum' is set to 0. | ||
41 | * | ||
42 | - * 'pnum' is set to the number of sectors (including and immediately following | ||
43 | - * the specified sector) that are known to be in the same | ||
44 | - * allocated/unallocated state. | ||
45 | - * | ||
46 | - * 'nb_sectors' is the max value 'pnum' should be set to. If nb_sectors goes | ||
47 | + * 'bytes' is the max value 'pnum' should be set to. If bytes goes | ||
48 | * beyond the end of the disk image it will be clamped; if 'pnum' is set to | ||
49 | * the end of the image, then the returned value will include BDRV_BLOCK_EOF. | ||
50 | * | ||
51 | - * If returned value is positive, BDRV_BLOCK_OFFSET_VALID bit is set, and | ||
52 | - * 'file' is non-NULL, then '*file' points to the BDS which the sector range | ||
53 | - * is allocated in. | ||
54 | + * 'pnum' is set to the number of bytes (including and immediately | ||
55 | + * following the specified offset) that are easily known to be in the | ||
56 | + * same allocated/unallocated state. Note that a second call starting | ||
57 | + * at the original offset plus returned pnum may have the same status. | ||
58 | + * The returned value is non-zero on success except at end-of-file. | ||
59 | + * | ||
60 | + * Returns negative errno on failure. Otherwise, if the | ||
61 | + * BDRV_BLOCK_OFFSET_VALID bit is set, 'map' and 'file' (if non-NULL) are | ||
62 | + * set to the host mapping and BDS corresponding to the guest offset. | ||
63 | */ | ||
64 | -static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
65 | - bool want_zero, | ||
66 | - int64_t sector_num, | ||
67 | - int nb_sectors, int *pnum, | ||
68 | - BlockDriverState **file) | ||
69 | -{ | ||
70 | - int64_t total_sectors; | ||
71 | - int64_t n; | ||
72 | - int64_t ret, ret2; | ||
73 | +static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, | ||
74 | + bool want_zero, | ||
75 | + int64_t offset, int64_t bytes, | ||
76 | + int64_t *pnum, int64_t *map, | ||
77 | + BlockDriverState **file) | ||
78 | +{ | ||
79 | + int64_t total_size; | ||
80 | + int64_t n; /* bytes */ | ||
81 | + int64_t ret; | ||
82 | + int64_t local_map = 0; | ||
83 | BlockDriverState *local_file = NULL; | ||
84 | + int count; /* sectors */ | ||
85 | |||
86 | assert(pnum); | ||
87 | *pnum = 0; | ||
88 | - total_sectors = bdrv_nb_sectors(bs); | ||
89 | - if (total_sectors < 0) { | ||
90 | - ret = total_sectors; | ||
91 | + total_size = bdrv_getlength(bs); | ||
92 | + if (total_size < 0) { | ||
93 | + ret = total_size; | ||
94 | goto early_out; | ||
95 | } | ||
96 | |||
97 | - if (sector_num >= total_sectors) { | ||
98 | + if (offset >= total_size) { | ||
99 | ret = BDRV_BLOCK_EOF; | ||
100 | goto early_out; | ||
101 | } | ||
102 | - if (!nb_sectors) { | ||
103 | + if (!bytes) { | ||
104 | ret = 0; | ||
105 | goto early_out; | ||
106 | } | ||
107 | |||
108 | - n = total_sectors - sector_num; | ||
109 | - if (n < nb_sectors) { | ||
110 | - nb_sectors = n; | ||
111 | + n = total_size - offset; | ||
112 | + if (n < bytes) { | ||
113 | + bytes = n; | ||
114 | } | ||
115 | |||
116 | if (!bs->drv->bdrv_co_get_block_status) { | ||
117 | - *pnum = nb_sectors; | ||
118 | + *pnum = bytes; | ||
119 | ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED; | ||
120 | - if (sector_num + nb_sectors == total_sectors) { | ||
121 | + if (offset + bytes == total_size) { | ||
122 | ret |= BDRV_BLOCK_EOF; | ||
123 | } | ||
124 | if (bs->drv->protocol_name) { | ||
125 | - ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE); | ||
126 | + ret |= BDRV_BLOCK_OFFSET_VALID; | ||
127 | + local_map = offset; | ||
128 | local_file = bs; | ||
129 | } | ||
130 | goto early_out; | ||
131 | } | ||
132 | |||
133 | bdrv_inc_in_flight(bs); | ||
134 | - ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum, | ||
135 | + /* | ||
136 | + * TODO: Rather than require aligned offsets, we could instead | ||
137 | + * round to the driver's request_alignment here, then touch up | ||
138 | + * count afterwards back to the caller's expectations. | ||
139 | + */ | ||
140 | + assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); | ||
141 | + /* | ||
142 | + * The contract allows us to return pnum smaller than bytes, even | ||
143 | + * if the next query would see the same status; we truncate the | ||
144 | + * request to avoid overflowing the driver's 32-bit interface. | ||
145 | + */ | ||
146 | + bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES); | ||
147 | + ret = bs->drv->bdrv_co_get_block_status(bs, offset >> BDRV_SECTOR_BITS, | ||
148 | + bytes >> BDRV_SECTOR_BITS, &count, | ||
149 | &local_file); | ||
150 | if (ret < 0) { | ||
151 | - *pnum = 0; | ||
152 | goto out; | ||
153 | } | ||
154 | + if (ret & BDRV_BLOCK_OFFSET_VALID) { | ||
155 | + local_map = ret & BDRV_BLOCK_OFFSET_MASK; | ||
156 | + } | ||
157 | + *pnum = count * BDRV_SECTOR_SIZE; | ||
158 | |||
159 | if (ret & BDRV_BLOCK_RAW) { | ||
160 | assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file); | ||
161 | - ret = bdrv_co_get_block_status(local_file, want_zero, | ||
162 | - ret >> BDRV_SECTOR_BITS, | ||
163 | - *pnum, pnum, &local_file); | ||
164 | + ret = bdrv_co_block_status(local_file, want_zero, local_map, | ||
165 | + *pnum, pnum, &local_map, &local_file); | ||
166 | + assert(ret < 0 || | ||
167 | + QEMU_IS_ALIGNED(*pnum | local_map, BDRV_SECTOR_SIZE)); | ||
168 | goto out; | ||
169 | } | ||
170 | |||
171 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
172 | ret |= BDRV_BLOCK_ZERO; | ||
173 | } else if (bs->backing) { | ||
174 | BlockDriverState *bs2 = bs->backing->bs; | ||
175 | - int64_t nb_sectors2 = bdrv_nb_sectors(bs2); | ||
176 | + int64_t size2 = bdrv_getlength(bs2); | ||
177 | |||
178 | - if (nb_sectors2 >= 0 && sector_num >= nb_sectors2) { | ||
179 | + if (size2 >= 0 && offset >= size2) { | ||
180 | ret |= BDRV_BLOCK_ZERO; | ||
181 | } | ||
182 | } | ||
183 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
184 | if (want_zero && local_file && local_file != bs && | ||
185 | (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && | ||
186 | (ret & BDRV_BLOCK_OFFSET_VALID)) { | ||
187 | - int file_pnum; | ||
188 | + int64_t file_pnum; | ||
189 | + int ret2; | ||
190 | |||
191 | - ret2 = bdrv_co_get_block_status(local_file, want_zero, | ||
192 | - ret >> BDRV_SECTOR_BITS, | ||
193 | - *pnum, &file_pnum, NULL); | ||
194 | + ret2 = bdrv_co_block_status(local_file, want_zero, local_map, | ||
195 | + *pnum, &file_pnum, NULL, NULL); | ||
196 | if (ret2 >= 0) { | ||
197 | /* Ignore errors. This is just providing extra information, it | ||
198 | * is useful but not necessary. | ||
199 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
200 | |||
201 | out: | ||
202 | bdrv_dec_in_flight(bs); | ||
203 | - if (ret >= 0 && sector_num + *pnum == total_sectors) { | ||
204 | + if (ret >= 0 && offset + *pnum == total_size) { | ||
205 | ret |= BDRV_BLOCK_EOF; | ||
206 | } | ||
207 | early_out: | ||
208 | if (file) { | ||
209 | *file = local_file; | ||
210 | } | ||
211 | + if (map) { | ||
212 | + *map = local_map; | ||
213 | + } | ||
214 | + if (ret >= 0) { | ||
215 | + ret &= ~BDRV_BLOCK_OFFSET_MASK; | ||
216 | + } else { | ||
217 | + assert(INT_MIN <= ret); | ||
218 | + } | ||
219 | return ret; | ||
220 | } | ||
221 | |||
222 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | ||
223 | BlockDriverState *p; | ||
224 | int64_t ret = 0; | ||
225 | bool first = true; | ||
226 | + int64_t map = 0; | ||
227 | |||
228 | assert(bs != base); | ||
229 | for (p = bs; p != base; p = backing_bs(p)) { | ||
230 | - ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors, | ||
231 | - pnum, file); | ||
232 | + int64_t count; | ||
233 | + | ||
234 | + ret = bdrv_co_block_status(p, want_zero, | ||
235 | + sector_num * BDRV_SECTOR_SIZE, | ||
236 | + nb_sectors * BDRV_SECTOR_SIZE, &count, | ||
237 | + &map, file); | ||
238 | if (ret < 0) { | ||
239 | break; | ||
240 | } | ||
241 | + assert(QEMU_IS_ALIGNED(count | map, BDRV_SECTOR_SIZE)); | ||
242 | + ret |= map; | ||
243 | + *pnum = count >> BDRV_SECTOR_BITS; | ||
244 | if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) { | ||
245 | /* | ||
246 | * Reading beyond the end of the file continues to read | ||
247 | -- | ||
248 | 2.13.6 | ||
249 | |||
250 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | We are gradually converting to byte-based interfaces, as they are | ||
4 | easier to reason about than sector-based. Convert another internal | ||
5 | type (no semantic change), and rename it to match the corresponding | ||
6 | public function rename. | ||
7 | |||
8 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | --- | ||
11 | block/io.c | 56 ++++++++++++++++++++++++++++++++++++++------------------ | ||
12 | 1 file changed, 38 insertions(+), 18 deletions(-) | ||
13 | |||
14 | diff --git a/block/io.c b/block/io.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/io.c | ||
17 | +++ b/block/io.c | ||
18 | @@ -XXX,XX +XXX,XX @@ int bdrv_flush_all(void) | ||
19 | } | ||
20 | |||
21 | |||
22 | -typedef struct BdrvCoGetBlockStatusData { | ||
23 | +typedef struct BdrvCoBlockStatusData { | ||
24 | BlockDriverState *bs; | ||
25 | BlockDriverState *base; | ||
26 | bool want_zero; | ||
27 | - int64_t sector_num; | ||
28 | - int nb_sectors; | ||
29 | - int *pnum; | ||
30 | + int64_t offset; | ||
31 | + int64_t bytes; | ||
32 | + int64_t *pnum; | ||
33 | + int64_t *map; | ||
34 | BlockDriverState **file; | ||
35 | - int64_t ret; | ||
36 | + int ret; | ||
37 | bool done; | ||
38 | -} BdrvCoGetBlockStatusData; | ||
39 | +} BdrvCoBlockStatusData; | ||
40 | |||
41 | int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs, | ||
42 | int64_t sector_num, | ||
43 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | ||
44 | /* Coroutine wrapper for bdrv_get_block_status_above() */ | ||
45 | static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) | ||
46 | { | ||
47 | - BdrvCoGetBlockStatusData *data = opaque; | ||
48 | + BdrvCoBlockStatusData *data = opaque; | ||
49 | + int n = 0; | ||
50 | + int64_t ret; | ||
51 | |||
52 | - data->ret = bdrv_co_get_block_status_above(data->bs, data->base, | ||
53 | - data->want_zero, | ||
54 | - data->sector_num, | ||
55 | - data->nb_sectors, | ||
56 | - data->pnum, | ||
57 | - data->file); | ||
58 | + ret = bdrv_co_get_block_status_above(data->bs, data->base, | ||
59 | + data->want_zero, | ||
60 | + data->offset >> BDRV_SECTOR_BITS, | ||
61 | + data->bytes >> BDRV_SECTOR_BITS, | ||
62 | + &n, | ||
63 | + data->file); | ||
64 | + if (ret < 0) { | ||
65 | + assert(INT_MIN <= ret); | ||
66 | + data->ret = ret; | ||
67 | + } else { | ||
68 | + *data->pnum = n * BDRV_SECTOR_SIZE; | ||
69 | + *data->map = ret & BDRV_BLOCK_OFFSET_MASK; | ||
70 | + data->ret = ret & ~BDRV_BLOCK_OFFSET_MASK; | ||
71 | + } | ||
72 | data->done = true; | ||
73 | } | ||
74 | |||
75 | @@ -XXX,XX +XXX,XX @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs, | ||
76 | BlockDriverState **file) | ||
77 | { | ||
78 | Coroutine *co; | ||
79 | - BdrvCoGetBlockStatusData data = { | ||
80 | + int64_t n; | ||
81 | + int64_t map; | ||
82 | + BdrvCoBlockStatusData data = { | ||
83 | .bs = bs, | ||
84 | .base = base, | ||
85 | .want_zero = want_zero, | ||
86 | - .sector_num = sector_num, | ||
87 | - .nb_sectors = nb_sectors, | ||
88 | - .pnum = pnum, | ||
89 | + .offset = sector_num * BDRV_SECTOR_SIZE, | ||
90 | + .bytes = nb_sectors * BDRV_SECTOR_SIZE, | ||
91 | + .pnum = &n, | ||
92 | + .map = &map, | ||
93 | .file = file, | ||
94 | .done = false, | ||
95 | }; | ||
96 | @@ -XXX,XX +XXX,XX @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs, | ||
97 | bdrv_coroutine_enter(bs, co); | ||
98 | BDRV_POLL_WHILE(bs, !data.done); | ||
99 | } | ||
100 | - return data.ret; | ||
101 | + if (data.ret < 0) { | ||
102 | + *pnum = 0; | ||
103 | + return data.ret; | ||
104 | + } | ||
105 | + assert(QEMU_IS_ALIGNED(n | map, BDRV_SECTOR_SIZE)); | ||
106 | + *pnum = n >> BDRV_SECTOR_BITS; | ||
107 | + return data.ret | map; | ||
108 | } | ||
109 | |||
110 | int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
111 | -- | ||
112 | 2.13.6 | ||
113 | |||
114 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | We are gradually converting to byte-based interfaces, as they are | ||
4 | easier to reason about than sector-based. Convert another internal | ||
5 | function (no semantic change). | ||
6 | |||
7 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | block/io.c | 61 ++++++++++++++++++++++++++++++------------------------------- | ||
11 | 1 file changed, 30 insertions(+), 31 deletions(-) | ||
12 | |||
13 | diff --git a/block/io.c b/block/io.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/block/io.c | ||
16 | +++ b/block/io.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) | ||
18 | * | ||
19 | * See bdrv_co_get_block_status_above() for details. | ||
20 | */ | ||
21 | -static int64_t bdrv_common_block_status_above(BlockDriverState *bs, | ||
22 | - BlockDriverState *base, | ||
23 | - bool want_zero, | ||
24 | - int64_t sector_num, | ||
25 | - int nb_sectors, int *pnum, | ||
26 | - BlockDriverState **file) | ||
27 | +static int bdrv_common_block_status_above(BlockDriverState *bs, | ||
28 | + BlockDriverState *base, | ||
29 | + bool want_zero, int64_t offset, | ||
30 | + int64_t bytes, int64_t *pnum, | ||
31 | + int64_t *map, | ||
32 | + BlockDriverState **file) | ||
33 | { | ||
34 | Coroutine *co; | ||
35 | - int64_t n; | ||
36 | - int64_t map; | ||
37 | BdrvCoBlockStatusData data = { | ||
38 | .bs = bs, | ||
39 | .base = base, | ||
40 | .want_zero = want_zero, | ||
41 | - .offset = sector_num * BDRV_SECTOR_SIZE, | ||
42 | - .bytes = nb_sectors * BDRV_SECTOR_SIZE, | ||
43 | - .pnum = &n, | ||
44 | - .map = &map, | ||
45 | + .offset = offset, | ||
46 | + .bytes = bytes, | ||
47 | + .pnum = pnum, | ||
48 | + .map = map, | ||
49 | .file = file, | ||
50 | .done = false, | ||
51 | }; | ||
52 | @@ -XXX,XX +XXX,XX @@ static int64_t bdrv_common_block_status_above(BlockDriverState *bs, | ||
53 | bdrv_coroutine_enter(bs, co); | ||
54 | BDRV_POLL_WHILE(bs, !data.done); | ||
55 | } | ||
56 | - if (data.ret < 0) { | ||
57 | - *pnum = 0; | ||
58 | - return data.ret; | ||
59 | - } | ||
60 | - assert(QEMU_IS_ALIGNED(n | map, BDRV_SECTOR_SIZE)); | ||
61 | - *pnum = n >> BDRV_SECTOR_BITS; | ||
62 | - return data.ret | map; | ||
63 | + return data.ret; | ||
64 | } | ||
65 | |||
66 | int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
67 | @@ -XXX,XX +XXX,XX @@ int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
68 | int nb_sectors, int *pnum, | ||
69 | BlockDriverState **file) | ||
70 | { | ||
71 | - return bdrv_common_block_status_above(bs, base, true, sector_num, | ||
72 | - nb_sectors, pnum, file); | ||
73 | + int64_t ret; | ||
74 | + int64_t n; | ||
75 | + int64_t map; | ||
76 | + | ||
77 | + ret = bdrv_common_block_status_above(bs, base, true, | ||
78 | + sector_num * BDRV_SECTOR_SIZE, | ||
79 | + nb_sectors * BDRV_SECTOR_SIZE, | ||
80 | + &n, &map, file); | ||
81 | + if (ret < 0) { | ||
82 | + *pnum = 0; | ||
83 | + return ret; | ||
84 | + } | ||
85 | + assert(QEMU_IS_ALIGNED(n | map, BDRV_SECTOR_SIZE)); | ||
86 | + *pnum = n >> BDRV_SECTOR_BITS; | ||
87 | + return ret | map; | ||
88 | } | ||
89 | |||
90 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
91 | @@ -XXX,XX +XXX,XX @@ int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
92 | int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | ||
93 | int64_t bytes, int64_t *pnum) | ||
94 | { | ||
95 | - int64_t ret; | ||
96 | - int psectors; | ||
97 | + int ret; | ||
98 | + int64_t dummy; | ||
99 | |||
100 | - assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); | ||
101 | - assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE) && bytes < INT_MAX); | ||
102 | - ret = bdrv_common_block_status_above(bs, backing_bs(bs), false, | ||
103 | - offset >> BDRV_SECTOR_BITS, | ||
104 | - bytes >> BDRV_SECTOR_BITS, &psectors, | ||
105 | + ret = bdrv_common_block_status_above(bs, backing_bs(bs), false, offset, | ||
106 | + bytes, pnum ? pnum : &dummy, NULL, | ||
107 | NULL); | ||
108 | if (ret < 0) { | ||
109 | return ret; | ||
110 | } | ||
111 | - if (pnum) { | ||
112 | - *pnum = psectors * BDRV_SECTOR_SIZE; | ||
113 | - } | ||
114 | return !!(ret & BDRV_BLOCK_ALLOCATED); | ||
115 | } | ||
116 | |||
117 | -- | ||
118 | 2.13.6 | ||
119 | |||
120 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | We are gradually converting to byte-based interfaces, as they are | ||
4 | easier to reason about than sector-based. Convert another internal | ||
5 | type (no semantic change), and rename it to match the corresponding | ||
6 | public function rename. | ||
7 | |||
8 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
10 | --- | ||
11 | block/io.c | 68 ++++++++++++++++++++++---------------------------------------- | ||
12 | 1 file changed, 24 insertions(+), 44 deletions(-) | ||
13 | |||
14 | diff --git a/block/io.c b/block/io.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/io.c | ||
17 | +++ b/block/io.c | ||
18 | @@ -XXX,XX +XXX,XX @@ early_out: | ||
19 | return ret; | ||
20 | } | ||
21 | |||
22 | -static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | ||
23 | - BlockDriverState *base, | ||
24 | - bool want_zero, | ||
25 | - int64_t sector_num, | ||
26 | - int nb_sectors, | ||
27 | - int *pnum, | ||
28 | - BlockDriverState **file) | ||
29 | +static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs, | ||
30 | + BlockDriverState *base, | ||
31 | + bool want_zero, | ||
32 | + int64_t offset, | ||
33 | + int64_t bytes, | ||
34 | + int64_t *pnum, | ||
35 | + int64_t *map, | ||
36 | + BlockDriverState **file) | ||
37 | { | ||
38 | BlockDriverState *p; | ||
39 | - int64_t ret = 0; | ||
40 | + int ret = 0; | ||
41 | bool first = true; | ||
42 | - int64_t map = 0; | ||
43 | |||
44 | assert(bs != base); | ||
45 | for (p = bs; p != base; p = backing_bs(p)) { | ||
46 | - int64_t count; | ||
47 | - | ||
48 | - ret = bdrv_co_block_status(p, want_zero, | ||
49 | - sector_num * BDRV_SECTOR_SIZE, | ||
50 | - nb_sectors * BDRV_SECTOR_SIZE, &count, | ||
51 | - &map, file); | ||
52 | + ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map, | ||
53 | + file); | ||
54 | if (ret < 0) { | ||
55 | break; | ||
56 | } | ||
57 | - assert(QEMU_IS_ALIGNED(count | map, BDRV_SECTOR_SIZE)); | ||
58 | - ret |= map; | ||
59 | - *pnum = count >> BDRV_SECTOR_BITS; | ||
60 | if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) { | ||
61 | /* | ||
62 | * Reading beyond the end of the file continues to read | ||
63 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | ||
64 | * unallocated length we learned from an earlier | ||
65 | * iteration. | ||
66 | */ | ||
67 | - *pnum = nb_sectors; | ||
68 | + *pnum = bytes; | ||
69 | } | ||
70 | if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) { | ||
71 | break; | ||
72 | } | ||
73 | - /* [sector_num, pnum] unallocated on this layer, which could be only | ||
74 | - * the first part of [sector_num, nb_sectors]. */ | ||
75 | - nb_sectors = MIN(nb_sectors, *pnum); | ||
76 | + /* [offset, pnum] unallocated on this layer, which could be only | ||
77 | + * the first part of [offset, bytes]. */ | ||
78 | + bytes = MIN(bytes, *pnum); | ||
79 | first = false; | ||
80 | } | ||
81 | return ret; | ||
82 | } | ||
83 | |||
84 | /* Coroutine wrapper for bdrv_get_block_status_above() */ | ||
85 | -static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque) | ||
86 | +static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque) | ||
87 | { | ||
88 | BdrvCoBlockStatusData *data = opaque; | ||
89 | - int n = 0; | ||
90 | - int64_t ret; | ||
91 | |||
92 | - ret = bdrv_co_get_block_status_above(data->bs, data->base, | ||
93 | - data->want_zero, | ||
94 | - data->offset >> BDRV_SECTOR_BITS, | ||
95 | - data->bytes >> BDRV_SECTOR_BITS, | ||
96 | - &n, | ||
97 | - data->file); | ||
98 | - if (ret < 0) { | ||
99 | - assert(INT_MIN <= ret); | ||
100 | - data->ret = ret; | ||
101 | - } else { | ||
102 | - *data->pnum = n * BDRV_SECTOR_SIZE; | ||
103 | - *data->map = ret & BDRV_BLOCK_OFFSET_MASK; | ||
104 | - data->ret = ret & ~BDRV_BLOCK_OFFSET_MASK; | ||
105 | - } | ||
106 | + data->ret = bdrv_co_block_status_above(data->bs, data->base, | ||
107 | + data->want_zero, | ||
108 | + data->offset, data->bytes, | ||
109 | + data->pnum, data->map, data->file); | ||
110 | data->done = true; | ||
111 | } | ||
112 | |||
113 | /* | ||
114 | - * Synchronous wrapper around bdrv_co_get_block_status_above(). | ||
115 | + * Synchronous wrapper around bdrv_co_block_status_above(). | ||
116 | * | ||
117 | - * See bdrv_co_get_block_status_above() for details. | ||
118 | + * See bdrv_co_block_status_above() for details. | ||
119 | */ | ||
120 | static int bdrv_common_block_status_above(BlockDriverState *bs, | ||
121 | BlockDriverState *base, | ||
122 | @@ -XXX,XX +XXX,XX @@ static int bdrv_common_block_status_above(BlockDriverState *bs, | ||
123 | |||
124 | if (qemu_in_coroutine()) { | ||
125 | /* Fast-path if already in coroutine context */ | ||
126 | - bdrv_get_block_status_above_co_entry(&data); | ||
127 | + bdrv_block_status_above_co_entry(&data); | ||
128 | } else { | ||
129 | - co = qemu_coroutine_create(bdrv_get_block_status_above_co_entry, | ||
130 | - &data); | ||
131 | + co = qemu_coroutine_create(bdrv_block_status_above_co_entry, &data); | ||
132 | bdrv_coroutine_enter(bs, co); | ||
133 | BDRV_POLL_WHILE(bs, !data.done); | ||
134 | } | ||
135 | -- | ||
136 | 2.13.6 | ||
137 | |||
138 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | We are gradually moving away from sector-based interfaces, towards | ||
4 | byte-based. In the common case, allocation is unlikely to ever use | ||
5 | values that are not naturally sector-aligned, but it is possible | ||
6 | that byte-based values will let us be more precise about allocation | ||
7 | at the end of an unaligned file that can do byte-based access. | ||
8 | |||
9 | Changing the name of the function from bdrv_get_block_status_above() | ||
10 | to bdrv_block_status_above() ensures that the compiler enforces that | ||
11 | all callers are updated. Likewise, since it a byte interface allows | ||
12 | an offset mapping that might not be sector aligned, split the mapping | ||
13 | out of the return value and into a pass-by-reference parameter. For | ||
14 | now, the io.c layer still assert()s that all uses are sector-aligned, | ||
15 | but that can be relaxed when a later patch implements byte-based | ||
16 | block status in the drivers. | ||
17 | |||
18 | For the most part this patch is just the addition of scaling at the | ||
19 | callers followed by inverse scaling at bdrv_block_status(), plus | ||
20 | updates for the new split return interface. But some code, | ||
21 | particularly bdrv_block_status(), gets a lot simpler because it no | ||
22 | longer has to mess with sectors. Likewise, mirror code no longer | ||
23 | computes s->granularity >> BDRV_SECTOR_BITS, and can therefore drop | ||
24 | an assertion about alignment because the loop no longer depends on | ||
25 | alignment (never mind that we don't really have a driver that | ||
26 | reports sub-sector alignments, so it's not really possible to test | ||
27 | the effect of sub-sector mirroring). Fix a neighboring assertion to | ||
28 | use is_power_of_2 while there. | ||
29 | |||
30 | For ease of review, bdrv_get_block_status() was tackled separately. | ||
31 | |||
32 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
33 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
34 | --- | ||
35 | include/block/block.h | 8 +++----- | ||
36 | block/io.c | 55 ++++++++------------------------------------------- | ||
37 | block/mirror.c | 18 ++++++----------- | ||
38 | block/qcow2.c | 30 +++++++++++----------------- | ||
39 | qemu-img.c | 49 +++++++++++++++++++++++++-------------------- | ||
40 | 5 files changed, 57 insertions(+), 103 deletions(-) | ||
41 | |||
42 | diff --git a/include/block/block.h b/include/block/block.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/block/block.h | ||
45 | +++ b/include/block/block.h | ||
46 | @@ -XXX,XX +XXX,XX @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs); | ||
47 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, | ||
48 | int64_t bytes, int64_t *pnum, int64_t *map, | ||
49 | BlockDriverState **file); | ||
50 | -int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
51 | - BlockDriverState *base, | ||
52 | - int64_t sector_num, | ||
53 | - int nb_sectors, int *pnum, | ||
54 | - BlockDriverState **file); | ||
55 | +int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, | ||
56 | + int64_t offset, int64_t bytes, int64_t *pnum, | ||
57 | + int64_t *map, BlockDriverState **file); | ||
58 | int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
59 | int64_t *pnum); | ||
60 | int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, | ||
61 | diff --git a/block/io.c b/block/io.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/block/io.c | ||
64 | +++ b/block/io.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs, | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | -/* Coroutine wrapper for bdrv_get_block_status_above() */ | ||
70 | +/* Coroutine wrapper for bdrv_block_status_above() */ | ||
71 | static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque) | ||
72 | { | ||
73 | BdrvCoBlockStatusData *data = opaque; | ||
74 | @@ -XXX,XX +XXX,XX @@ static int bdrv_common_block_status_above(BlockDriverState *bs, | ||
75 | return data.ret; | ||
76 | } | ||
77 | |||
78 | -int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
79 | - BlockDriverState *base, | ||
80 | - int64_t sector_num, | ||
81 | - int nb_sectors, int *pnum, | ||
82 | - BlockDriverState **file) | ||
83 | +int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, | ||
84 | + int64_t offset, int64_t bytes, int64_t *pnum, | ||
85 | + int64_t *map, BlockDriverState **file) | ||
86 | { | ||
87 | - int64_t ret; | ||
88 | - int64_t n; | ||
89 | - int64_t map; | ||
90 | - | ||
91 | - ret = bdrv_common_block_status_above(bs, base, true, | ||
92 | - sector_num * BDRV_SECTOR_SIZE, | ||
93 | - nb_sectors * BDRV_SECTOR_SIZE, | ||
94 | - &n, &map, file); | ||
95 | - if (ret < 0) { | ||
96 | - *pnum = 0; | ||
97 | - return ret; | ||
98 | - } | ||
99 | - assert(QEMU_IS_ALIGNED(n | map, BDRV_SECTOR_SIZE)); | ||
100 | - *pnum = n >> BDRV_SECTOR_BITS; | ||
101 | - return ret | map; | ||
102 | + return bdrv_common_block_status_above(bs, base, true, offset, bytes, | ||
103 | + pnum, map, file); | ||
104 | } | ||
105 | |||
106 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, | ||
107 | int64_t *pnum, int64_t *map, BlockDriverState **file) | ||
108 | { | ||
109 | - int64_t ret; | ||
110 | - int n; | ||
111 | - | ||
112 | - assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); | ||
113 | - assert(pnum); | ||
114 | - /* | ||
115 | - * The contract allows us to return pnum smaller than bytes, even | ||
116 | - * if the next query would see the same status; we truncate the | ||
117 | - * request to avoid overflowing the driver's 32-bit interface. | ||
118 | - */ | ||
119 | - bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES); | ||
120 | - ret = bdrv_get_block_status_above(bs, backing_bs(bs), | ||
121 | - offset >> BDRV_SECTOR_BITS, | ||
122 | - bytes >> BDRV_SECTOR_BITS, &n, file); | ||
123 | - if (ret < 0) { | ||
124 | - assert(INT_MIN <= ret); | ||
125 | - *pnum = 0; | ||
126 | - return ret; | ||
127 | - } | ||
128 | - *pnum = n * BDRV_SECTOR_SIZE; | ||
129 | - if (map) { | ||
130 | - *map = ret & BDRV_BLOCK_OFFSET_MASK; | ||
131 | - } else { | ||
132 | - ret &= ~BDRV_BLOCK_OFFSET_VALID; | ||
133 | - } | ||
134 | - return ret & ~BDRV_BLOCK_OFFSET_MASK; | ||
135 | + return bdrv_block_status_above(bs, backing_bs(bs), | ||
136 | + offset, bytes, pnum, map, file); | ||
137 | } | ||
138 | |||
139 | int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | ||
140 | diff --git a/block/mirror.c b/block/mirror.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/block/mirror.c | ||
143 | +++ b/block/mirror.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
145 | uint64_t delay_ns = 0; | ||
146 | /* At least the first dirty chunk is mirrored in one iteration. */ | ||
147 | int nb_chunks = 1; | ||
148 | - int sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; | ||
149 | bool write_zeroes_ok = bdrv_can_write_zeroes_with_unmap(blk_bs(s->target)); | ||
150 | int max_io_bytes = MAX(s->buf_size / MAX_IN_FLIGHT, MAX_IO_BYTES); | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
153 | } | ||
154 | |||
155 | /* Clear dirty bits before querying the block status, because | ||
156 | - * calling bdrv_get_block_status_above could yield - if some blocks are | ||
157 | + * calling bdrv_block_status_above could yield - if some blocks are | ||
158 | * marked dirty in this window, we need to know. | ||
159 | */ | ||
160 | bdrv_reset_dirty_bitmap_locked(s->dirty_bitmap, offset, | ||
161 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
162 | |||
163 | bitmap_set(s->in_flight_bitmap, offset / s->granularity, nb_chunks); | ||
164 | while (nb_chunks > 0 && offset < s->bdev_length) { | ||
165 | - int64_t ret; | ||
166 | - int io_sectors; | ||
167 | + int ret; | ||
168 | int64_t io_bytes; | ||
169 | int64_t io_bytes_acct; | ||
170 | enum MirrorMethod { | ||
171 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
172 | } mirror_method = MIRROR_METHOD_COPY; | ||
173 | |||
174 | assert(!(offset % s->granularity)); | ||
175 | - ret = bdrv_get_block_status_above(source, NULL, | ||
176 | - offset >> BDRV_SECTOR_BITS, | ||
177 | - nb_chunks * sectors_per_chunk, | ||
178 | - &io_sectors, NULL); | ||
179 | - io_bytes = io_sectors * BDRV_SECTOR_SIZE; | ||
180 | + ret = bdrv_block_status_above(source, NULL, offset, | ||
181 | + nb_chunks * s->granularity, | ||
182 | + &io_bytes, NULL, NULL); | ||
183 | if (ret < 0) { | ||
184 | io_bytes = MIN(nb_chunks * s->granularity, max_io_bytes); | ||
185 | } else if (ret & BDRV_BLOCK_DATA) { | ||
186 | @@ -XXX,XX +XXX,XX @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, | ||
187 | granularity = bdrv_get_default_bitmap_granularity(target); | ||
188 | } | ||
189 | |||
190 | - assert ((granularity & (granularity - 1)) == 0); | ||
191 | - /* Granularity must be large enough for sector-based dirty bitmap */ | ||
192 | - assert(granularity >= BDRV_SECTOR_SIZE); | ||
193 | + assert(is_power_of_2(granularity)); | ||
194 | |||
195 | if (buf_size < 0) { | ||
196 | error_setg(errp, "Invalid parameter 'buf-size'"); | ||
197 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
198 | index XXXXXXX..XXXXXXX 100644 | ||
199 | --- a/block/qcow2.c | ||
200 | +++ b/block/qcow2.c | ||
201 | @@ -XXX,XX +XXX,XX @@ finish: | ||
202 | |||
203 | static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) | ||
204 | { | ||
205 | - int nr; | ||
206 | - int64_t res; | ||
207 | + int64_t nr; | ||
208 | + int res; | ||
209 | int64_t start; | ||
210 | |||
211 | /* TODO: Widening to sector boundaries should only be needed as | ||
212 | @@ -XXX,XX +XXX,XX @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) | ||
213 | if (!bytes) { | ||
214 | return true; | ||
215 | } | ||
216 | - res = bdrv_get_block_status_above(bs, NULL, start >> BDRV_SECTOR_BITS, | ||
217 | - bytes >> BDRV_SECTOR_BITS, &nr, NULL); | ||
218 | - return res >= 0 && (res & BDRV_BLOCK_ZERO) && | ||
219 | - nr * BDRV_SECTOR_SIZE == bytes; | ||
220 | + res = bdrv_block_status_above(bs, NULL, start, bytes, &nr, NULL, NULL); | ||
221 | + return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == bytes; | ||
222 | } | ||
223 | |||
224 | static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, | ||
225 | @@ -XXX,XX +XXX,XX @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs, | ||
226 | required = virtual_size; | ||
227 | } else { | ||
228 | int64_t offset; | ||
229 | - int pnum = 0; | ||
230 | + int64_t pnum = 0; | ||
231 | |||
232 | - for (offset = 0; offset < ssize; | ||
233 | - offset += pnum * BDRV_SECTOR_SIZE) { | ||
234 | - int nb_sectors = MIN(ssize - offset, | ||
235 | - BDRV_REQUEST_MAX_BYTES) / BDRV_SECTOR_SIZE; | ||
236 | - int64_t ret; | ||
237 | + for (offset = 0; offset < ssize; offset += pnum) { | ||
238 | + int ret; | ||
239 | |||
240 | - ret = bdrv_get_block_status_above(in_bs, NULL, | ||
241 | - offset >> BDRV_SECTOR_BITS, | ||
242 | - nb_sectors, &pnum, NULL); | ||
243 | + ret = bdrv_block_status_above(in_bs, NULL, offset, | ||
244 | + ssize - offset, &pnum, NULL, | ||
245 | + NULL); | ||
246 | if (ret < 0) { | ||
247 | error_setg_errno(&local_err, -ret, | ||
248 | "Unable to get block status"); | ||
249 | @@ -XXX,XX +XXX,XX @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs, | ||
250 | } else if ((ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED)) == | ||
251 | (BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED)) { | ||
252 | /* Extend pnum to end of cluster for next iteration */ | ||
253 | - pnum = (ROUND_UP(offset + pnum * BDRV_SECTOR_SIZE, | ||
254 | - cluster_size) - offset) >> BDRV_SECTOR_BITS; | ||
255 | + pnum = ROUND_UP(offset + pnum, cluster_size) - offset; | ||
256 | |||
257 | /* Count clusters we've seen */ | ||
258 | - required += offset % cluster_size + pnum * BDRV_SECTOR_SIZE; | ||
259 | + required += offset % cluster_size + pnum; | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | diff --git a/qemu-img.c b/qemu-img.c | ||
264 | index XXXXXXX..XXXXXXX 100644 | ||
265 | --- a/qemu-img.c | ||
266 | +++ b/qemu-img.c | ||
267 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
268 | BlockDriverState *bs1, *bs2; | ||
269 | int64_t total_sectors1, total_sectors2; | ||
270 | uint8_t *buf1 = NULL, *buf2 = NULL; | ||
271 | - int pnum1, pnum2; | ||
272 | + int64_t pnum1, pnum2; | ||
273 | int allocated1, allocated2; | ||
274 | int ret = 0; /* return value - 0 Ident, 1 Different, >1 Error */ | ||
275 | bool progress = false, quiet = false, strict = false; | ||
276 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
277 | } | ||
278 | |||
279 | for (;;) { | ||
280 | - int64_t status1, status2; | ||
281 | + int status1, status2; | ||
282 | |||
283 | nb_sectors = sectors_to_process(total_sectors, sector_num); | ||
284 | if (nb_sectors <= 0) { | ||
285 | break; | ||
286 | } | ||
287 | - status1 = bdrv_get_block_status_above(bs1, NULL, sector_num, | ||
288 | - total_sectors1 - sector_num, | ||
289 | - &pnum1, NULL); | ||
290 | + status1 = bdrv_block_status_above(bs1, NULL, | ||
291 | + sector_num * BDRV_SECTOR_SIZE, | ||
292 | + (total_sectors1 - sector_num) * | ||
293 | + BDRV_SECTOR_SIZE, | ||
294 | + &pnum1, NULL, NULL); | ||
295 | if (status1 < 0) { | ||
296 | ret = 3; | ||
297 | error_report("Sector allocation test failed for %s", filename1); | ||
298 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
299 | } | ||
300 | allocated1 = status1 & BDRV_BLOCK_ALLOCATED; | ||
301 | |||
302 | - status2 = bdrv_get_block_status_above(bs2, NULL, sector_num, | ||
303 | - total_sectors2 - sector_num, | ||
304 | - &pnum2, NULL); | ||
305 | + status2 = bdrv_block_status_above(bs2, NULL, | ||
306 | + sector_num * BDRV_SECTOR_SIZE, | ||
307 | + (total_sectors2 - sector_num) * | ||
308 | + BDRV_SECTOR_SIZE, | ||
309 | + &pnum2, NULL, NULL); | ||
310 | if (status2 < 0) { | ||
311 | ret = 3; | ||
312 | error_report("Sector allocation test failed for %s", filename2); | ||
313 | goto out; | ||
314 | } | ||
315 | allocated2 = status2 & BDRV_BLOCK_ALLOCATED; | ||
316 | + /* TODO: Relax this once comparison is byte-based, and we no longer | ||
317 | + * have to worry about sector alignment */ | ||
318 | + assert(QEMU_IS_ALIGNED(pnum1 | pnum2, BDRV_SECTOR_SIZE)); | ||
319 | if (pnum1) { | ||
320 | - nb_sectors = MIN(nb_sectors, pnum1); | ||
321 | + nb_sectors = MIN(nb_sectors, pnum1 >> BDRV_SECTOR_BITS); | ||
322 | } | ||
323 | if (pnum2) { | ||
324 | - nb_sectors = MIN(nb_sectors, pnum2); | ||
325 | + nb_sectors = MIN(nb_sectors, pnum2 >> BDRV_SECTOR_BITS); | ||
326 | } | ||
327 | |||
328 | if (strict) { | ||
329 | - if ((status1 & ~BDRV_BLOCK_OFFSET_MASK) != | ||
330 | - (status2 & ~BDRV_BLOCK_OFFSET_MASK)) { | ||
331 | + if (status1 != status2) { | ||
332 | ret = 1; | ||
333 | qprintf(quiet, "Strict mode: Offset %" PRId64 | ||
334 | " block status mismatch!\n", | ||
335 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
336 | } | ||
337 | } | ||
338 | if ((status1 & BDRV_BLOCK_ZERO) && (status2 & BDRV_BLOCK_ZERO)) { | ||
339 | - nb_sectors = MIN(pnum1, pnum2); | ||
340 | + nb_sectors = DIV_ROUND_UP(MIN(pnum1, pnum2), BDRV_SECTOR_SIZE); | ||
341 | } else if (allocated1 == allocated2) { | ||
342 | if (allocated1) { | ||
343 | ret = blk_pread(blk1, sector_num << BDRV_SECTOR_BITS, buf1, | ||
344 | @@ -XXX,XX +XXX,XX @@ static void convert_select_part(ImgConvertState *s, int64_t sector_num, | ||
345 | |||
346 | static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) | ||
347 | { | ||
348 | - int64_t ret, src_cur_offset; | ||
349 | - int n, src_cur; | ||
350 | + int64_t src_cur_offset; | ||
351 | + int ret, n, src_cur; | ||
352 | |||
353 | convert_select_part(s, sector_num, &src_cur, &src_cur_offset); | ||
354 | |||
355 | @@ -XXX,XX +XXX,XX @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) | ||
356 | n = MIN(s->total_sectors - sector_num, BDRV_REQUEST_MAX_SECTORS); | ||
357 | |||
358 | if (s->sector_next_status <= sector_num) { | ||
359 | + int64_t count = n * BDRV_SECTOR_SIZE; | ||
360 | + | ||
361 | if (s->target_has_backing) { | ||
362 | - int64_t count = n * BDRV_SECTOR_SIZE; | ||
363 | |||
364 | ret = bdrv_block_status(blk_bs(s->src[src_cur]), | ||
365 | (sector_num - src_cur_offset) * | ||
366 | BDRV_SECTOR_SIZE, | ||
367 | count, &count, NULL, NULL); | ||
368 | - assert(ret < 0 || QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)); | ||
369 | - n = count >> BDRV_SECTOR_BITS; | ||
370 | } else { | ||
371 | - ret = bdrv_get_block_status_above(blk_bs(s->src[src_cur]), NULL, | ||
372 | - sector_num - src_cur_offset, | ||
373 | - n, &n, NULL); | ||
374 | + ret = bdrv_block_status_above(blk_bs(s->src[src_cur]), NULL, | ||
375 | + (sector_num - src_cur_offset) * | ||
376 | + BDRV_SECTOR_SIZE, | ||
377 | + count, &count, NULL, NULL); | ||
378 | } | ||
379 | if (ret < 0) { | ||
380 | return ret; | ||
381 | } | ||
382 | + n = DIV_ROUND_UP(count, BDRV_SECTOR_SIZE); | ||
383 | |||
384 | if (ret & BDRV_BLOCK_ZERO) { | ||
385 | s->status = BLK_ZERO; | ||
386 | -- | ||
387 | 2.13.6 | ||
388 | |||
389 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | As long as we are querying the status for a chunk smaller than | ||
4 | the known image size, we are guaranteed that a successful return | ||
5 | will have set pnum to a non-zero size (pnum is zero only for | ||
6 | queries beyond the end of the file). Use that to slightly | ||
7 | simplify the calculation of the current chunk size being compared. | ||
8 | Likewise, we don't have to shrink the amount of data operated on | ||
9 | until we know we have to read the file, and therefore have to fit | ||
10 | in the bounds of our buffer. Also, note that 'total_sectors_over' | ||
11 | is equivalent to 'progress_base'. | ||
12 | |||
13 | With these changes in place, sectors_to_process() is now dead code, | ||
14 | and can be removed. | ||
15 | |||
16 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
18 | --- | ||
19 | qemu-img.c | 38 +++++++++++--------------------------- | ||
20 | 1 file changed, 11 insertions(+), 27 deletions(-) | ||
21 | |||
22 | diff --git a/qemu-img.c b/qemu-img.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/qemu-img.c | ||
25 | +++ b/qemu-img.c | ||
26 | @@ -XXX,XX +XXX,XX @@ static int64_t sectors_to_bytes(int64_t sectors) | ||
27 | return sectors << BDRV_SECTOR_BITS; | ||
28 | } | ||
29 | |||
30 | -static int64_t sectors_to_process(int64_t total, int64_t from) | ||
31 | -{ | ||
32 | - return MIN(total - from, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
33 | -} | ||
34 | - | ||
35 | /* | ||
36 | * Check if passed sectors are empty (not allocated or contain only 0 bytes) | ||
37 | * | ||
38 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
39 | goto out; | ||
40 | } | ||
41 | |||
42 | - for (;;) { | ||
43 | + while (sector_num < total_sectors) { | ||
44 | int status1, status2; | ||
45 | |||
46 | - nb_sectors = sectors_to_process(total_sectors, sector_num); | ||
47 | - if (nb_sectors <= 0) { | ||
48 | - break; | ||
49 | - } | ||
50 | status1 = bdrv_block_status_above(bs1, NULL, | ||
51 | sector_num * BDRV_SECTOR_SIZE, | ||
52 | (total_sectors1 - sector_num) * | ||
53 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
54 | /* TODO: Relax this once comparison is byte-based, and we no longer | ||
55 | * have to worry about sector alignment */ | ||
56 | assert(QEMU_IS_ALIGNED(pnum1 | pnum2, BDRV_SECTOR_SIZE)); | ||
57 | - if (pnum1) { | ||
58 | - nb_sectors = MIN(nb_sectors, pnum1 >> BDRV_SECTOR_BITS); | ||
59 | - } | ||
60 | - if (pnum2) { | ||
61 | - nb_sectors = MIN(nb_sectors, pnum2 >> BDRV_SECTOR_BITS); | ||
62 | - } | ||
63 | + | ||
64 | + assert(pnum1 && pnum2); | ||
65 | + nb_sectors = MIN(pnum1, pnum2) >> BDRV_SECTOR_BITS; | ||
66 | |||
67 | if (strict) { | ||
68 | if (status1 != status2) { | ||
69 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
70 | } | ||
71 | } | ||
72 | if ((status1 & BDRV_BLOCK_ZERO) && (status2 & BDRV_BLOCK_ZERO)) { | ||
73 | - nb_sectors = DIV_ROUND_UP(MIN(pnum1, pnum2), BDRV_SECTOR_SIZE); | ||
74 | + /* nothing to do */ | ||
75 | } else if (allocated1 == allocated2) { | ||
76 | if (allocated1) { | ||
77 | + nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
78 | ret = blk_pread(blk1, sector_num << BDRV_SECTOR_BITS, buf1, | ||
79 | nb_sectors << BDRV_SECTOR_BITS); | ||
80 | if (ret < 0) { | ||
81 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
82 | } | ||
83 | } | ||
84 | } else { | ||
85 | - | ||
86 | + nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
87 | if (allocated1) { | ||
88 | ret = check_empty_sectors(blk1, sector_num, nb_sectors, | ||
89 | filename1, buf1, quiet); | ||
90 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
91 | |||
92 | if (total_sectors1 != total_sectors2) { | ||
93 | BlockBackend *blk_over; | ||
94 | - int64_t total_sectors_over; | ||
95 | const char *filename_over; | ||
96 | |||
97 | qprintf(quiet, "Warning: Image size mismatch!\n"); | ||
98 | if (total_sectors1 > total_sectors2) { | ||
99 | - total_sectors_over = total_sectors1; | ||
100 | blk_over = blk1; | ||
101 | filename_over = filename1; | ||
102 | } else { | ||
103 | - total_sectors_over = total_sectors2; | ||
104 | blk_over = blk2; | ||
105 | filename_over = filename2; | ||
106 | } | ||
107 | |||
108 | - for (;;) { | ||
109 | + while (sector_num < progress_base) { | ||
110 | int64_t count; | ||
111 | |||
112 | - nb_sectors = sectors_to_process(total_sectors_over, sector_num); | ||
113 | - if (nb_sectors <= 0) { | ||
114 | - break; | ||
115 | - } | ||
116 | ret = bdrv_is_allocated_above(blk_bs(blk_over), NULL, | ||
117 | sector_num * BDRV_SECTOR_SIZE, | ||
118 | - nb_sectors * BDRV_SECTOR_SIZE, | ||
119 | + (progress_base - sector_num) * | ||
120 | + BDRV_SECTOR_SIZE, | ||
121 | &count); | ||
122 | if (ret < 0) { | ||
123 | ret = 3; | ||
124 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
125 | assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)); | ||
126 | nb_sectors = count >> BDRV_SECTOR_BITS; | ||
127 | if (ret) { | ||
128 | + nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
129 | ret = check_empty_sectors(blk_over, sector_num, nb_sectors, | ||
130 | filename_over, buf1, quiet); | ||
131 | if (ret) { | ||
132 | -- | ||
133 | 2.13.6 | ||
134 | |||
135 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | Compare the following images with all-zero contents: | ||
4 | $ truncate --size 1M A | ||
5 | $ qemu-img create -f qcow2 -o preallocation=off B 1G | ||
6 | $ qemu-img create -f qcow2 -o preallocation=metadata C 1G | ||
7 | |||
8 | On my machine, the difference is noticeable for pre-patch speeds, | ||
9 | with more than an order of magnitude in difference caused by the | ||
10 | choice of preallocation in the qcow2 file: | ||
11 | |||
12 | $ time ./qemu-img compare -f raw -F qcow2 A B | ||
13 | Warning: Image size mismatch! | ||
14 | Images are identical. | ||
15 | |||
16 | real 0m0.014s | ||
17 | user 0m0.007s | ||
18 | sys 0m0.007s | ||
19 | |||
20 | $ time ./qemu-img compare -f raw -F qcow2 A C | ||
21 | Warning: Image size mismatch! | ||
22 | Images are identical. | ||
23 | |||
24 | real 0m0.341s | ||
25 | user 0m0.144s | ||
26 | sys 0m0.188s | ||
27 | |||
28 | Why? Because bdrv_is_allocated() returns false for image B but | ||
29 | true for image C, throwing away the fact that both images know | ||
30 | via lseek(SEEK_HOLE) that the entire image still reads as zero. | ||
31 | From there, qemu-img ends up calling bdrv_pread() for every byte | ||
32 | of the tail, instead of quickly looking for the next allocation. | ||
33 | The solution: use block_status instead of is_allocated, giving: | ||
34 | |||
35 | $ time ./qemu-img compare -f raw -F qcow2 A C | ||
36 | Warning: Image size mismatch! | ||
37 | Images are identical. | ||
38 | |||
39 | real 0m0.014s | ||
40 | user 0m0.011s | ||
41 | sys 0m0.003s | ||
42 | |||
43 | which is on par with the speeds for no pre-allocation. | ||
44 | |||
45 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
46 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
47 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
48 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
49 | --- | ||
50 | qemu-img.c | 8 ++++---- | ||
51 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
52 | |||
53 | diff --git a/qemu-img.c b/qemu-img.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/qemu-img.c | ||
56 | +++ b/qemu-img.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
58 | while (sector_num < progress_base) { | ||
59 | int64_t count; | ||
60 | |||
61 | - ret = bdrv_is_allocated_above(blk_bs(blk_over), NULL, | ||
62 | + ret = bdrv_block_status_above(blk_bs(blk_over), NULL, | ||
63 | sector_num * BDRV_SECTOR_SIZE, | ||
64 | (progress_base - sector_num) * | ||
65 | BDRV_SECTOR_SIZE, | ||
66 | - &count); | ||
67 | + &count, NULL, NULL); | ||
68 | if (ret < 0) { | ||
69 | ret = 3; | ||
70 | error_report("Sector allocation test failed for %s", | ||
71 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
72 | goto out; | ||
73 | |||
74 | } | ||
75 | - /* TODO relax this once bdrv_is_allocated_above does not enforce | ||
76 | + /* TODO relax this once bdrv_block_status_above does not enforce | ||
77 | * sector alignment */ | ||
78 | assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)); | ||
79 | nb_sectors = count >> BDRV_SECTOR_BITS; | ||
80 | - if (ret) { | ||
81 | + if (ret & BDRV_BLOCK_ALLOCATED && !(ret & BDRV_BLOCK_ZERO)) { | ||
82 | nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
83 | ret = check_empty_sectors(blk_over, sector_num, nb_sectors, | ||
84 | filename_over, buf1, quiet); | ||
85 | -- | ||
86 | 2.13.6 | ||
87 | |||
88 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | If a read error is encountered during 'qemu-img compare', we | ||
4 | were printing the "Error while reading offset ..." message twice; | ||
5 | this was because our helper function was awkward, printing output | ||
6 | on some but not all paths. Fix it to consistently report errors | ||
7 | on all paths, so that the callers do not risk a redundant message, | ||
8 | and update the testsuite for the improved output. | ||
9 | |||
10 | Further simplify the code by hoisting the conversion from an error | ||
11 | message to an exit code into the helper function, rather than | ||
12 | repeating that logic at all callers (yes, the helper function is | ||
13 | now less generic, but it's a net win in lines of code). | ||
14 | |||
15 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
16 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
18 | --- | ||
19 | qemu-img.c | 19 +++++-------------- | ||
20 | tests/qemu-iotests/074.out | 2 -- | ||
21 | 2 files changed, 5 insertions(+), 16 deletions(-) | ||
22 | |||
23 | diff --git a/qemu-img.c b/qemu-img.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/qemu-img.c | ||
26 | +++ b/qemu-img.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static int64_t sectors_to_bytes(int64_t sectors) | ||
28 | /* | ||
29 | * Check if passed sectors are empty (not allocated or contain only 0 bytes) | ||
30 | * | ||
31 | - * Returns 0 in case sectors are filled with 0, 1 if sectors contain non-zero | ||
32 | - * data and negative value on error. | ||
33 | + * Intended for use by 'qemu-img compare': Returns 0 in case sectors are | ||
34 | + * filled with 0, 1 if sectors contain non-zero data (this is a comparison | ||
35 | + * failure), and 4 on error (the exit status for read errors), after emitting | ||
36 | + * an error message. | ||
37 | * | ||
38 | * @param blk: BlockBackend for the image | ||
39 | * @param sect_num: Number of first sector to check | ||
40 | @@ -XXX,XX +XXX,XX @@ static int check_empty_sectors(BlockBackend *blk, int64_t sect_num, | ||
41 | if (ret < 0) { | ||
42 | error_report("Error while reading offset %" PRId64 " of %s: %s", | ||
43 | sectors_to_bytes(sect_num), filename, strerror(-ret)); | ||
44 | - return ret; | ||
45 | + return 4; | ||
46 | } | ||
47 | idx = find_nonzero(buffer, sect_count * BDRV_SECTOR_SIZE); | ||
48 | if (idx >= 0) { | ||
49 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
50 | filename2, buf1, quiet); | ||
51 | } | ||
52 | if (ret) { | ||
53 | - if (ret < 0) { | ||
54 | - error_report("Error while reading offset %" PRId64 ": %s", | ||
55 | - sectors_to_bytes(sector_num), strerror(-ret)); | ||
56 | - ret = 4; | ||
57 | - } | ||
58 | goto out; | ||
59 | } | ||
60 | } | ||
61 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
62 | ret = check_empty_sectors(blk_over, sector_num, nb_sectors, | ||
63 | filename_over, buf1, quiet); | ||
64 | if (ret) { | ||
65 | - if (ret < 0) { | ||
66 | - error_report("Error while reading offset %" PRId64 | ||
67 | - " of %s: %s", sectors_to_bytes(sector_num), | ||
68 | - filename_over, strerror(-ret)); | ||
69 | - ret = 4; | ||
70 | - } | ||
71 | goto out; | ||
72 | } | ||
73 | } | ||
74 | diff --git a/tests/qemu-iotests/074.out b/tests/qemu-iotests/074.out | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/tests/qemu-iotests/074.out | ||
77 | +++ b/tests/qemu-iotests/074.out | ||
78 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 | ||
79 | wrote 512/512 bytes at offset 512 | ||
80 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
81 | qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error | ||
82 | -qemu-img: Error while reading offset 0: Input/output error | ||
83 | 4 | ||
84 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 | ||
85 | Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=0 | ||
86 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=0 | ||
87 | wrote 512/512 bytes at offset 512 | ||
88 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
89 | qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error | ||
90 | -qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error | ||
91 | Warning: Image size mismatch! | ||
92 | 4 | ||
93 | Cleanup | ||
94 | -- | ||
95 | 2.13.6 | ||
96 | |||
97 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | Continue on the quest to make more things byte-based instead of | ||
4 | sector-based. | ||
5 | |||
6 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | qemu-img.c | 27 +++++++++++++++------------ | ||
11 | 1 file changed, 15 insertions(+), 12 deletions(-) | ||
12 | |||
13 | diff --git a/qemu-img.c b/qemu-img.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/qemu-img.c | ||
16 | +++ b/qemu-img.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static int64_t sectors_to_bytes(int64_t sectors) | ||
18 | * an error message. | ||
19 | * | ||
20 | * @param blk: BlockBackend for the image | ||
21 | - * @param sect_num: Number of first sector to check | ||
22 | - * @param sect_count: Number of sectors to check | ||
23 | + * @param offset: Starting offset to check | ||
24 | + * @param bytes: Number of bytes to check | ||
25 | * @param filename: Name of disk file we are checking (logging purpose) | ||
26 | * @param buffer: Allocated buffer for storing read data | ||
27 | * @param quiet: Flag for quiet mode | ||
28 | */ | ||
29 | -static int check_empty_sectors(BlockBackend *blk, int64_t sect_num, | ||
30 | - int sect_count, const char *filename, | ||
31 | +static int check_empty_sectors(BlockBackend *blk, int64_t offset, | ||
32 | + int64_t bytes, const char *filename, | ||
33 | uint8_t *buffer, bool quiet) | ||
34 | { | ||
35 | int ret = 0; | ||
36 | int64_t idx; | ||
37 | |||
38 | - ret = blk_pread(blk, sect_num << BDRV_SECTOR_BITS, buffer, | ||
39 | - sect_count << BDRV_SECTOR_BITS); | ||
40 | + ret = blk_pread(blk, offset, buffer, bytes); | ||
41 | if (ret < 0) { | ||
42 | error_report("Error while reading offset %" PRId64 " of %s: %s", | ||
43 | - sectors_to_bytes(sect_num), filename, strerror(-ret)); | ||
44 | + offset, filename, strerror(-ret)); | ||
45 | return 4; | ||
46 | } | ||
47 | - idx = find_nonzero(buffer, sect_count * BDRV_SECTOR_SIZE); | ||
48 | + idx = find_nonzero(buffer, bytes); | ||
49 | if (idx >= 0) { | ||
50 | qprintf(quiet, "Content mismatch at offset %" PRId64 "!\n", | ||
51 | - sectors_to_bytes(sect_num) + idx); | ||
52 | + offset + idx); | ||
53 | return 1; | ||
54 | } | ||
55 | |||
56 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
57 | } else { | ||
58 | nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
59 | if (allocated1) { | ||
60 | - ret = check_empty_sectors(blk1, sector_num, nb_sectors, | ||
61 | + ret = check_empty_sectors(blk1, sector_num * BDRV_SECTOR_SIZE, | ||
62 | + nb_sectors * BDRV_SECTOR_SIZE, | ||
63 | filename1, buf1, quiet); | ||
64 | } else { | ||
65 | - ret = check_empty_sectors(blk2, sector_num, nb_sectors, | ||
66 | + ret = check_empty_sectors(blk2, sector_num * BDRV_SECTOR_SIZE, | ||
67 | + nb_sectors * BDRV_SECTOR_SIZE, | ||
68 | filename2, buf1, quiet); | ||
69 | } | ||
70 | if (ret) { | ||
71 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
72 | nb_sectors = count >> BDRV_SECTOR_BITS; | ||
73 | if (ret & BDRV_BLOCK_ALLOCATED && !(ret & BDRV_BLOCK_ZERO)) { | ||
74 | nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
75 | - ret = check_empty_sectors(blk_over, sector_num, nb_sectors, | ||
76 | + ret = check_empty_sectors(blk_over, | ||
77 | + sector_num * BDRV_SECTOR_SIZE, | ||
78 | + nb_sectors * BDRV_SECTOR_SIZE, | ||
79 | filename_over, buf1, quiet); | ||
80 | if (ret) { | ||
81 | goto out; | ||
82 | -- | ||
83 | 2.13.6 | ||
84 | |||
85 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | In the continuing quest to make more things byte-based, change | ||
4 | compare_sectors(), renaming it to compare_buffers() in the | ||
5 | process. Note that one caller (qemu-img compare) only cares | ||
6 | about the first difference, while the other (qemu-img rebase) | ||
7 | cares about how many consecutive sectors have the same | ||
8 | equal/different status; however, this patch does not bother to | ||
9 | micro-optimize the compare case to avoid the comparisons of | ||
10 | sectors beyond the first mismatch. Both callers are always | ||
11 | passing valid buffers in, so the initial check for buffer size | ||
12 | can be turned into an assertion. | ||
13 | |||
14 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
15 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
17 | --- | ||
18 | qemu-img.c | 55 +++++++++++++++++++++++++++---------------------------- | ||
19 | 1 file changed, 27 insertions(+), 28 deletions(-) | ||
20 | |||
21 | diff --git a/qemu-img.c b/qemu-img.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/qemu-img.c | ||
24 | +++ b/qemu-img.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static int is_allocated_sectors_min(const uint8_t *buf, int n, int *pnum, | ||
26 | } | ||
27 | |||
28 | /* | ||
29 | - * Compares two buffers sector by sector. Returns 0 if the first sector of both | ||
30 | - * buffers matches, non-zero otherwise. | ||
31 | + * Compares two buffers sector by sector. Returns 0 if the first | ||
32 | + * sector of each buffer matches, non-zero otherwise. | ||
33 | * | ||
34 | - * pnum is set to the number of sectors (including and immediately following | ||
35 | - * the first one) that are known to have the same comparison result | ||
36 | + * pnum is set to the sector-aligned size of the buffer prefix that | ||
37 | + * has the same matching status as the first sector. | ||
38 | */ | ||
39 | -static int compare_sectors(const uint8_t *buf1, const uint8_t *buf2, int n, | ||
40 | - int *pnum) | ||
41 | +static int compare_buffers(const uint8_t *buf1, const uint8_t *buf2, | ||
42 | + int64_t bytes, int64_t *pnum) | ||
43 | { | ||
44 | bool res; | ||
45 | - int i; | ||
46 | + int64_t i = MIN(bytes, BDRV_SECTOR_SIZE); | ||
47 | |||
48 | - if (n <= 0) { | ||
49 | - *pnum = 0; | ||
50 | - return 0; | ||
51 | - } | ||
52 | + assert(bytes > 0); | ||
53 | |||
54 | - res = !!memcmp(buf1, buf2, 512); | ||
55 | - for(i = 1; i < n; i++) { | ||
56 | - buf1 += 512; | ||
57 | - buf2 += 512; | ||
58 | + res = !!memcmp(buf1, buf2, i); | ||
59 | + while (i < bytes) { | ||
60 | + int64_t len = MIN(bytes - i, BDRV_SECTOR_SIZE); | ||
61 | |||
62 | - if (!!memcmp(buf1, buf2, 512) != res) { | ||
63 | + if (!!memcmp(buf1 + i, buf2 + i, len) != res) { | ||
64 | break; | ||
65 | } | ||
66 | + i += len; | ||
67 | } | ||
68 | |||
69 | *pnum = i; | ||
70 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
71 | int64_t total_sectors; | ||
72 | int64_t sector_num = 0; | ||
73 | int64_t nb_sectors; | ||
74 | - int c, pnum; | ||
75 | + int c; | ||
76 | uint64_t progress_base; | ||
77 | bool image_opts = false; | ||
78 | bool force_share = false; | ||
79 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
80 | /* nothing to do */ | ||
81 | } else if (allocated1 == allocated2) { | ||
82 | if (allocated1) { | ||
83 | + int64_t pnum; | ||
84 | + | ||
85 | nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
86 | ret = blk_pread(blk1, sector_num << BDRV_SECTOR_BITS, buf1, | ||
87 | nb_sectors << BDRV_SECTOR_BITS); | ||
88 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
89 | ret = 4; | ||
90 | goto out; | ||
91 | } | ||
92 | - ret = compare_sectors(buf1, buf2, nb_sectors, &pnum); | ||
93 | - if (ret || pnum != nb_sectors) { | ||
94 | + ret = compare_buffers(buf1, buf2, | ||
95 | + nb_sectors * BDRV_SECTOR_SIZE, &pnum); | ||
96 | + if (ret || pnum != nb_sectors * BDRV_SECTOR_SIZE) { | ||
97 | qprintf(quiet, "Content mismatch at offset %" PRId64 "!\n", | ||
98 | - sectors_to_bytes( | ||
99 | - ret ? sector_num : sector_num + pnum)); | ||
100 | + sectors_to_bytes(sector_num) + (ret ? 0 : pnum)); | ||
101 | ret = 1; | ||
102 | goto out; | ||
103 | } | ||
104 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | ||
105 | /* If they differ, we need to write to the COW file */ | ||
106 | uint64_t written = 0; | ||
107 | |||
108 | - while (written < n) { | ||
109 | - int pnum; | ||
110 | + while (written < n * BDRV_SECTOR_SIZE) { | ||
111 | + int64_t pnum; | ||
112 | |||
113 | - if (compare_sectors(buf_old + written * 512, | ||
114 | - buf_new + written * 512, n - written, &pnum)) | ||
115 | + if (compare_buffers(buf_old + written, | ||
116 | + buf_new + written, | ||
117 | + n * BDRV_SECTOR_SIZE - written, &pnum)) | ||
118 | { | ||
119 | ret = blk_pwrite(blk, | ||
120 | - (sector + written) << BDRV_SECTOR_BITS, | ||
121 | - buf_old + written * 512, | ||
122 | - pnum << BDRV_SECTOR_BITS, 0); | ||
123 | + (sector << BDRV_SECTOR_BITS) + written, | ||
124 | + buf_old + written, pnum, 0); | ||
125 | if (ret < 0) { | ||
126 | error_report("Error while writing to COW image: %s", | ||
127 | strerror(-ret)); | ||
128 | -- | ||
129 | 2.13.6 | ||
130 | |||
131 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | In the continuing quest to make more things byte-based, change | ||
4 | the internal iteration of img_rebase(). We can finally drop the | ||
5 | TODO assertion added earlier, now that the entire algorithm is | ||
6 | byte-based and no longer has to shift from bytes to sectors. | ||
7 | |||
8 | Most of the change is mechanical ('num_sectors' becomes 'size', | ||
9 | 'sector' becomes 'offset', 'n' goes from sectors to bytes); some | ||
10 | of it is also a cleanup (use of MIN() instead of open-coding, | ||
11 | loss of variable 'count' added earlier in commit d6a644bb). | ||
12 | |||
13 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
14 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
15 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
16 | --- | ||
17 | qemu-img.c | 84 +++++++++++++++++++++++++------------------------------------- | ||
18 | 1 file changed, 34 insertions(+), 50 deletions(-) | ||
19 | |||
20 | diff --git a/qemu-img.c b/qemu-img.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/qemu-img.c | ||
23 | +++ b/qemu-img.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | ||
25 | * the image is the same as the original one at any time. | ||
26 | */ | ||
27 | if (!unsafe) { | ||
28 | - int64_t num_sectors; | ||
29 | - int64_t old_backing_num_sectors; | ||
30 | - int64_t new_backing_num_sectors = 0; | ||
31 | - uint64_t sector; | ||
32 | - int n; | ||
33 | - int64_t count; | ||
34 | + int64_t size; | ||
35 | + int64_t old_backing_size; | ||
36 | + int64_t new_backing_size = 0; | ||
37 | + uint64_t offset; | ||
38 | + int64_t n; | ||
39 | float local_progress = 0; | ||
40 | |||
41 | buf_old = blk_blockalign(blk, IO_BUF_SIZE); | ||
42 | buf_new = blk_blockalign(blk, IO_BUF_SIZE); | ||
43 | |||
44 | - num_sectors = blk_nb_sectors(blk); | ||
45 | - if (num_sectors < 0) { | ||
46 | + size = blk_getlength(blk); | ||
47 | + if (size < 0) { | ||
48 | error_report("Could not get size of '%s': %s", | ||
49 | - filename, strerror(-num_sectors)); | ||
50 | + filename, strerror(-size)); | ||
51 | ret = -1; | ||
52 | goto out; | ||
53 | } | ||
54 | - old_backing_num_sectors = blk_nb_sectors(blk_old_backing); | ||
55 | - if (old_backing_num_sectors < 0) { | ||
56 | + old_backing_size = blk_getlength(blk_old_backing); | ||
57 | + if (old_backing_size < 0) { | ||
58 | char backing_name[PATH_MAX]; | ||
59 | |||
60 | bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); | ||
61 | error_report("Could not get size of '%s': %s", | ||
62 | - backing_name, strerror(-old_backing_num_sectors)); | ||
63 | + backing_name, strerror(-old_backing_size)); | ||
64 | ret = -1; | ||
65 | goto out; | ||
66 | } | ||
67 | if (blk_new_backing) { | ||
68 | - new_backing_num_sectors = blk_nb_sectors(blk_new_backing); | ||
69 | - if (new_backing_num_sectors < 0) { | ||
70 | + new_backing_size = blk_getlength(blk_new_backing); | ||
71 | + if (new_backing_size < 0) { | ||
72 | error_report("Could not get size of '%s': %s", | ||
73 | - out_baseimg, strerror(-new_backing_num_sectors)); | ||
74 | + out_baseimg, strerror(-new_backing_size)); | ||
75 | ret = -1; | ||
76 | goto out; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | - if (num_sectors != 0) { | ||
81 | - local_progress = (float)100 / | ||
82 | - (num_sectors / MIN(num_sectors, IO_BUF_SIZE / 512)); | ||
83 | + if (size != 0) { | ||
84 | + local_progress = (float)100 / (size / MIN(size, IO_BUF_SIZE)); | ||
85 | } | ||
86 | |||
87 | - for (sector = 0; sector < num_sectors; sector += n) { | ||
88 | - | ||
89 | - /* How many sectors can we handle with the next read? */ | ||
90 | - if (sector + (IO_BUF_SIZE / 512) <= num_sectors) { | ||
91 | - n = (IO_BUF_SIZE / 512); | ||
92 | - } else { | ||
93 | - n = num_sectors - sector; | ||
94 | - } | ||
95 | + for (offset = 0; offset < size; offset += n) { | ||
96 | + /* How many bytes can we handle with the next read? */ | ||
97 | + n = MIN(IO_BUF_SIZE, size - offset); | ||
98 | |||
99 | /* If the cluster is allocated, we don't need to take action */ | ||
100 | - ret = bdrv_is_allocated(bs, sector << BDRV_SECTOR_BITS, | ||
101 | - n << BDRV_SECTOR_BITS, &count); | ||
102 | + ret = bdrv_is_allocated(bs, offset, n, &n); | ||
103 | if (ret < 0) { | ||
104 | error_report("error while reading image metadata: %s", | ||
105 | strerror(-ret)); | ||
106 | goto out; | ||
107 | } | ||
108 | - /* TODO relax this once bdrv_is_allocated does not enforce | ||
109 | - * sector alignment */ | ||
110 | - assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)); | ||
111 | - n = count >> BDRV_SECTOR_BITS; | ||
112 | if (ret) { | ||
113 | continue; | ||
114 | } | ||
115 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | ||
116 | * Read old and new backing file and take into consideration that | ||
117 | * backing files may be smaller than the COW image. | ||
118 | */ | ||
119 | - if (sector >= old_backing_num_sectors) { | ||
120 | - memset(buf_old, 0, n * BDRV_SECTOR_SIZE); | ||
121 | + if (offset >= old_backing_size) { | ||
122 | + memset(buf_old, 0, n); | ||
123 | } else { | ||
124 | - if (sector + n > old_backing_num_sectors) { | ||
125 | - n = old_backing_num_sectors - sector; | ||
126 | + if (offset + n > old_backing_size) { | ||
127 | + n = old_backing_size - offset; | ||
128 | } | ||
129 | |||
130 | - ret = blk_pread(blk_old_backing, sector << BDRV_SECTOR_BITS, | ||
131 | - buf_old, n << BDRV_SECTOR_BITS); | ||
132 | + ret = blk_pread(blk_old_backing, offset, buf_old, n); | ||
133 | if (ret < 0) { | ||
134 | error_report("error while reading from old backing file"); | ||
135 | goto out; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | - if (sector >= new_backing_num_sectors || !blk_new_backing) { | ||
140 | - memset(buf_new, 0, n * BDRV_SECTOR_SIZE); | ||
141 | + if (offset >= new_backing_size || !blk_new_backing) { | ||
142 | + memset(buf_new, 0, n); | ||
143 | } else { | ||
144 | - if (sector + n > new_backing_num_sectors) { | ||
145 | - n = new_backing_num_sectors - sector; | ||
146 | + if (offset + n > new_backing_size) { | ||
147 | + n = new_backing_size - offset; | ||
148 | } | ||
149 | |||
150 | - ret = blk_pread(blk_new_backing, sector << BDRV_SECTOR_BITS, | ||
151 | - buf_new, n << BDRV_SECTOR_BITS); | ||
152 | + ret = blk_pread(blk_new_backing, offset, buf_new, n); | ||
153 | if (ret < 0) { | ||
154 | error_report("error while reading from new backing file"); | ||
155 | goto out; | ||
156 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | ||
157 | /* If they differ, we need to write to the COW file */ | ||
158 | uint64_t written = 0; | ||
159 | |||
160 | - while (written < n * BDRV_SECTOR_SIZE) { | ||
161 | + while (written < n) { | ||
162 | int64_t pnum; | ||
163 | |||
164 | - if (compare_buffers(buf_old + written, | ||
165 | - buf_new + written, | ||
166 | - n * BDRV_SECTOR_SIZE - written, &pnum)) | ||
167 | + if (compare_buffers(buf_old + written, buf_new + written, | ||
168 | + n - written, &pnum)) | ||
169 | { | ||
170 | - ret = blk_pwrite(blk, | ||
171 | - (sector << BDRV_SECTOR_BITS) + written, | ||
172 | + ret = blk_pwrite(blk, offset + written, | ||
173 | buf_old + written, pnum, 0); | ||
174 | if (ret < 0) { | ||
175 | error_report("Error while writing to COW image: %s", | ||
176 | -- | ||
177 | 2.13.6 | ||
178 | |||
179 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | In the continuing quest to make more things byte-based, change | ||
4 | the internal iteration of img_compare(). We can finally drop the | ||
5 | TODO assertions added earlier, now that the entire algorithm is | ||
6 | byte-based and no longer has to shift from bytes to sectors. | ||
7 | |||
8 | Most of the change is mechanical ('total_sectors' becomes | ||
9 | 'total_size', 'sector_num' becomes 'offset', 'nb_sectors' becomes | ||
10 | 'chunk', 'progress_base' goes from sectors to bytes); some of it | ||
11 | is also a cleanup (sectors_to_bytes() is now unused, loss of | ||
12 | variable 'count' added earlier in commit 51b0a488). | ||
13 | |||
14 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
15 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
17 | --- | ||
18 | qemu-img.c | 124 ++++++++++++++++++++++++------------------------------------- | ||
19 | 1 file changed, 48 insertions(+), 76 deletions(-) | ||
20 | |||
21 | diff --git a/qemu-img.c b/qemu-img.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/qemu-img.c | ||
24 | +++ b/qemu-img.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static int compare_buffers(const uint8_t *buf1, const uint8_t *buf2, | ||
26 | |||
27 | #define IO_BUF_SIZE (2 * 1024 * 1024) | ||
28 | |||
29 | -static int64_t sectors_to_bytes(int64_t sectors) | ||
30 | -{ | ||
31 | - return sectors << BDRV_SECTOR_BITS; | ||
32 | -} | ||
33 | - | ||
34 | /* | ||
35 | * Check if passed sectors are empty (not allocated or contain only 0 bytes) | ||
36 | * | ||
37 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
38 | const char *fmt1 = NULL, *fmt2 = NULL, *cache, *filename1, *filename2; | ||
39 | BlockBackend *blk1, *blk2; | ||
40 | BlockDriverState *bs1, *bs2; | ||
41 | - int64_t total_sectors1, total_sectors2; | ||
42 | + int64_t total_size1, total_size2; | ||
43 | uint8_t *buf1 = NULL, *buf2 = NULL; | ||
44 | int64_t pnum1, pnum2; | ||
45 | int allocated1, allocated2; | ||
46 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
47 | bool progress = false, quiet = false, strict = false; | ||
48 | int flags; | ||
49 | bool writethrough; | ||
50 | - int64_t total_sectors; | ||
51 | - int64_t sector_num = 0; | ||
52 | - int64_t nb_sectors; | ||
53 | + int64_t total_size; | ||
54 | + int64_t offset = 0; | ||
55 | + int64_t chunk; | ||
56 | int c; | ||
57 | uint64_t progress_base; | ||
58 | bool image_opts = false; | ||
59 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
60 | |||
61 | buf1 = blk_blockalign(blk1, IO_BUF_SIZE); | ||
62 | buf2 = blk_blockalign(blk2, IO_BUF_SIZE); | ||
63 | - total_sectors1 = blk_nb_sectors(blk1); | ||
64 | - if (total_sectors1 < 0) { | ||
65 | + total_size1 = blk_getlength(blk1); | ||
66 | + if (total_size1 < 0) { | ||
67 | error_report("Can't get size of %s: %s", | ||
68 | - filename1, strerror(-total_sectors1)); | ||
69 | + filename1, strerror(-total_size1)); | ||
70 | ret = 4; | ||
71 | goto out; | ||
72 | } | ||
73 | - total_sectors2 = blk_nb_sectors(blk2); | ||
74 | - if (total_sectors2 < 0) { | ||
75 | + total_size2 = blk_getlength(blk2); | ||
76 | + if (total_size2 < 0) { | ||
77 | error_report("Can't get size of %s: %s", | ||
78 | - filename2, strerror(-total_sectors2)); | ||
79 | + filename2, strerror(-total_size2)); | ||
80 | ret = 4; | ||
81 | goto out; | ||
82 | } | ||
83 | - total_sectors = MIN(total_sectors1, total_sectors2); | ||
84 | - progress_base = MAX(total_sectors1, total_sectors2); | ||
85 | + total_size = MIN(total_size1, total_size2); | ||
86 | + progress_base = MAX(total_size1, total_size2); | ||
87 | |||
88 | qemu_progress_print(0, 100); | ||
89 | |||
90 | - if (strict && total_sectors1 != total_sectors2) { | ||
91 | + if (strict && total_size1 != total_size2) { | ||
92 | ret = 1; | ||
93 | qprintf(quiet, "Strict mode: Image size mismatch!\n"); | ||
94 | goto out; | ||
95 | } | ||
96 | |||
97 | - while (sector_num < total_sectors) { | ||
98 | + while (offset < total_size) { | ||
99 | int status1, status2; | ||
100 | |||
101 | - status1 = bdrv_block_status_above(bs1, NULL, | ||
102 | - sector_num * BDRV_SECTOR_SIZE, | ||
103 | - (total_sectors1 - sector_num) * | ||
104 | - BDRV_SECTOR_SIZE, | ||
105 | - &pnum1, NULL, NULL); | ||
106 | + status1 = bdrv_block_status_above(bs1, NULL, offset, | ||
107 | + total_size1 - offset, &pnum1, NULL, | ||
108 | + NULL); | ||
109 | if (status1 < 0) { | ||
110 | ret = 3; | ||
111 | error_report("Sector allocation test failed for %s", filename1); | ||
112 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
113 | } | ||
114 | allocated1 = status1 & BDRV_BLOCK_ALLOCATED; | ||
115 | |||
116 | - status2 = bdrv_block_status_above(bs2, NULL, | ||
117 | - sector_num * BDRV_SECTOR_SIZE, | ||
118 | - (total_sectors2 - sector_num) * | ||
119 | - BDRV_SECTOR_SIZE, | ||
120 | - &pnum2, NULL, NULL); | ||
121 | + status2 = bdrv_block_status_above(bs2, NULL, offset, | ||
122 | + total_size2 - offset, &pnum2, NULL, | ||
123 | + NULL); | ||
124 | if (status2 < 0) { | ||
125 | ret = 3; | ||
126 | error_report("Sector allocation test failed for %s", filename2); | ||
127 | goto out; | ||
128 | } | ||
129 | allocated2 = status2 & BDRV_BLOCK_ALLOCATED; | ||
130 | - /* TODO: Relax this once comparison is byte-based, and we no longer | ||
131 | - * have to worry about sector alignment */ | ||
132 | - assert(QEMU_IS_ALIGNED(pnum1 | pnum2, BDRV_SECTOR_SIZE)); | ||
133 | |||
134 | assert(pnum1 && pnum2); | ||
135 | - nb_sectors = MIN(pnum1, pnum2) >> BDRV_SECTOR_BITS; | ||
136 | + chunk = MIN(pnum1, pnum2); | ||
137 | |||
138 | if (strict) { | ||
139 | if (status1 != status2) { | ||
140 | ret = 1; | ||
141 | qprintf(quiet, "Strict mode: Offset %" PRId64 | ||
142 | - " block status mismatch!\n", | ||
143 | - sectors_to_bytes(sector_num)); | ||
144 | + " block status mismatch!\n", offset); | ||
145 | goto out; | ||
146 | } | ||
147 | } | ||
148 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
149 | if (allocated1) { | ||
150 | int64_t pnum; | ||
151 | |||
152 | - nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
153 | - ret = blk_pread(blk1, sector_num << BDRV_SECTOR_BITS, buf1, | ||
154 | - nb_sectors << BDRV_SECTOR_BITS); | ||
155 | + chunk = MIN(chunk, IO_BUF_SIZE); | ||
156 | + ret = blk_pread(blk1, offset, buf1, chunk); | ||
157 | if (ret < 0) { | ||
158 | - error_report("Error while reading offset %" PRId64 " of %s:" | ||
159 | - " %s", sectors_to_bytes(sector_num), filename1, | ||
160 | - strerror(-ret)); | ||
161 | + error_report("Error while reading offset %" PRId64 | ||
162 | + " of %s: %s", | ||
163 | + offset, filename1, strerror(-ret)); | ||
164 | ret = 4; | ||
165 | goto out; | ||
166 | } | ||
167 | - ret = blk_pread(blk2, sector_num << BDRV_SECTOR_BITS, buf2, | ||
168 | - nb_sectors << BDRV_SECTOR_BITS); | ||
169 | + ret = blk_pread(blk2, offset, buf2, chunk); | ||
170 | if (ret < 0) { | ||
171 | error_report("Error while reading offset %" PRId64 | ||
172 | - " of %s: %s", sectors_to_bytes(sector_num), | ||
173 | - filename2, strerror(-ret)); | ||
174 | + " of %s: %s", | ||
175 | + offset, filename2, strerror(-ret)); | ||
176 | ret = 4; | ||
177 | goto out; | ||
178 | } | ||
179 | - ret = compare_buffers(buf1, buf2, | ||
180 | - nb_sectors * BDRV_SECTOR_SIZE, &pnum); | ||
181 | - if (ret || pnum != nb_sectors * BDRV_SECTOR_SIZE) { | ||
182 | + ret = compare_buffers(buf1, buf2, chunk, &pnum); | ||
183 | + if (ret || pnum != chunk) { | ||
184 | qprintf(quiet, "Content mismatch at offset %" PRId64 "!\n", | ||
185 | - sectors_to_bytes(sector_num) + (ret ? 0 : pnum)); | ||
186 | + offset + (ret ? 0 : pnum)); | ||
187 | ret = 1; | ||
188 | goto out; | ||
189 | } | ||
190 | } | ||
191 | } else { | ||
192 | - nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
193 | + chunk = MIN(chunk, IO_BUF_SIZE); | ||
194 | if (allocated1) { | ||
195 | - ret = check_empty_sectors(blk1, sector_num * BDRV_SECTOR_SIZE, | ||
196 | - nb_sectors * BDRV_SECTOR_SIZE, | ||
197 | + ret = check_empty_sectors(blk1, offset, chunk, | ||
198 | filename1, buf1, quiet); | ||
199 | } else { | ||
200 | - ret = check_empty_sectors(blk2, sector_num * BDRV_SECTOR_SIZE, | ||
201 | - nb_sectors * BDRV_SECTOR_SIZE, | ||
202 | + ret = check_empty_sectors(blk2, offset, chunk, | ||
203 | filename2, buf1, quiet); | ||
204 | } | ||
205 | if (ret) { | ||
206 | goto out; | ||
207 | } | ||
208 | } | ||
209 | - sector_num += nb_sectors; | ||
210 | - qemu_progress_print(((float) nb_sectors / progress_base)*100, 100); | ||
211 | + offset += chunk; | ||
212 | + qemu_progress_print(((float) chunk / progress_base) * 100, 100); | ||
213 | } | ||
214 | |||
215 | - if (total_sectors1 != total_sectors2) { | ||
216 | + if (total_size1 != total_size2) { | ||
217 | BlockBackend *blk_over; | ||
218 | const char *filename_over; | ||
219 | |||
220 | qprintf(quiet, "Warning: Image size mismatch!\n"); | ||
221 | - if (total_sectors1 > total_sectors2) { | ||
222 | + if (total_size1 > total_size2) { | ||
223 | blk_over = blk1; | ||
224 | filename_over = filename1; | ||
225 | } else { | ||
226 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
227 | filename_over = filename2; | ||
228 | } | ||
229 | |||
230 | - while (sector_num < progress_base) { | ||
231 | - int64_t count; | ||
232 | - | ||
233 | - ret = bdrv_block_status_above(blk_bs(blk_over), NULL, | ||
234 | - sector_num * BDRV_SECTOR_SIZE, | ||
235 | - (progress_base - sector_num) * | ||
236 | - BDRV_SECTOR_SIZE, | ||
237 | - &count, NULL, NULL); | ||
238 | + while (offset < progress_base) { | ||
239 | + ret = bdrv_block_status_above(blk_bs(blk_over), NULL, offset, | ||
240 | + progress_base - offset, &chunk, | ||
241 | + NULL, NULL); | ||
242 | if (ret < 0) { | ||
243 | ret = 3; | ||
244 | error_report("Sector allocation test failed for %s", | ||
245 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | ||
246 | goto out; | ||
247 | |||
248 | } | ||
249 | - /* TODO relax this once bdrv_block_status_above does not enforce | ||
250 | - * sector alignment */ | ||
251 | - assert(QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)); | ||
252 | - nb_sectors = count >> BDRV_SECTOR_BITS; | ||
253 | if (ret & BDRV_BLOCK_ALLOCATED && !(ret & BDRV_BLOCK_ZERO)) { | ||
254 | - nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | ||
255 | - ret = check_empty_sectors(blk_over, | ||
256 | - sector_num * BDRV_SECTOR_SIZE, | ||
257 | - nb_sectors * BDRV_SECTOR_SIZE, | ||
258 | + chunk = MIN(chunk, IO_BUF_SIZE); | ||
259 | + ret = check_empty_sectors(blk_over, offset, chunk, | ||
260 | filename_over, buf1, quiet); | ||
261 | if (ret) { | ||
262 | goto out; | ||
263 | } | ||
264 | } | ||
265 | - sector_num += nb_sectors; | ||
266 | - qemu_progress_print(((float) nb_sectors / progress_base)*100, 100); | ||
267 | + offset += chunk; | ||
268 | + qemu_progress_print(((float) chunk / progress_base) * 100, 100); | ||
269 | } | ||
270 | } | ||
271 | |||
272 | -- | ||
273 | 2.13.6 | ||
274 | |||
275 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | Any device that has request_alignment greater than 512 should be | ||
4 | unable to report status at a finer granularity; it may also be | ||
5 | simpler for such devices to be guaranteed that the block layer | ||
6 | has rounded things out to the granularity boundary (the way the | ||
7 | block layer already rounds all other I/O out). Besides, getting | ||
8 | the code correct for super-sector alignment also benefits us | ||
9 | for the fact that our public interface now has byte granularity, | ||
10 | even though none of our drivers have byte-level callbacks. | ||
11 | |||
12 | Add an assertion in blkdebug that proves that the block layer | ||
13 | never requests status of unaligned sections, similar to what it | ||
14 | does on other requests (while still keeping the generic helper | ||
15 | in place for when future patches add a throttle driver). Note | ||
16 | that iotest 177 already covers this (it would fail if you use | ||
17 | just the blkdebug.c hunk without the io.c changes). Meanwhile, | ||
18 | we can drop assertions in callers that no longer have to pass | ||
19 | in sector-aligned addresses. | ||
20 | |||
21 | There is a mid-function scope added for 'count' and 'longret', | ||
22 | for a couple of reasons: first, an upcoming patch will add an | ||
23 | 'if' statement that checks whether a driver has an old- or | ||
24 | new-style callback, and can conveniently use the same scope for | ||
25 | less indentation churn at that time. Second, since we are | ||
26 | trying to get rid of sector-based computations, wrapping things | ||
27 | in a scope makes it easier to group and see what will be | ||
28 | deleted in a final cleanup patch once all drivers have been | ||
29 | converted to the new-style callback. | ||
30 | |||
31 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
32 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
33 | --- | ||
34 | include/block/block_int.h | 3 +- | ||
35 | block/blkdebug.c | 13 ++++++++- | ||
36 | block/io.c | 71 ++++++++++++++++++++++++++++++----------------- | ||
37 | 3 files changed, 59 insertions(+), 28 deletions(-) | ||
38 | |||
39 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/include/block/block_int.h | ||
42 | +++ b/include/block/block_int.h | ||
43 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
44 | * according to the current layer, and should not set | ||
45 | * BDRV_BLOCK_ALLOCATED, but may set BDRV_BLOCK_RAW. See block.h | ||
46 | * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. The block | ||
47 | - * layer guarantees non-NULL pnum and file. | ||
48 | + * layer guarantees input aligned to request_alignment, as well as | ||
49 | + * non-NULL pnum and file. | ||
50 | */ | ||
51 | int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs, | ||
52 | int64_t sector_num, int nb_sectors, int *pnum, | ||
53 | diff --git a/block/blkdebug.c b/block/blkdebug.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/block/blkdebug.c | ||
56 | +++ b/block/blkdebug.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs, | ||
58 | return bdrv_co_pdiscard(bs->file->bs, offset, bytes); | ||
59 | } | ||
60 | |||
61 | +static int64_t coroutine_fn blkdebug_co_get_block_status( | ||
62 | + BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, | ||
63 | + BlockDriverState **file) | ||
64 | +{ | ||
65 | + assert(QEMU_IS_ALIGNED(sector_num | nb_sectors, | ||
66 | + DIV_ROUND_UP(bs->bl.request_alignment, | ||
67 | + BDRV_SECTOR_SIZE))); | ||
68 | + return bdrv_co_get_block_status_from_file(bs, sector_num, nb_sectors, | ||
69 | + pnum, file); | ||
70 | +} | ||
71 | + | ||
72 | static void blkdebug_close(BlockDriverState *bs) | ||
73 | { | ||
74 | BDRVBlkdebugState *s = bs->opaque; | ||
75 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_blkdebug = { | ||
76 | .bdrv_co_flush_to_disk = blkdebug_co_flush, | ||
77 | .bdrv_co_pwrite_zeroes = blkdebug_co_pwrite_zeroes, | ||
78 | .bdrv_co_pdiscard = blkdebug_co_pdiscard, | ||
79 | - .bdrv_co_get_block_status = bdrv_co_get_block_status_from_file, | ||
80 | + .bdrv_co_get_block_status = blkdebug_co_get_block_status, | ||
81 | |||
82 | .bdrv_debug_event = blkdebug_debug_event, | ||
83 | .bdrv_debug_breakpoint = blkdebug_debug_breakpoint, | ||
84 | diff --git a/block/io.c b/block/io.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/block/io.c | ||
87 | +++ b/block/io.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, | ||
89 | { | ||
90 | int64_t total_size; | ||
91 | int64_t n; /* bytes */ | ||
92 | - int64_t ret; | ||
93 | + int ret; | ||
94 | int64_t local_map = 0; | ||
95 | BlockDriverState *local_file = NULL; | ||
96 | - int count; /* sectors */ | ||
97 | + int64_t aligned_offset, aligned_bytes; | ||
98 | + uint32_t align; | ||
99 | |||
100 | assert(pnum); | ||
101 | *pnum = 0; | ||
102 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs, | ||
103 | } | ||
104 | |||
105 | bdrv_inc_in_flight(bs); | ||
106 | + | ||
107 | + /* Round out to request_alignment boundaries */ | ||
108 | + /* TODO: until we have a byte-based driver callback, we also have to | ||
109 | + * round out to sectors, even if that is bigger than request_alignment */ | ||
110 | + align = MAX(bs->bl.request_alignment, BDRV_SECTOR_SIZE); | ||
111 | + aligned_offset = QEMU_ALIGN_DOWN(offset, align); | ||
112 | + aligned_bytes = ROUND_UP(offset + bytes, align) - aligned_offset; | ||
113 | + | ||
114 | + { | ||
115 | + int count; /* sectors */ | ||
116 | + int64_t longret; | ||
117 | + | ||
118 | + assert(QEMU_IS_ALIGNED(aligned_offset | aligned_bytes, | ||
119 | + BDRV_SECTOR_SIZE)); | ||
120 | + /* | ||
121 | + * The contract allows us to return pnum smaller than bytes, even | ||
122 | + * if the next query would see the same status; we truncate the | ||
123 | + * request to avoid overflowing the driver's 32-bit interface. | ||
124 | + */ | ||
125 | + longret = bs->drv->bdrv_co_get_block_status( | ||
126 | + bs, aligned_offset >> BDRV_SECTOR_BITS, | ||
127 | + MIN(INT_MAX, aligned_bytes) >> BDRV_SECTOR_BITS, &count, | ||
128 | + &local_file); | ||
129 | + if (longret < 0) { | ||
130 | + assert(INT_MIN <= longret); | ||
131 | + ret = longret; | ||
132 | + goto out; | ||
133 | + } | ||
134 | + if (longret & BDRV_BLOCK_OFFSET_VALID) { | ||
135 | + local_map = longret & BDRV_BLOCK_OFFSET_MASK; | ||
136 | + } | ||
137 | + ret = longret & ~BDRV_BLOCK_OFFSET_MASK; | ||
138 | + *pnum = count * BDRV_SECTOR_SIZE; | ||
139 | + } | ||
140 | + | ||
141 | /* | ||
142 | - * TODO: Rather than require aligned offsets, we could instead | ||
143 | - * round to the driver's request_alignment here, then touch up | ||
144 | - * count afterwards back to the caller's expectations. | ||
145 | - */ | ||
146 | - assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); | ||
147 | - /* | ||
148 | - * The contract allows us to return pnum smaller than bytes, even | ||
149 | - * if the next query would see the same status; we truncate the | ||
150 | - * request to avoid overflowing the driver's 32-bit interface. | ||
151 | + * The driver's result must be a multiple of request_alignment. | ||
152 | + * Clamp pnum and adjust map to original request. | ||
153 | */ | ||
154 | - bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES); | ||
155 | - ret = bs->drv->bdrv_co_get_block_status(bs, offset >> BDRV_SECTOR_BITS, | ||
156 | - bytes >> BDRV_SECTOR_BITS, &count, | ||
157 | - &local_file); | ||
158 | - if (ret < 0) { | ||
159 | - goto out; | ||
160 | + assert(QEMU_IS_ALIGNED(*pnum, align) && align > offset - aligned_offset); | ||
161 | + *pnum -= offset - aligned_offset; | ||
162 | + if (*pnum > bytes) { | ||
163 | + *pnum = bytes; | ||
164 | } | ||
165 | if (ret & BDRV_BLOCK_OFFSET_VALID) { | ||
166 | - local_map = ret & BDRV_BLOCK_OFFSET_MASK; | ||
167 | + local_map += offset - aligned_offset; | ||
168 | } | ||
169 | - *pnum = count * BDRV_SECTOR_SIZE; | ||
170 | |||
171 | if (ret & BDRV_BLOCK_RAW) { | ||
172 | assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file); | ||
173 | ret = bdrv_co_block_status(local_file, want_zero, local_map, | ||
174 | *pnum, pnum, &local_map, &local_file); | ||
175 | - assert(ret < 0 || | ||
176 | - QEMU_IS_ALIGNED(*pnum | local_map, BDRV_SECTOR_SIZE)); | ||
177 | goto out; | ||
178 | } | ||
179 | |||
180 | @@ -XXX,XX +XXX,XX @@ early_out: | ||
181 | if (map) { | ||
182 | *map = local_map; | ||
183 | } | ||
184 | - if (ret >= 0) { | ||
185 | - ret &= ~BDRV_BLOCK_OFFSET_MASK; | ||
186 | - } else { | ||
187 | - assert(INT_MIN <= ret); | ||
188 | - } | ||
189 | return ret; | ||
190 | } | ||
191 | |||
192 | -- | ||
193 | 2.13.6 | ||
194 | |||
195 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | Now that bdrv_is_allocated accepts non-aligned inputs, we can | ||
4 | remove the TODO added in commit d6a644bb. | ||
5 | |||
6 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
9 | --- | ||
10 | block/io.c | 8 ++------ | ||
11 | 1 file changed, 2 insertions(+), 6 deletions(-) | ||
12 | |||
13 | diff --git a/block/io.c b/block/io.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/block/io.c | ||
16 | +++ b/block/io.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, | ||
18 | } | ||
19 | |||
20 | if (flags & BDRV_REQ_COPY_ON_READ) { | ||
21 | - /* TODO: Simplify further once bdrv_is_allocated no longer | ||
22 | - * requires sector alignment */ | ||
23 | - int64_t start = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); | ||
24 | - int64_t end = QEMU_ALIGN_UP(offset + bytes, BDRV_SECTOR_SIZE); | ||
25 | int64_t pnum; | ||
26 | |||
27 | - ret = bdrv_is_allocated(bs, start, end - start, &pnum); | ||
28 | + ret = bdrv_is_allocated(bs, offset, bytes, &pnum); | ||
29 | if (ret < 0) { | ||
30 | goto out; | ||
31 | } | ||
32 | |||
33 | - if (!ret || pnum != end - start) { | ||
34 | + if (!ret || pnum != bytes) { | ||
35 | ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov); | ||
36 | goto out; | ||
37 | } | ||
38 | -- | ||
39 | 2.13.6 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | Now that bdrv_is_allocated accepts non-aligned inputs, we can | ||
4 | remove the TODO added in earlier refactoring. | ||
5 | |||
6 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
8 | --- | ||
9 | block/qcow2.c | 12 +++--------- | ||
10 | 1 file changed, 3 insertions(+), 9 deletions(-) | ||
11 | |||
12 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/block/qcow2.c | ||
15 | +++ b/block/qcow2.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) | ||
17 | { | ||
18 | int64_t nr; | ||
19 | int res; | ||
20 | - int64_t start; | ||
21 | - | ||
22 | - /* TODO: Widening to sector boundaries should only be needed as | ||
23 | - * long as we can't query finer granularity. */ | ||
24 | - start = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); | ||
25 | - bytes = QEMU_ALIGN_UP(offset + bytes, BDRV_SECTOR_SIZE) - start; | ||
26 | |||
27 | /* Clamp to image length, before checking status of underlying sectors */ | ||
28 | - if (start + bytes > bs->total_sectors * BDRV_SECTOR_SIZE) { | ||
29 | - bytes = bs->total_sectors * BDRV_SECTOR_SIZE - start; | ||
30 | + if (offset + bytes > bs->total_sectors * BDRV_SECTOR_SIZE) { | ||
31 | + bytes = bs->total_sectors * BDRV_SECTOR_SIZE - offset; | ||
32 | } | ||
33 | |||
34 | if (!bytes) { | ||
35 | return true; | ||
36 | } | ||
37 | - res = bdrv_block_status_above(bs, NULL, start, bytes, &nr, NULL, NULL); | ||
38 | + res = bdrv_block_status_above(bs, NULL, offset, bytes, &nr, NULL, NULL); | ||
39 | return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == bytes; | ||
40 | } | ||
41 | |||
42 | -- | ||
43 | 2.13.6 | ||
44 | |||
45 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | BDRV_SECTOR_BITS is defined to be 9 in block.h (and BDRV_SECTOR_SIZE | ||
4 | is calculated from that), but there are still a couple of places where | ||
5 | we are using the literal value instead of the macro. | ||
6 | |||
7 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
8 | Message-id: 20171009153856.20387-1-berto@igalia.com | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | block/qcow2.c | 4 ++-- | ||
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/qcow2.c | ||
17 | +++ b/block/qcow2.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags, | ||
19 | |||
20 | s->cluster_bits = header.cluster_bits; | ||
21 | s->cluster_size = 1 << s->cluster_bits; | ||
22 | - s->cluster_sectors = 1 << (s->cluster_bits - 9); | ||
23 | + s->cluster_sectors = 1 << (s->cluster_bits - BDRV_SECTOR_BITS); | ||
24 | |||
25 | /* Initialise version 3 header fields */ | ||
26 | if (header.version == 2) { | ||
27 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn qcow2_co_get_block_status(BlockDriverState *bs, | ||
28 | |||
29 | bytes = MIN(INT_MAX, nb_sectors * BDRV_SECTOR_SIZE); | ||
30 | qemu_co_mutex_lock(&s->lock); | ||
31 | - ret = qcow2_get_cluster_offset(bs, sector_num << 9, &bytes, | ||
32 | + ret = qcow2_get_cluster_offset(bs, sector_num << BDRV_SECTOR_BITS, &bytes, | ||
33 | &cluster_offset); | ||
34 | qemu_co_mutex_unlock(&s->lock); | ||
35 | if (ret < 0) { | ||
36 | -- | ||
37 | 2.13.6 | ||
38 | |||
39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | Tests 067 and 087 filter the actual image size because it depends on the | ||
4 | host filesystem (and is not part of the respective test). Since this is | ||
5 | generally true, we should have a common filter function for this, so | ||
6 | let's pull out the sed line from both tests into such a function. | ||
7 | |||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | Message-id: 20171009163456.485-2-mreitz@redhat.com | ||
10 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
11 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
13 | --- | ||
14 | tests/qemu-iotests/067 | 2 +- | ||
15 | tests/qemu-iotests/087 | 2 +- | ||
16 | tests/qemu-iotests/common.filter | 6 ++++++ | ||
17 | 3 files changed, 8 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067 | ||
20 | index XXXXXXX..XXXXXXX 100755 | ||
21 | --- a/tests/qemu-iotests/067 | ||
22 | +++ b/tests/qemu-iotests/067 | ||
23 | @@ -XXX,XX +XXX,XX @@ _filter_qmp_events() | ||
24 | function run_qemu() | ||
25 | { | ||
26 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu \ | ||
27 | - | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g' \ | ||
28 | + | _filter_actual_image_size \ | ||
29 | | _filter_generated_node_ids | _filter_qmp_events | ||
30 | } | ||
31 | |||
32 | diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 | ||
33 | index XXXXXXX..XXXXXXX 100755 | ||
34 | --- a/tests/qemu-iotests/087 | ||
35 | +++ b/tests/qemu-iotests/087 | ||
36 | @@ -XXX,XX +XXX,XX @@ function run_qemu() | ||
37 | { | ||
38 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ | ||
39 | | _filter_qemu | _filter_imgfmt \ | ||
40 | - | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g' | ||
41 | + | _filter_actual_image_size | ||
42 | } | ||
43 | |||
44 | size=128M | ||
45 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/tests/qemu-iotests/common.filter | ||
48 | +++ b/tests/qemu-iotests/common.filter | ||
49 | @@ -XXX,XX +XXX,XX @@ _filter_block_job_len() | ||
50 | sed -e 's/, "len": [0-9]\+,/, "len": LEN,/g' | ||
51 | } | ||
52 | |||
53 | +# replace actual image size (depends on the host filesystem) | ||
54 | +_filter_actual_image_size() | ||
55 | +{ | ||
56 | + sed -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g' | ||
57 | +} | ||
58 | + | ||
59 | # replace driver-specific options in the "Formatting..." line | ||
60 | _filter_img_create() | ||
61 | { | ||
62 | -- | ||
63 | 2.13.6 | ||
64 | |||
65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | Whenever the actual image size is not part of the test, it should be | ||
4 | filtered as it depends on the host filesystem. | ||
5 | |||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | Message-id: 20171009163456.485-3-mreitz@redhat.com | ||
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/184 | 3 ++- | ||
13 | tests/qemu-iotests/184.out | 6 +++--- | ||
14 | tests/qemu-iotests/191 | 4 ++-- | ||
15 | tests/qemu-iotests/191.out | 46 +++++++++++++++++++++++----------------------- | ||
16 | 4 files changed, 30 insertions(+), 29 deletions(-) | ||
17 | |||
18 | diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184 | ||
19 | index XXXXXXX..XXXXXXX 100755 | ||
20 | --- a/tests/qemu-iotests/184 | ||
21 | +++ b/tests/qemu-iotests/184 | ||
22 | @@ -XXX,XX +XXX,XX @@ function do_run_qemu() | ||
23 | function run_qemu() | ||
24 | { | ||
25 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\ | ||
26 | - | _filter_qemu_io | _filter_generated_node_ids | ||
27 | + | _filter_qemu_io | _filter_generated_node_ids \ | ||
28 | + | _filter_actual_image_size | ||
29 | } | ||
30 | |||
31 | _make_test_img 64M | ||
32 | diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/tests/qemu-iotests/184.out | ||
35 | +++ b/tests/qemu-iotests/184.out | ||
36 | @@ -XXX,XX +XXX,XX @@ Testing: | ||
37 | "filename": "json:{\"throttle-group\": \"group0\", \"driver\": \"throttle\", \"file\": {\"driver\": \"qcow2\", \"file\": {\"driver\": \"file\", \"filename\": \"TEST_DIR/t.qcow2\"}}}", | ||
38 | "cluster-size": 65536, | ||
39 | "format": "throttle", | ||
40 | - "actual-size": 200704, | ||
41 | + "actual-size": SIZE, | ||
42 | "dirty-flag": false | ||
43 | }, | ||
44 | "iops_wr": 0, | ||
45 | @@ -XXX,XX +XXX,XX @@ Testing: | ||
46 | "filename": "TEST_DIR/t.qcow2", | ||
47 | "cluster-size": 65536, | ||
48 | "format": "qcow2", | ||
49 | - "actual-size": 200704, | ||
50 | + "actual-size": SIZE, | ||
51 | "format-specific": { | ||
52 | "type": "qcow2", | ||
53 | "data": { | ||
54 | @@ -XXX,XX +XXX,XX @@ Testing: | ||
55 | "virtual-size": 197120, | ||
56 | "filename": "TEST_DIR/t.qcow2", | ||
57 | "format": "file", | ||
58 | - "actual-size": 200704, | ||
59 | + "actual-size": SIZE, | ||
60 | "dirty-flag": false | ||
61 | }, | ||
62 | "iops_wr": 0, | ||
63 | diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 | ||
64 | index XXXXXXX..XXXXXXX 100755 | ||
65 | --- a/tests/qemu-iotests/191 | ||
66 | +++ b/tests/qemu-iotests/191 | ||
67 | @@ -XXX,XX +XXX,XX @@ echo === Check that both top and top2 point to base now === | ||
68 | echo | ||
69 | |||
70 | _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" | | ||
71 | - _filter_generated_node_ids | ||
72 | + _filter_generated_node_ids | _filter_actual_image_size | ||
73 | |||
74 | _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}" | ||
75 | wait=1 _cleanup_qemu | ||
76 | @@ -XXX,XX +XXX,XX @@ echo === Check that both top and top2 point to base now === | ||
77 | echo | ||
78 | |||
79 | _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" | | ||
80 | - _filter_generated_node_ids | ||
81 | + _filter_generated_node_ids | _filter_actual_image_size | ||
82 | |||
83 | _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}" | ||
84 | wait=1 _cleanup_qemu | ||
85 | diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/tests/qemu-iotests/191.out | ||
88 | +++ b/tests/qemu-iotests/191.out | ||
89 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
90 | "filename": "TEST_DIR/t.qcow2.base", | ||
91 | "cluster-size": 65536, | ||
92 | "format": "qcow2", | ||
93 | - "actual-size": 397312, | ||
94 | + "actual-size": SIZE, | ||
95 | "format-specific": { | ||
96 | "type": "qcow2", | ||
97 | "data": { | ||
98 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
99 | "filename": "TEST_DIR/t.qcow2.ovl2", | ||
100 | "cluster-size": 65536, | ||
101 | "format": "qcow2", | ||
102 | - "actual-size": 200704, | ||
103 | + "actual-size": SIZE, | ||
104 | "format-specific": { | ||
105 | "type": "qcow2", | ||
106 | "data": { | ||
107 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
108 | "virtual-size": 197120, | ||
109 | "filename": "TEST_DIR/t.qcow2.ovl2", | ||
110 | "format": "file", | ||
111 | - "actual-size": 200704, | ||
112 | + "actual-size": SIZE, | ||
113 | "dirty-flag": false | ||
114 | }, | ||
115 | "iops_wr": 0, | ||
116 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
117 | "filename": "TEST_DIR/t.qcow2.base", | ||
118 | "cluster-size": 65536, | ||
119 | "format": "qcow2", | ||
120 | - "actual-size": 397312, | ||
121 | + "actual-size": SIZE, | ||
122 | "format-specific": { | ||
123 | "type": "qcow2", | ||
124 | "data": { | ||
125 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
126 | "filename": "TEST_DIR/t.qcow2", | ||
127 | "cluster-size": 65536, | ||
128 | "format": "qcow2", | ||
129 | - "actual-size": 200704, | ||
130 | + "actual-size": SIZE, | ||
131 | "format-specific": { | ||
132 | "type": "qcow2", | ||
133 | "data": { | ||
134 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
135 | "virtual-size": 197120, | ||
136 | "filename": "TEST_DIR/t.qcow2", | ||
137 | "format": "file", | ||
138 | - "actual-size": 200704, | ||
139 | + "actual-size": SIZE, | ||
140 | "dirty-flag": false | ||
141 | }, | ||
142 | "iops_wr": 0, | ||
143 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
144 | "filename": "TEST_DIR/t.qcow2.base", | ||
145 | "cluster-size": 65536, | ||
146 | "format": "qcow2", | ||
147 | - "actual-size": 397312, | ||
148 | + "actual-size": SIZE, | ||
149 | "format-specific": { | ||
150 | "type": "qcow2", | ||
151 | "data": { | ||
152 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
153 | "filename": "TEST_DIR/t.qcow2.mid", | ||
154 | "cluster-size": 65536, | ||
155 | "format": "qcow2", | ||
156 | - "actual-size": 397312, | ||
157 | + "actual-size": SIZE, | ||
158 | "format-specific": { | ||
159 | "type": "qcow2", | ||
160 | "data": { | ||
161 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
162 | "virtual-size": 393216, | ||
163 | "filename": "TEST_DIR/t.qcow2.mid", | ||
164 | "format": "file", | ||
165 | - "actual-size": 397312, | ||
166 | + "actual-size": SIZE, | ||
167 | "dirty-flag": false | ||
168 | }, | ||
169 | "iops_wr": 0, | ||
170 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
171 | "filename": "TEST_DIR/t.qcow2.base", | ||
172 | "cluster-size": 65536, | ||
173 | "format": "qcow2", | ||
174 | - "actual-size": 397312, | ||
175 | + "actual-size": SIZE, | ||
176 | "format-specific": { | ||
177 | "type": "qcow2", | ||
178 | "data": { | ||
179 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
180 | "virtual-size": 393216, | ||
181 | "filename": "TEST_DIR/t.qcow2.base", | ||
182 | "format": "file", | ||
183 | - "actual-size": 397312, | ||
184 | + "actual-size": SIZE, | ||
185 | "dirty-flag": false | ||
186 | }, | ||
187 | "iops_wr": 0, | ||
188 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
189 | "filename": "TEST_DIR/t.qcow2.base", | ||
190 | "cluster-size": 65536, | ||
191 | "format": "qcow2", | ||
192 | - "actual-size": 397312, | ||
193 | + "actual-size": SIZE, | ||
194 | "format-specific": { | ||
195 | "type": "qcow2", | ||
196 | "data": { | ||
197 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
198 | "filename": "TEST_DIR/t.qcow2.ovl2", | ||
199 | "cluster-size": 65536, | ||
200 | "format": "qcow2", | ||
201 | - "actual-size": 200704, | ||
202 | + "actual-size": SIZE, | ||
203 | "format-specific": { | ||
204 | "type": "qcow2", | ||
205 | "data": { | ||
206 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
207 | "virtual-size": 197120, | ||
208 | "filename": "TEST_DIR/t.qcow2.ovl2", | ||
209 | "format": "file", | ||
210 | - "actual-size": 200704, | ||
211 | + "actual-size": SIZE, | ||
212 | "dirty-flag": false | ||
213 | }, | ||
214 | "iops_wr": 0, | ||
215 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
216 | "filename": "TEST_DIR/t.qcow2.base", | ||
217 | "cluster-size": 65536, | ||
218 | "format": "qcow2", | ||
219 | - "actual-size": 397312, | ||
220 | + "actual-size": SIZE, | ||
221 | "format-specific": { | ||
222 | "type": "qcow2", | ||
223 | "data": { | ||
224 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
225 | "filename": "TEST_DIR/t.qcow2.ovl2", | ||
226 | "cluster-size": 65536, | ||
227 | "format": "qcow2", | ||
228 | - "actual-size": 200704, | ||
229 | + "actual-size": SIZE, | ||
230 | "format-specific": { | ||
231 | "type": "qcow2", | ||
232 | "data": { | ||
233 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
234 | "filename": "TEST_DIR/t.qcow2.ovl3", | ||
235 | "cluster-size": 65536, | ||
236 | "format": "qcow2", | ||
237 | - "actual-size": 200704, | ||
238 | + "actual-size": SIZE, | ||
239 | "format-specific": { | ||
240 | "type": "qcow2", | ||
241 | "data": { | ||
242 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
243 | "virtual-size": 197120, | ||
244 | "filename": "TEST_DIR/t.qcow2.ovl3", | ||
245 | "format": "file", | ||
246 | - "actual-size": 200704, | ||
247 | + "actual-size": SIZE, | ||
248 | "dirty-flag": false | ||
249 | }, | ||
250 | "iops_wr": 0, | ||
251 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
252 | "filename": "TEST_DIR/t.qcow2.base", | ||
253 | "cluster-size": 65536, | ||
254 | "format": "qcow2", | ||
255 | - "actual-size": 397312, | ||
256 | + "actual-size": SIZE, | ||
257 | "format-specific": { | ||
258 | "type": "qcow2", | ||
259 | "data": { | ||
260 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
261 | "virtual-size": 393216, | ||
262 | "filename": "TEST_DIR/t.qcow2.base", | ||
263 | "format": "file", | ||
264 | - "actual-size": 397312, | ||
265 | + "actual-size": SIZE, | ||
266 | "dirty-flag": false | ||
267 | }, | ||
268 | "iops_wr": 0, | ||
269 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
270 | "filename": "TEST_DIR/t.qcow2.base", | ||
271 | "cluster-size": 65536, | ||
272 | "format": "qcow2", | ||
273 | - "actual-size": 397312, | ||
274 | + "actual-size": SIZE, | ||
275 | "format-specific": { | ||
276 | "type": "qcow2", | ||
277 | "data": { | ||
278 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
279 | "filename": "TEST_DIR/t.qcow2", | ||
280 | "cluster-size": 65536, | ||
281 | "format": "qcow2", | ||
282 | - "actual-size": 200704, | ||
283 | + "actual-size": SIZE, | ||
284 | "format-specific": { | ||
285 | "type": "qcow2", | ||
286 | "data": { | ||
287 | @@ -XXX,XX +XXX,XX @@ wrote 65536/65536 bytes at offset 1048576 | ||
288 | "virtual-size": 197120, | ||
289 | "filename": "TEST_DIR/t.qcow2", | ||
290 | "format": "file", | ||
291 | - "actual-size": 200704, | ||
292 | + "actual-size": SIZE, | ||
293 | "dirty-flag": false | ||
294 | }, | ||
295 | "iops_wr": 0, | ||
296 | -- | ||
297 | 2.13.6 | ||
298 | |||
299 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | bdrv_truncate() has an errp parameter which is always set when an error | ||
4 | occurs. Let's use that instead of a plain strerror(). | ||
5 | |||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | Message-id: 20171009155431.14093-1-mreitz@redhat.com | ||
8 | Reviewed-by: Pavel Butsykin <pbutsykin@virtuozzo.com> | ||
9 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | block/qcow2.c | 13 +++++++------ | ||
13 | 1 file changed, 7 insertions(+), 6 deletions(-) | ||
14 | |||
15 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/block/qcow2.c | ||
18 | +++ b/block/qcow2.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset, | ||
20 | return last_cluster; | ||
21 | } | ||
22 | if ((last_cluster + 1) * s->cluster_size < old_file_size) { | ||
23 | - ret = bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size, | ||
24 | - PREALLOC_MODE_OFF, NULL); | ||
25 | - if (ret < 0) { | ||
26 | - warn_report("Failed to truncate the tail of the image: %s", | ||
27 | - strerror(-ret)); | ||
28 | - ret = 0; | ||
29 | + Error *local_err = NULL; | ||
30 | + | ||
31 | + bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size, | ||
32 | + PREALLOC_MODE_OFF, &local_err); | ||
33 | + if (local_err) { | ||
34 | + warn_reportf_err(local_err, | ||
35 | + "Failed to truncate the tail of the image: "); | ||
36 | } | ||
37 | } | ||
38 | } else { | ||
39 | -- | ||
40 | 2.13.6 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | Some qcow2 functions (at least perform_cow()) expect s->lock to be | ||
4 | taken. Therefore, if we want to make use of them, we should execute | ||
5 | preallocate() (as "preallocate_co") in a coroutine so that we can use | ||
6 | the qemu_co_mutex_* functions. | ||
7 | |||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | Message-id: 20171009215533.12530-3-mreitz@redhat.com | ||
10 | Cc: qemu-stable@nongnu.org | ||
11 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
12 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
13 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
15 | --- | ||
16 | block/qcow2.c | 41 ++++++++++++++++++++++++++++++++++------- | ||
17 | 1 file changed, 34 insertions(+), 7 deletions(-) | ||
18 | |||
19 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/block/qcow2.c | ||
22 | +++ b/block/qcow2.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static int qcow2_set_up_encryption(BlockDriverState *bs, const char *encryptfmt, | ||
24 | } | ||
25 | |||
26 | |||
27 | +typedef struct PreallocCo { | ||
28 | + BlockDriverState *bs; | ||
29 | + uint64_t offset; | ||
30 | + uint64_t new_length; | ||
31 | + | ||
32 | + int ret; | ||
33 | +} PreallocCo; | ||
34 | + | ||
35 | /** | ||
36 | * Preallocates metadata structures for data clusters between @offset (in the | ||
37 | * guest disk) and @new_length (which is thus generally the new guest disk | ||
38 | @@ -XXX,XX +XXX,XX @@ static int qcow2_set_up_encryption(BlockDriverState *bs, const char *encryptfmt, | ||
39 | * | ||
40 | * Returns: 0 on success, -errno on failure. | ||
41 | */ | ||
42 | -static int preallocate(BlockDriverState *bs, | ||
43 | - uint64_t offset, uint64_t new_length) | ||
44 | +static void coroutine_fn preallocate_co(void *opaque) | ||
45 | { | ||
46 | + PreallocCo *params = opaque; | ||
47 | + BlockDriverState *bs = params->bs; | ||
48 | + uint64_t offset = params->offset; | ||
49 | + uint64_t new_length = params->new_length; | ||
50 | BDRVQcow2State *s = bs->opaque; | ||
51 | uint64_t bytes; | ||
52 | uint64_t host_offset = 0; | ||
53 | @@ -XXX,XX +XXX,XX @@ static int preallocate(BlockDriverState *bs, | ||
54 | int ret; | ||
55 | QCowL2Meta *meta; | ||
56 | |||
57 | - if (qemu_in_coroutine()) { | ||
58 | - qemu_co_mutex_lock(&s->lock); | ||
59 | - } | ||
60 | + qemu_co_mutex_lock(&s->lock); | ||
61 | |||
62 | assert(offset <= new_length); | ||
63 | bytes = new_length - offset; | ||
64 | @@ -XXX,XX +XXX,XX @@ static int preallocate(BlockDriverState *bs, | ||
65 | ret = 0; | ||
66 | |||
67 | done: | ||
68 | + qemu_co_mutex_unlock(&s->lock); | ||
69 | + params->ret = ret; | ||
70 | +} | ||
71 | + | ||
72 | +static int preallocate(BlockDriverState *bs, | ||
73 | + uint64_t offset, uint64_t new_length) | ||
74 | +{ | ||
75 | + PreallocCo params = { | ||
76 | + .bs = bs, | ||
77 | + .offset = offset, | ||
78 | + .new_length = new_length, | ||
79 | + .ret = -EINPROGRESS, | ||
80 | + }; | ||
81 | + | ||
82 | if (qemu_in_coroutine()) { | ||
83 | - qemu_co_mutex_unlock(&s->lock); | ||
84 | + preallocate_co(¶ms); | ||
85 | + } else { | ||
86 | + Coroutine *co = qemu_coroutine_create(preallocate_co, ¶ms); | ||
87 | + bdrv_coroutine_enter(bs, co); | ||
88 | + BDRV_POLL_WHILE(bs, params.ret == -EINPROGRESS); | ||
89 | } | ||
90 | - return ret; | ||
91 | + return params.ret; | ||
92 | } | ||
93 | |||
94 | /* qcow2_refcount_metadata_size: | ||
95 | -- | ||
96 | 2.13.6 | ||
97 | |||
98 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Max Reitz <mreitz@redhat.com> | ||
2 | 1 | ||
3 | Apparently it would be a good idea to test that, too. | ||
4 | |||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Message-id: 20171009215533.12530-4-mreitz@redhat.com | ||
7 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
8 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/125 | 7 +- | ||
13 | tests/qemu-iotests/125.out | 480 ++++++++++++++++++++++++++++++++++++++++----- | ||
14 | 2 files changed, 437 insertions(+), 50 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/125 b/tests/qemu-iotests/125 | ||
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/tests/qemu-iotests/125 | ||
19 | +++ b/tests/qemu-iotests/125 | ||
20 | @@ -XXX,XX +XXX,XX @@ fi | ||
21 | # in B | ||
22 | CREATION_SIZE=$((2 * 1024 * 1024 - 48 * 1024)) | ||
23 | |||
24 | +# 512 is the actual test -- but it's good to test 64k as well, just to be sure. | ||
25 | +for cluster_size in 512 64k; do | ||
26 | # in kB | ||
27 | for GROWTH_SIZE in 16 48 80; do | ||
28 | for create_mode in off metadata falloc full; do | ||
29 | for growth_mode in off metadata falloc full; do | ||
30 | - echo "--- growth_size=$GROWTH_SIZE create_mode=$create_mode growth_mode=$growth_mode ---" | ||
31 | + echo "--- cluster_size=$cluster_size growth_size=$GROWTH_SIZE create_mode=$create_mode growth_mode=$growth_mode ---" | ||
32 | |||
33 | - IMGOPTS="preallocation=$create_mode,cluster_size=512" _make_test_img ${CREATION_SIZE} | ||
34 | + IMGOPTS="preallocation=$create_mode,cluster_size=$cluster_size" _make_test_img ${CREATION_SIZE} | ||
35 | $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K | ||
36 | |||
37 | host_size_0=$(get_image_size_on_host) | ||
38 | @@ -XXX,XX +XXX,XX @@ for GROWTH_SIZE in 16 48 80; do | ||
39 | done | ||
40 | done | ||
41 | done | ||
42 | +done | ||
43 | |||
44 | # success, all done | ||
45 | echo '*** done' | ||
46 | diff --git a/tests/qemu-iotests/125.out b/tests/qemu-iotests/125.out | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/tests/qemu-iotests/125.out | ||
49 | +++ b/tests/qemu-iotests/125.out | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | QA output created by 125 | ||
52 | ---- growth_size=16 create_mode=off growth_mode=off --- | ||
53 | +--- cluster_size=512 growth_size=16 create_mode=off growth_mode=off --- | ||
54 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
55 | Image resized. | ||
56 | wrote 2048000/2048000 bytes at offset 0 | ||
57 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
58 | wrote 16384/16384 bytes at offset 2048000 | ||
59 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
60 | |||
61 | ---- growth_size=16 create_mode=off growth_mode=metadata --- | ||
62 | +--- cluster_size=512 growth_size=16 create_mode=off growth_mode=metadata --- | ||
63 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
64 | Image resized. | ||
65 | wrote 2048000/2048000 bytes at offset 0 | ||
66 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
67 | wrote 16384/16384 bytes at offset 2048000 | ||
68 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
69 | |||
70 | ---- growth_size=16 create_mode=off growth_mode=falloc --- | ||
71 | +--- cluster_size=512 growth_size=16 create_mode=off growth_mode=falloc --- | ||
72 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
73 | Image resized. | ||
74 | wrote 2048000/2048000 bytes at offset 0 | ||
75 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
76 | wrote 16384/16384 bytes at offset 2048000 | ||
77 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
78 | |||
79 | ---- growth_size=16 create_mode=off growth_mode=full --- | ||
80 | +--- cluster_size=512 growth_size=16 create_mode=off growth_mode=full --- | ||
81 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
82 | Image resized. | ||
83 | wrote 2048000/2048000 bytes at offset 0 | ||
84 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
85 | wrote 16384/16384 bytes at offset 2048000 | ||
86 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
87 | |||
88 | ---- growth_size=16 create_mode=metadata growth_mode=off --- | ||
89 | +--- cluster_size=512 growth_size=16 create_mode=metadata growth_mode=off --- | ||
90 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
91 | Image resized. | ||
92 | wrote 2048000/2048000 bytes at offset 0 | ||
93 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
94 | wrote 16384/16384 bytes at offset 2048000 | ||
95 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
96 | |||
97 | ---- growth_size=16 create_mode=metadata growth_mode=metadata --- | ||
98 | +--- cluster_size=512 growth_size=16 create_mode=metadata growth_mode=metadata --- | ||
99 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
100 | Image resized. | ||
101 | wrote 2048000/2048000 bytes at offset 0 | ||
102 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
103 | wrote 16384/16384 bytes at offset 2048000 | ||
104 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
105 | |||
106 | ---- growth_size=16 create_mode=metadata growth_mode=falloc --- | ||
107 | +--- cluster_size=512 growth_size=16 create_mode=metadata growth_mode=falloc --- | ||
108 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
109 | Image resized. | ||
110 | wrote 2048000/2048000 bytes at offset 0 | ||
111 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
112 | wrote 16384/16384 bytes at offset 2048000 | ||
113 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
114 | |||
115 | ---- growth_size=16 create_mode=metadata growth_mode=full --- | ||
116 | +--- cluster_size=512 growth_size=16 create_mode=metadata growth_mode=full --- | ||
117 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
118 | Image resized. | ||
119 | wrote 2048000/2048000 bytes at offset 0 | ||
120 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
121 | wrote 16384/16384 bytes at offset 2048000 | ||
122 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
123 | |||
124 | ---- growth_size=16 create_mode=falloc growth_mode=off --- | ||
125 | +--- cluster_size=512 growth_size=16 create_mode=falloc growth_mode=off --- | ||
126 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
127 | Image resized. | ||
128 | wrote 2048000/2048000 bytes at offset 0 | ||
129 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
130 | wrote 16384/16384 bytes at offset 2048000 | ||
131 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
132 | |||
133 | ---- growth_size=16 create_mode=falloc growth_mode=metadata --- | ||
134 | +--- cluster_size=512 growth_size=16 create_mode=falloc growth_mode=metadata --- | ||
135 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
136 | Image resized. | ||
137 | wrote 2048000/2048000 bytes at offset 0 | ||
138 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
139 | wrote 16384/16384 bytes at offset 2048000 | ||
140 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
141 | |||
142 | ---- growth_size=16 create_mode=falloc growth_mode=falloc --- | ||
143 | +--- cluster_size=512 growth_size=16 create_mode=falloc growth_mode=falloc --- | ||
144 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
145 | Image resized. | ||
146 | wrote 2048000/2048000 bytes at offset 0 | ||
147 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
148 | wrote 16384/16384 bytes at offset 2048000 | ||
149 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
150 | |||
151 | ---- growth_size=16 create_mode=falloc growth_mode=full --- | ||
152 | +--- cluster_size=512 growth_size=16 create_mode=falloc growth_mode=full --- | ||
153 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
154 | Image resized. | ||
155 | wrote 2048000/2048000 bytes at offset 0 | ||
156 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
157 | wrote 16384/16384 bytes at offset 2048000 | ||
158 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
159 | |||
160 | ---- growth_size=16 create_mode=full growth_mode=off --- | ||
161 | +--- cluster_size=512 growth_size=16 create_mode=full growth_mode=off --- | ||
162 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
163 | Image resized. | ||
164 | wrote 2048000/2048000 bytes at offset 0 | ||
165 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
166 | wrote 16384/16384 bytes at offset 2048000 | ||
167 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
168 | |||
169 | ---- growth_size=16 create_mode=full growth_mode=metadata --- | ||
170 | +--- cluster_size=512 growth_size=16 create_mode=full growth_mode=metadata --- | ||
171 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
172 | Image resized. | ||
173 | wrote 2048000/2048000 bytes at offset 0 | ||
174 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
175 | wrote 16384/16384 bytes at offset 2048000 | ||
176 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
177 | |||
178 | ---- growth_size=16 create_mode=full growth_mode=falloc --- | ||
179 | +--- cluster_size=512 growth_size=16 create_mode=full growth_mode=falloc --- | ||
180 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
181 | Image resized. | ||
182 | wrote 2048000/2048000 bytes at offset 0 | ||
183 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
184 | wrote 16384/16384 bytes at offset 2048000 | ||
185 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
186 | |||
187 | ---- growth_size=16 create_mode=full growth_mode=full --- | ||
188 | +--- cluster_size=512 growth_size=16 create_mode=full growth_mode=full --- | ||
189 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
190 | Image resized. | ||
191 | wrote 2048000/2048000 bytes at offset 0 | ||
192 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
193 | wrote 16384/16384 bytes at offset 2048000 | ||
194 | 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
195 | |||
196 | ---- growth_size=48 create_mode=off growth_mode=off --- | ||
197 | +--- cluster_size=512 growth_size=48 create_mode=off growth_mode=off --- | ||
198 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
199 | Image resized. | ||
200 | wrote 2048000/2048000 bytes at offset 0 | ||
201 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
202 | wrote 49152/49152 bytes at offset 2048000 | ||
203 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
204 | |||
205 | ---- growth_size=48 create_mode=off growth_mode=metadata --- | ||
206 | +--- cluster_size=512 growth_size=48 create_mode=off growth_mode=metadata --- | ||
207 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
208 | Image resized. | ||
209 | wrote 2048000/2048000 bytes at offset 0 | ||
210 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
211 | wrote 49152/49152 bytes at offset 2048000 | ||
212 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
213 | |||
214 | ---- growth_size=48 create_mode=off growth_mode=falloc --- | ||
215 | +--- cluster_size=512 growth_size=48 create_mode=off growth_mode=falloc --- | ||
216 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
217 | Image resized. | ||
218 | wrote 2048000/2048000 bytes at offset 0 | ||
219 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
220 | wrote 49152/49152 bytes at offset 2048000 | ||
221 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
222 | |||
223 | ---- growth_size=48 create_mode=off growth_mode=full --- | ||
224 | +--- cluster_size=512 growth_size=48 create_mode=off growth_mode=full --- | ||
225 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
226 | Image resized. | ||
227 | wrote 2048000/2048000 bytes at offset 0 | ||
228 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
229 | wrote 49152/49152 bytes at offset 2048000 | ||
230 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
231 | |||
232 | ---- growth_size=48 create_mode=metadata growth_mode=off --- | ||
233 | +--- cluster_size=512 growth_size=48 create_mode=metadata growth_mode=off --- | ||
234 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
235 | Image resized. | ||
236 | wrote 2048000/2048000 bytes at offset 0 | ||
237 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
238 | wrote 49152/49152 bytes at offset 2048000 | ||
239 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
240 | |||
241 | ---- growth_size=48 create_mode=metadata growth_mode=metadata --- | ||
242 | +--- cluster_size=512 growth_size=48 create_mode=metadata growth_mode=metadata --- | ||
243 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
244 | Image resized. | ||
245 | wrote 2048000/2048000 bytes at offset 0 | ||
246 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
247 | wrote 49152/49152 bytes at offset 2048000 | ||
248 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
249 | |||
250 | ---- growth_size=48 create_mode=metadata growth_mode=falloc --- | ||
251 | +--- cluster_size=512 growth_size=48 create_mode=metadata growth_mode=falloc --- | ||
252 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
253 | Image resized. | ||
254 | wrote 2048000/2048000 bytes at offset 0 | ||
255 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
256 | wrote 49152/49152 bytes at offset 2048000 | ||
257 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
258 | |||
259 | ---- growth_size=48 create_mode=metadata growth_mode=full --- | ||
260 | +--- cluster_size=512 growth_size=48 create_mode=metadata growth_mode=full --- | ||
261 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
262 | Image resized. | ||
263 | wrote 2048000/2048000 bytes at offset 0 | ||
264 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
265 | wrote 49152/49152 bytes at offset 2048000 | ||
266 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
267 | |||
268 | ---- growth_size=48 create_mode=falloc growth_mode=off --- | ||
269 | +--- cluster_size=512 growth_size=48 create_mode=falloc growth_mode=off --- | ||
270 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
271 | Image resized. | ||
272 | wrote 2048000/2048000 bytes at offset 0 | ||
273 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
274 | wrote 49152/49152 bytes at offset 2048000 | ||
275 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
276 | |||
277 | ---- growth_size=48 create_mode=falloc growth_mode=metadata --- | ||
278 | +--- cluster_size=512 growth_size=48 create_mode=falloc growth_mode=metadata --- | ||
279 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
280 | Image resized. | ||
281 | wrote 2048000/2048000 bytes at offset 0 | ||
282 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
283 | wrote 49152/49152 bytes at offset 2048000 | ||
284 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
285 | |||
286 | ---- growth_size=48 create_mode=falloc growth_mode=falloc --- | ||
287 | +--- cluster_size=512 growth_size=48 create_mode=falloc growth_mode=falloc --- | ||
288 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
289 | Image resized. | ||
290 | wrote 2048000/2048000 bytes at offset 0 | ||
291 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
292 | wrote 49152/49152 bytes at offset 2048000 | ||
293 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
294 | |||
295 | ---- growth_size=48 create_mode=falloc growth_mode=full --- | ||
296 | +--- cluster_size=512 growth_size=48 create_mode=falloc growth_mode=full --- | ||
297 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
298 | Image resized. | ||
299 | wrote 2048000/2048000 bytes at offset 0 | ||
300 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
301 | wrote 49152/49152 bytes at offset 2048000 | ||
302 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
303 | |||
304 | ---- growth_size=48 create_mode=full growth_mode=off --- | ||
305 | +--- cluster_size=512 growth_size=48 create_mode=full growth_mode=off --- | ||
306 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
307 | Image resized. | ||
308 | wrote 2048000/2048000 bytes at offset 0 | ||
309 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
310 | wrote 49152/49152 bytes at offset 2048000 | ||
311 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
312 | |||
313 | ---- growth_size=48 create_mode=full growth_mode=metadata --- | ||
314 | +--- cluster_size=512 growth_size=48 create_mode=full growth_mode=metadata --- | ||
315 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
316 | Image resized. | ||
317 | wrote 2048000/2048000 bytes at offset 0 | ||
318 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
319 | wrote 49152/49152 bytes at offset 2048000 | ||
320 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
321 | |||
322 | ---- growth_size=48 create_mode=full growth_mode=falloc --- | ||
323 | +--- cluster_size=512 growth_size=48 create_mode=full growth_mode=falloc --- | ||
324 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
325 | Image resized. | ||
326 | wrote 2048000/2048000 bytes at offset 0 | ||
327 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
328 | wrote 49152/49152 bytes at offset 2048000 | ||
329 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
330 | |||
331 | ---- growth_size=48 create_mode=full growth_mode=full --- | ||
332 | +--- cluster_size=512 growth_size=48 create_mode=full growth_mode=full --- | ||
333 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
334 | Image resized. | ||
335 | wrote 2048000/2048000 bytes at offset 0 | ||
336 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
337 | wrote 49152/49152 bytes at offset 2048000 | ||
338 | 48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
339 | |||
340 | ---- growth_size=80 create_mode=off growth_mode=off --- | ||
341 | +--- cluster_size=512 growth_size=80 create_mode=off growth_mode=off --- | ||
342 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
343 | Image resized. | ||
344 | wrote 2048000/2048000 bytes at offset 0 | ||
345 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
346 | wrote 81920/81920 bytes at offset 2048000 | ||
347 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
348 | |||
349 | ---- growth_size=80 create_mode=off growth_mode=metadata --- | ||
350 | +--- cluster_size=512 growth_size=80 create_mode=off growth_mode=metadata --- | ||
351 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
352 | Image resized. | ||
353 | wrote 2048000/2048000 bytes at offset 0 | ||
354 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
355 | wrote 81920/81920 bytes at offset 2048000 | ||
356 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
357 | |||
358 | ---- growth_size=80 create_mode=off growth_mode=falloc --- | ||
359 | +--- cluster_size=512 growth_size=80 create_mode=off growth_mode=falloc --- | ||
360 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
361 | Image resized. | ||
362 | wrote 2048000/2048000 bytes at offset 0 | ||
363 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
364 | wrote 81920/81920 bytes at offset 2048000 | ||
365 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
366 | |||
367 | ---- growth_size=80 create_mode=off growth_mode=full --- | ||
368 | +--- cluster_size=512 growth_size=80 create_mode=off growth_mode=full --- | ||
369 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
370 | Image resized. | ||
371 | wrote 2048000/2048000 bytes at offset 0 | ||
372 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
373 | wrote 81920/81920 bytes at offset 2048000 | ||
374 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
375 | |||
376 | ---- growth_size=80 create_mode=metadata growth_mode=off --- | ||
377 | +--- cluster_size=512 growth_size=80 create_mode=metadata growth_mode=off --- | ||
378 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
379 | Image resized. | ||
380 | wrote 2048000/2048000 bytes at offset 0 | ||
381 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
382 | wrote 81920/81920 bytes at offset 2048000 | ||
383 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
384 | |||
385 | ---- growth_size=80 create_mode=metadata growth_mode=metadata --- | ||
386 | +--- cluster_size=512 growth_size=80 create_mode=metadata growth_mode=metadata --- | ||
387 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
388 | Image resized. | ||
389 | wrote 2048000/2048000 bytes at offset 0 | ||
390 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
391 | wrote 81920/81920 bytes at offset 2048000 | ||
392 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
393 | |||
394 | ---- growth_size=80 create_mode=metadata growth_mode=falloc --- | ||
395 | +--- cluster_size=512 growth_size=80 create_mode=metadata growth_mode=falloc --- | ||
396 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
397 | Image resized. | ||
398 | wrote 2048000/2048000 bytes at offset 0 | ||
399 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
400 | wrote 81920/81920 bytes at offset 2048000 | ||
401 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
402 | |||
403 | ---- growth_size=80 create_mode=metadata growth_mode=full --- | ||
404 | +--- cluster_size=512 growth_size=80 create_mode=metadata growth_mode=full --- | ||
405 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
406 | Image resized. | ||
407 | wrote 2048000/2048000 bytes at offset 0 | ||
408 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
409 | wrote 81920/81920 bytes at offset 2048000 | ||
410 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
411 | |||
412 | ---- growth_size=80 create_mode=falloc growth_mode=off --- | ||
413 | +--- cluster_size=512 growth_size=80 create_mode=falloc growth_mode=off --- | ||
414 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
415 | Image resized. | ||
416 | wrote 2048000/2048000 bytes at offset 0 | ||
417 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
418 | wrote 81920/81920 bytes at offset 2048000 | ||
419 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
420 | |||
421 | ---- growth_size=80 create_mode=falloc growth_mode=metadata --- | ||
422 | +--- cluster_size=512 growth_size=80 create_mode=falloc growth_mode=metadata --- | ||
423 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
424 | Image resized. | ||
425 | wrote 2048000/2048000 bytes at offset 0 | ||
426 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
427 | wrote 81920/81920 bytes at offset 2048000 | ||
428 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
429 | |||
430 | ---- growth_size=80 create_mode=falloc growth_mode=falloc --- | ||
431 | +--- cluster_size=512 growth_size=80 create_mode=falloc growth_mode=falloc --- | ||
432 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
433 | Image resized. | ||
434 | wrote 2048000/2048000 bytes at offset 0 | ||
435 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
436 | wrote 81920/81920 bytes at offset 2048000 | ||
437 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
438 | |||
439 | ---- growth_size=80 create_mode=falloc growth_mode=full --- | ||
440 | +--- cluster_size=512 growth_size=80 create_mode=falloc growth_mode=full --- | ||
441 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
442 | Image resized. | ||
443 | wrote 2048000/2048000 bytes at offset 0 | ||
444 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
445 | wrote 81920/81920 bytes at offset 2048000 | ||
446 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
447 | |||
448 | ---- growth_size=80 create_mode=full growth_mode=off --- | ||
449 | +--- cluster_size=512 growth_size=80 create_mode=full growth_mode=off --- | ||
450 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
451 | Image resized. | ||
452 | wrote 2048000/2048000 bytes at offset 0 | ||
453 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
454 | wrote 81920/81920 bytes at offset 2048000 | ||
455 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
456 | |||
457 | ---- growth_size=80 create_mode=full growth_mode=metadata --- | ||
458 | +--- cluster_size=512 growth_size=80 create_mode=full growth_mode=metadata --- | ||
459 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
460 | Image resized. | ||
461 | wrote 2048000/2048000 bytes at offset 0 | ||
462 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
463 | wrote 81920/81920 bytes at offset 2048000 | ||
464 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
465 | |||
466 | ---- growth_size=80 create_mode=full growth_mode=falloc --- | ||
467 | +--- cluster_size=512 growth_size=80 create_mode=full growth_mode=falloc --- | ||
468 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
469 | Image resized. | ||
470 | wrote 2048000/2048000 bytes at offset 0 | ||
471 | @@ -XXX,XX +XXX,XX @@ wrote 2048000/2048000 bytes at offset 0 | ||
472 | wrote 81920/81920 bytes at offset 2048000 | ||
473 | 80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
474 | |||
475 | ---- growth_size=80 create_mode=full growth_mode=full --- | ||
476 | +--- cluster_size=512 growth_size=80 create_mode=full growth_mode=full --- | ||
477 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
478 | +Image resized. | ||
479 | +wrote 2048000/2048000 bytes at offset 0 | ||
480 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
481 | +wrote 81920/81920 bytes at offset 2048000 | ||
482 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
483 | + | ||
484 | +--- cluster_size=64k growth_size=16 create_mode=off growth_mode=off --- | ||
485 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
486 | +Image resized. | ||
487 | +wrote 2048000/2048000 bytes at offset 0 | ||
488 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
489 | +wrote 16384/16384 bytes at offset 2048000 | ||
490 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
491 | + | ||
492 | +--- cluster_size=64k growth_size=16 create_mode=off growth_mode=metadata --- | ||
493 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
494 | +Image resized. | ||
495 | +wrote 2048000/2048000 bytes at offset 0 | ||
496 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
497 | +wrote 16384/16384 bytes at offset 2048000 | ||
498 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
499 | + | ||
500 | +--- cluster_size=64k growth_size=16 create_mode=off growth_mode=falloc --- | ||
501 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
502 | +Image resized. | ||
503 | +wrote 2048000/2048000 bytes at offset 0 | ||
504 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
505 | +wrote 16384/16384 bytes at offset 2048000 | ||
506 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
507 | + | ||
508 | +--- cluster_size=64k growth_size=16 create_mode=off growth_mode=full --- | ||
509 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
510 | +Image resized. | ||
511 | +wrote 2048000/2048000 bytes at offset 0 | ||
512 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
513 | +wrote 16384/16384 bytes at offset 2048000 | ||
514 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
515 | + | ||
516 | +--- cluster_size=64k growth_size=16 create_mode=metadata growth_mode=off --- | ||
517 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
518 | +Image resized. | ||
519 | +wrote 2048000/2048000 bytes at offset 0 | ||
520 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
521 | +wrote 16384/16384 bytes at offset 2048000 | ||
522 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
523 | + | ||
524 | +--- cluster_size=64k growth_size=16 create_mode=metadata growth_mode=metadata --- | ||
525 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
526 | +Image resized. | ||
527 | +wrote 2048000/2048000 bytes at offset 0 | ||
528 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
529 | +wrote 16384/16384 bytes at offset 2048000 | ||
530 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
531 | + | ||
532 | +--- cluster_size=64k growth_size=16 create_mode=metadata growth_mode=falloc --- | ||
533 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
534 | +Image resized. | ||
535 | +wrote 2048000/2048000 bytes at offset 0 | ||
536 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
537 | +wrote 16384/16384 bytes at offset 2048000 | ||
538 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
539 | + | ||
540 | +--- cluster_size=64k growth_size=16 create_mode=metadata growth_mode=full --- | ||
541 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
542 | +Image resized. | ||
543 | +wrote 2048000/2048000 bytes at offset 0 | ||
544 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
545 | +wrote 16384/16384 bytes at offset 2048000 | ||
546 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
547 | + | ||
548 | +--- cluster_size=64k growth_size=16 create_mode=falloc growth_mode=off --- | ||
549 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
550 | +Image resized. | ||
551 | +wrote 2048000/2048000 bytes at offset 0 | ||
552 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
553 | +wrote 16384/16384 bytes at offset 2048000 | ||
554 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
555 | + | ||
556 | +--- cluster_size=64k growth_size=16 create_mode=falloc growth_mode=metadata --- | ||
557 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
558 | +Image resized. | ||
559 | +wrote 2048000/2048000 bytes at offset 0 | ||
560 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
561 | +wrote 16384/16384 bytes at offset 2048000 | ||
562 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
563 | + | ||
564 | +--- cluster_size=64k growth_size=16 create_mode=falloc growth_mode=falloc --- | ||
565 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
566 | +Image resized. | ||
567 | +wrote 2048000/2048000 bytes at offset 0 | ||
568 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
569 | +wrote 16384/16384 bytes at offset 2048000 | ||
570 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
571 | + | ||
572 | +--- cluster_size=64k growth_size=16 create_mode=falloc growth_mode=full --- | ||
573 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
574 | +Image resized. | ||
575 | +wrote 2048000/2048000 bytes at offset 0 | ||
576 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
577 | +wrote 16384/16384 bytes at offset 2048000 | ||
578 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
579 | + | ||
580 | +--- cluster_size=64k growth_size=16 create_mode=full growth_mode=off --- | ||
581 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
582 | +Image resized. | ||
583 | +wrote 2048000/2048000 bytes at offset 0 | ||
584 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
585 | +wrote 16384/16384 bytes at offset 2048000 | ||
586 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
587 | + | ||
588 | +--- cluster_size=64k growth_size=16 create_mode=full growth_mode=metadata --- | ||
589 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
590 | +Image resized. | ||
591 | +wrote 2048000/2048000 bytes at offset 0 | ||
592 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
593 | +wrote 16384/16384 bytes at offset 2048000 | ||
594 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
595 | + | ||
596 | +--- cluster_size=64k growth_size=16 create_mode=full growth_mode=falloc --- | ||
597 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
598 | +Image resized. | ||
599 | +wrote 2048000/2048000 bytes at offset 0 | ||
600 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
601 | +wrote 16384/16384 bytes at offset 2048000 | ||
602 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
603 | + | ||
604 | +--- cluster_size=64k growth_size=16 create_mode=full growth_mode=full --- | ||
605 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
606 | +Image resized. | ||
607 | +wrote 2048000/2048000 bytes at offset 0 | ||
608 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
609 | +wrote 16384/16384 bytes at offset 2048000 | ||
610 | +16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
611 | + | ||
612 | +--- cluster_size=64k growth_size=48 create_mode=off growth_mode=off --- | ||
613 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
614 | +Image resized. | ||
615 | +wrote 2048000/2048000 bytes at offset 0 | ||
616 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
617 | +wrote 49152/49152 bytes at offset 2048000 | ||
618 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
619 | + | ||
620 | +--- cluster_size=64k growth_size=48 create_mode=off growth_mode=metadata --- | ||
621 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
622 | +Image resized. | ||
623 | +wrote 2048000/2048000 bytes at offset 0 | ||
624 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
625 | +wrote 49152/49152 bytes at offset 2048000 | ||
626 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
627 | + | ||
628 | +--- cluster_size=64k growth_size=48 create_mode=off growth_mode=falloc --- | ||
629 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
630 | +Image resized. | ||
631 | +wrote 2048000/2048000 bytes at offset 0 | ||
632 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
633 | +wrote 49152/49152 bytes at offset 2048000 | ||
634 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
635 | + | ||
636 | +--- cluster_size=64k growth_size=48 create_mode=off growth_mode=full --- | ||
637 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
638 | +Image resized. | ||
639 | +wrote 2048000/2048000 bytes at offset 0 | ||
640 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
641 | +wrote 49152/49152 bytes at offset 2048000 | ||
642 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
643 | + | ||
644 | +--- cluster_size=64k growth_size=48 create_mode=metadata growth_mode=off --- | ||
645 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
646 | +Image resized. | ||
647 | +wrote 2048000/2048000 bytes at offset 0 | ||
648 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
649 | +wrote 49152/49152 bytes at offset 2048000 | ||
650 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
651 | + | ||
652 | +--- cluster_size=64k growth_size=48 create_mode=metadata growth_mode=metadata --- | ||
653 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
654 | +Image resized. | ||
655 | +wrote 2048000/2048000 bytes at offset 0 | ||
656 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
657 | +wrote 49152/49152 bytes at offset 2048000 | ||
658 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
659 | + | ||
660 | +--- cluster_size=64k growth_size=48 create_mode=metadata growth_mode=falloc --- | ||
661 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
662 | +Image resized. | ||
663 | +wrote 2048000/2048000 bytes at offset 0 | ||
664 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
665 | +wrote 49152/49152 bytes at offset 2048000 | ||
666 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
667 | + | ||
668 | +--- cluster_size=64k growth_size=48 create_mode=metadata growth_mode=full --- | ||
669 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
670 | +Image resized. | ||
671 | +wrote 2048000/2048000 bytes at offset 0 | ||
672 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
673 | +wrote 49152/49152 bytes at offset 2048000 | ||
674 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
675 | + | ||
676 | +--- cluster_size=64k growth_size=48 create_mode=falloc growth_mode=off --- | ||
677 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
678 | +Image resized. | ||
679 | +wrote 2048000/2048000 bytes at offset 0 | ||
680 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
681 | +wrote 49152/49152 bytes at offset 2048000 | ||
682 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
683 | + | ||
684 | +--- cluster_size=64k growth_size=48 create_mode=falloc growth_mode=metadata --- | ||
685 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
686 | +Image resized. | ||
687 | +wrote 2048000/2048000 bytes at offset 0 | ||
688 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
689 | +wrote 49152/49152 bytes at offset 2048000 | ||
690 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
691 | + | ||
692 | +--- cluster_size=64k growth_size=48 create_mode=falloc growth_mode=falloc --- | ||
693 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
694 | +Image resized. | ||
695 | +wrote 2048000/2048000 bytes at offset 0 | ||
696 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
697 | +wrote 49152/49152 bytes at offset 2048000 | ||
698 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
699 | + | ||
700 | +--- cluster_size=64k growth_size=48 create_mode=falloc growth_mode=full --- | ||
701 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
702 | +Image resized. | ||
703 | +wrote 2048000/2048000 bytes at offset 0 | ||
704 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
705 | +wrote 49152/49152 bytes at offset 2048000 | ||
706 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
707 | + | ||
708 | +--- cluster_size=64k growth_size=48 create_mode=full growth_mode=off --- | ||
709 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
710 | +Image resized. | ||
711 | +wrote 2048000/2048000 bytes at offset 0 | ||
712 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
713 | +wrote 49152/49152 bytes at offset 2048000 | ||
714 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
715 | + | ||
716 | +--- cluster_size=64k growth_size=48 create_mode=full growth_mode=metadata --- | ||
717 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
718 | +Image resized. | ||
719 | +wrote 2048000/2048000 bytes at offset 0 | ||
720 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
721 | +wrote 49152/49152 bytes at offset 2048000 | ||
722 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
723 | + | ||
724 | +--- cluster_size=64k growth_size=48 create_mode=full growth_mode=falloc --- | ||
725 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
726 | +Image resized. | ||
727 | +wrote 2048000/2048000 bytes at offset 0 | ||
728 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
729 | +wrote 49152/49152 bytes at offset 2048000 | ||
730 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
731 | + | ||
732 | +--- cluster_size=64k growth_size=48 create_mode=full growth_mode=full --- | ||
733 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
734 | +Image resized. | ||
735 | +wrote 2048000/2048000 bytes at offset 0 | ||
736 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
737 | +wrote 49152/49152 bytes at offset 2048000 | ||
738 | +48 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
739 | + | ||
740 | +--- cluster_size=64k growth_size=80 create_mode=off growth_mode=off --- | ||
741 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
742 | +Image resized. | ||
743 | +wrote 2048000/2048000 bytes at offset 0 | ||
744 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
745 | +wrote 81920/81920 bytes at offset 2048000 | ||
746 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
747 | + | ||
748 | +--- cluster_size=64k growth_size=80 create_mode=off growth_mode=metadata --- | ||
749 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
750 | +Image resized. | ||
751 | +wrote 2048000/2048000 bytes at offset 0 | ||
752 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
753 | +wrote 81920/81920 bytes at offset 2048000 | ||
754 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
755 | + | ||
756 | +--- cluster_size=64k growth_size=80 create_mode=off growth_mode=falloc --- | ||
757 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
758 | +Image resized. | ||
759 | +wrote 2048000/2048000 bytes at offset 0 | ||
760 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
761 | +wrote 81920/81920 bytes at offset 2048000 | ||
762 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
763 | + | ||
764 | +--- cluster_size=64k growth_size=80 create_mode=off growth_mode=full --- | ||
765 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=off | ||
766 | +Image resized. | ||
767 | +wrote 2048000/2048000 bytes at offset 0 | ||
768 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
769 | +wrote 81920/81920 bytes at offset 2048000 | ||
770 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
771 | + | ||
772 | +--- cluster_size=64k growth_size=80 create_mode=metadata growth_mode=off --- | ||
773 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
774 | +Image resized. | ||
775 | +wrote 2048000/2048000 bytes at offset 0 | ||
776 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
777 | +wrote 81920/81920 bytes at offset 2048000 | ||
778 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
779 | + | ||
780 | +--- cluster_size=64k growth_size=80 create_mode=metadata growth_mode=metadata --- | ||
781 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
782 | +Image resized. | ||
783 | +wrote 2048000/2048000 bytes at offset 0 | ||
784 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
785 | +wrote 81920/81920 bytes at offset 2048000 | ||
786 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
787 | + | ||
788 | +--- cluster_size=64k growth_size=80 create_mode=metadata growth_mode=falloc --- | ||
789 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
790 | +Image resized. | ||
791 | +wrote 2048000/2048000 bytes at offset 0 | ||
792 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
793 | +wrote 81920/81920 bytes at offset 2048000 | ||
794 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
795 | + | ||
796 | +--- cluster_size=64k growth_size=80 create_mode=metadata growth_mode=full --- | ||
797 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=metadata | ||
798 | +Image resized. | ||
799 | +wrote 2048000/2048000 bytes at offset 0 | ||
800 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
801 | +wrote 81920/81920 bytes at offset 2048000 | ||
802 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
803 | + | ||
804 | +--- cluster_size=64k growth_size=80 create_mode=falloc growth_mode=off --- | ||
805 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
806 | +Image resized. | ||
807 | +wrote 2048000/2048000 bytes at offset 0 | ||
808 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
809 | +wrote 81920/81920 bytes at offset 2048000 | ||
810 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
811 | + | ||
812 | +--- cluster_size=64k growth_size=80 create_mode=falloc growth_mode=metadata --- | ||
813 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
814 | +Image resized. | ||
815 | +wrote 2048000/2048000 bytes at offset 0 | ||
816 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
817 | +wrote 81920/81920 bytes at offset 2048000 | ||
818 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
819 | + | ||
820 | +--- cluster_size=64k growth_size=80 create_mode=falloc growth_mode=falloc --- | ||
821 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
822 | +Image resized. | ||
823 | +wrote 2048000/2048000 bytes at offset 0 | ||
824 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
825 | +wrote 81920/81920 bytes at offset 2048000 | ||
826 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
827 | + | ||
828 | +--- cluster_size=64k growth_size=80 create_mode=falloc growth_mode=full --- | ||
829 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=falloc | ||
830 | +Image resized. | ||
831 | +wrote 2048000/2048000 bytes at offset 0 | ||
832 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
833 | +wrote 81920/81920 bytes at offset 2048000 | ||
834 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
835 | + | ||
836 | +--- cluster_size=64k growth_size=80 create_mode=full growth_mode=off --- | ||
837 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
838 | +Image resized. | ||
839 | +wrote 2048000/2048000 bytes at offset 0 | ||
840 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
841 | +wrote 81920/81920 bytes at offset 2048000 | ||
842 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
843 | + | ||
844 | +--- cluster_size=64k growth_size=80 create_mode=full growth_mode=metadata --- | ||
845 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
846 | +Image resized. | ||
847 | +wrote 2048000/2048000 bytes at offset 0 | ||
848 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
849 | +wrote 81920/81920 bytes at offset 2048000 | ||
850 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
851 | + | ||
852 | +--- cluster_size=64k growth_size=80 create_mode=full growth_mode=falloc --- | ||
853 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
854 | +Image resized. | ||
855 | +wrote 2048000/2048000 bytes at offset 0 | ||
856 | +1.953 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
857 | +wrote 81920/81920 bytes at offset 2048000 | ||
858 | +80 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
859 | + | ||
860 | +--- cluster_size=64k growth_size=80 create_mode=full growth_mode=full --- | ||
861 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2048000 preallocation=full | ||
862 | Image resized. | ||
863 | wrote 2048000/2048000 bytes at offset 0 | ||
864 | -- | ||
865 | 2.13.6 | ||
866 | |||
867 | diff view generated by jsdifflib |