1 | The following changes since commit ae49fbbcd8e4e9d8bf7131add34773f579e1aff7: | 1 | The following changes since commit efb4f3b62c69383a7308d7b739a3193e7c0ccae8: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20171025' into staging (2017-10-25 16:38:57 +0100) | 3 | Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2019-05-10 14:49:36 +0100) |
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 11f6fc50e7501b5f5d04100ea1c21fa8f1cf7b53: |
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 | iotests: Add test for rebase without input base (2019-05-10 16:45:40 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block layer patches | 14 | Block layer patches: |
15 | |||
16 | - block: Remove bdrv_read() and bdrv_write() | ||
17 | - qemu-img: Allow rebase with no input base | ||
18 | - blockjob: Fix coroutine thread after AioContext change | ||
19 | - MAINTAINERS updates for pflash, curl and gluster | ||
15 | 20 | ||
16 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
17 | Alberto Garcia (1): | 22 | Alberto Garcia (5): |
18 | qcow2: Use BDRV_SECTOR_BITS instead of its literal value | 23 | qcow2: Replace bdrv_write() with bdrv_pwrite() |
24 | vdi: Replace bdrv_{read,write}() with bdrv_{pread,pwrite}() | ||
25 | vvfat: Replace bdrv_{read,write}() with bdrv_{pread,pwrite}() | ||
26 | block: Remove bdrv_read() and bdrv_write() | ||
27 | qcow2: Remove BDRVQcow2State.cluster_sectors | ||
19 | 28 | ||
20 | Eric Blake (24): | 29 | Anton Kuchin (1): |
21 | block: Allow NULL file for bdrv_get_block_status() | 30 | block: remove bs from lists before closing |
22 | block: Add flag to avoid wasted work in bdrv_is_allocated() | ||
23 | block: Make bdrv_round_to_clusters() signature more useful | ||
24 | qcow2: Switch is_zero_sectors() to byte-based | ||
25 | block: Switch bdrv_make_zero() to byte-based | ||
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 | 31 | ||
46 | Kevin Wolf (2): | 32 | Kevin Wolf (3): |
47 | qemu-iotests: Test backing_fmt with backing node reference | 33 | qemu-iotests: Fix cleanup for 192 |
48 | Merge remote-tracking branch 'mreitz/tags/pull-block-2017-10-26' into queue-block | 34 | blockjob: Fix coroutine thread after AioContext change |
35 | test-block-iothread: Job coroutine thread after AioContext switch | ||
49 | 36 | ||
50 | Max Reitz (8): | 37 | Max Reitz (3): |
51 | qemu-img.1: Image invalidation on qemu-img commit | 38 | qemu-img: Allow rebase with no input base |
52 | iotests: Add test for dataplane mirroring | 39 | qemu-img: Use zero writes after source backing EOF |
53 | iotests: Pull _filter_actual_image_size from 67/87 | 40 | iotests: Add test for rebase without input base |
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 | 41 | ||
60 | Peter Krempa (1): | 42 | Philippe Mathieu-Daudé (1): |
61 | block: don't add 'driver' to options when referring to backing via node name | 43 | MAINTAINERS: Add an entry for the Parallel NOR Flash devices |
62 | 44 | ||
63 | include/block/block.h | 29 ++- | 45 | Stefano Garzarella (1): |
64 | include/block/block_int.h | 11 +- | 46 | qemu-img: Use IEC binary prefixes for size constants |
65 | block.c | 3 +- | ||
66 | block/blkdebug.c | 13 +- | ||
67 | block/io.c | 334 ++++++++++++++++----------- | ||
68 | block/mirror.c | 26 +-- | ||
69 | block/qcow2-cluster.c | 2 +- | ||
70 | block/qcow2.c | 116 ++++++---- | ||
71 | qemu-img.c | 381 ++++++++++++++----------------- | ||
72 | qemu-io-cmds.c | 13 -- | ||
73 | block/trace-events | 2 +- | ||
74 | qemu-img.texi | 9 +- | ||
75 | tests/qemu-iotests/067 | 2 +- | ||
76 | tests/qemu-iotests/074.out | 2 - | ||
77 | tests/qemu-iotests/087 | 2 +- | ||
78 | tests/qemu-iotests/125 | 7 +- | ||
79 | tests/qemu-iotests/125.out | 480 +++++++++++++++++++++++++++++++++++---- | ||
80 | tests/qemu-iotests/127 | 97 ++++++++ | ||
81 | tests/qemu-iotests/127.out | 14 ++ | ||
82 | tests/qemu-iotests/177 | 12 +- | ||
83 | tests/qemu-iotests/177.out | 19 +- | ||
84 | tests/qemu-iotests/184 | 3 +- | ||
85 | tests/qemu-iotests/184.out | 6 +- | ||
86 | tests/qemu-iotests/191 | 7 +- | ||
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 | 47 | ||
48 | Thomas Huth (1): | ||
49 | MAINTAINERS: Downgrade status of block sections without "M:" to "Odd Fixes" | ||
50 | |||
51 | block/qcow2.h | 1 - | ||
52 | include/block/block.h | 4 -- | ||
53 | block.c | 4 +- | ||
54 | block/io.c | 43 +++------------ | ||
55 | block/qcow2-refcount.c | 4 +- | ||
56 | block/qcow2.c | 1 - | ||
57 | block/vdi.c | 15 +++--- | ||
58 | block/vvfat.c | 12 +++-- | ||
59 | job.c | 2 +- | ||
60 | qemu-img.c | 77 ++++++++++++++++----------- | ||
61 | tests/test-block-iothread.c | 107 ++++++++++++++++++++++++++++++++++++++ | ||
62 | MAINTAINERS | 12 ++++- | ||
63 | tests/qemu-iotests/192 | 4 +- | ||
64 | tests/qemu-iotests/252 | 124 ++++++++++++++++++++++++++++++++++++++++++++ | ||
65 | tests/qemu-iotests/252.out | 39 ++++++++++++++ | ||
66 | tests/qemu-iotests/group | 1 + | ||
67 | 16 files changed, 358 insertions(+), 92 deletions(-) | ||
68 | create mode 100755 tests/qemu-iotests/252 | ||
69 | create mode 100644 tests/qemu-iotests/252.out | ||
70 | diff view generated by jsdifflib |
1 | From: Peter Krempa <pkrempa@redhat.com> | 1 | From: Anton Kuchin <antonkuchin@yandex-team.ru> |
---|---|---|---|
2 | 2 | ||
3 | When referring to a backing file of an image via node name | 3 | Close involves flush that can be performed asynchronously and bs |
4 | bdrv_open_backing_file would add the 'driver' option to the option list | 4 | must be protected from being referenced before it is deleted. |
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 | 5 | ||
9 | $ qemu-img create -f raw /tmp/backing.raw 64M | 6 | Signed-off-by: Anton Kuchin <antonkuchin@yandex-team.ru> |
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> | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
18 | --- | 8 | --- |
19 | block.c | 3 ++- | 9 | block.c | 4 ++-- |
20 | 1 file changed, 2 insertions(+), 1 deletion(-) | 10 | 1 file changed, 2 insertions(+), 2 deletions(-) |
21 | 11 | ||
22 | diff --git a/block.c b/block.c | 12 | diff --git a/block.c b/block.c |
23 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block.c | 14 | --- a/block.c |
25 | +++ b/block.c | 15 | +++ b/block.c |
26 | @@ -XXX,XX +XXX,XX @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, | 16 | @@ -XXX,XX +XXX,XX @@ static void bdrv_delete(BlockDriverState *bs) |
27 | goto free_exit; | 17 | assert(bdrv_op_blocker_is_empty(bs)); |
18 | assert(!bs->refcnt); | ||
19 | |||
20 | - bdrv_close(bs); | ||
21 | - | ||
22 | /* remove from list, if necessary */ | ||
23 | if (bs->node_name[0] != '\0') { | ||
24 | QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list); | ||
28 | } | 25 | } |
29 | 26 | QTAILQ_REMOVE(&all_bdrv_states, bs, bs_list); | |
30 | - if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { | 27 | |
31 | + if (!reference && | 28 | + bdrv_close(bs); |
32 | + bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { | 29 | + |
33 | qdict_put_str(options, "driver", bs->backing_format); | 30 | g_free(bs); |
34 | } | 31 | } |
35 | 32 | ||
36 | -- | 33 | -- |
37 | 2.13.6 | 34 | 2.20.1 |
38 | 35 | ||
39 | 36 | 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 |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | Not all callers care about which BDS owns the mapping for a given | ||
4 | range of the file. This patch merely simplifies the callers by | ||
5 | consolidating the logic in the common call point, while guaranteeing | ||
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 | |||
11 | Furthermore, this will also set the stage for a future cleanup: when | ||
12 | a caller does not care about which BDS owns an offset, it would be | ||
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> | ||
24 | --- | ||
25 | include/block/block_int.h | 10 ++++++---- | ||
26 | block/io.c | 49 ++++++++++++++++++++++++++--------------------- | ||
27 | block/mirror.c | 3 +-- | ||
28 | block/qcow2.c | 8 ++------ | ||
29 | qemu-img.c | 10 ++++------ | ||
30 | 5 files changed, 40 insertions(+), 40 deletions(-) | ||
31 | |||
32 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/include/block/block_int.h | ||
35 | +++ b/include/block/block_int.h | ||
36 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
37 | int64_t offset, int bytes); | ||
38 | |||
39 | /* | ||
40 | - * Building block for bdrv_block_status[_above]. The driver should | ||
41 | - * answer only according to the current layer, and should not | ||
42 | - * set BDRV_BLOCK_ALLOCATED, but may set BDRV_BLOCK_RAW. See block.h | ||
43 | - * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. | ||
44 | + * Building block for bdrv_block_status[_above] and | ||
45 | + * bdrv_is_allocated[_above]. The driver should answer only | ||
46 | + * according to the current layer, and should not set | ||
47 | + * BDRV_BLOCK_ALLOCATED, but may set BDRV_BLOCK_RAW. See block.h | ||
48 | + * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. The block | ||
49 | + * layer guarantees 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/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 | { | ||
59 | int64_t target_sectors, ret, nb_sectors, sector_num = 0; | ||
60 | BlockDriverState *bs = child->bs; | ||
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 | } | ||
174 | |||
175 | @@ -XXX,XX +XXX,XX @@ int64_t bdrv_get_block_status(BlockDriverState *bs, | ||
176 | int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | ||
177 | int64_t bytes, int64_t *pnum) | ||
178 | { | ||
179 | - BlockDriverState *file; | ||
180 | int64_t sector_num = offset >> BDRV_SECTOR_BITS; | ||
181 | int nb_sectors = bytes >> BDRV_SECTOR_BITS; | ||
182 | int64_t ret; | ||
183 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset, | ||
184 | assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); | ||
185 | assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE) && bytes < INT_MAX); | ||
186 | ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &psectors, | ||
187 | - &file); | ||
188 | + NULL); | ||
189 | if (ret < 0) { | ||
190 | return ret; | ||
191 | } | ||
192 | diff --git a/block/mirror.c b/block/mirror.c | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/block/mirror.c | ||
195 | +++ b/block/mirror.c | ||
196 | @@ -XXX,XX +XXX,XX @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) | ||
197 | int io_sectors; | ||
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 | -- | ||
299 | 2.13.6 | ||
300 | |||
301 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Now that bdrv_is_allocated accepts non-aligned inputs, we can | 3 | Fixes might still get picked up via the qemu-block mailing list, |
4 | remove the TODO added in earlier refactoring. | 4 | so the status is not "Orphan" yet. |
5 | Also add the gluster mailing list as suggested by Niels here: | ||
5 | 6 | ||
6 | Signed-off-by: Eric Blake <eblake@redhat.com> | 7 | https://patchwork.kernel.org/patch/10613297/#22409943 |
8 | |||
9 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Reviewed-by: Niels de Vos <ndevos@redhat.com> | ||
7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 12 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
8 | --- | 13 | --- |
9 | block/qcow2.c | 12 +++--------- | 14 | MAINTAINERS | 5 +++-- |
10 | 1 file changed, 3 insertions(+), 9 deletions(-) | 15 | 1 file changed, 3 insertions(+), 2 deletions(-) |
11 | 16 | ||
12 | diff --git a/block/qcow2.c b/block/qcow2.c | 17 | diff --git a/MAINTAINERS b/MAINTAINERS |
13 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/block/qcow2.c | 19 | --- a/MAINTAINERS |
15 | +++ b/block/qcow2.c | 20 | +++ b/MAINTAINERS |
16 | @@ -XXX,XX +XXX,XX @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) | 21 | @@ -XXX,XX +XXX,XX @@ F: block/ssh.c |
17 | { | 22 | |
18 | int64_t nr; | 23 | CURL |
19 | int res; | 24 | L: qemu-block@nongnu.org |
20 | - int64_t start; | 25 | -S: Supported |
21 | - | 26 | +S: Odd Fixes |
22 | - /* TODO: Widening to sector boundaries should only be needed as | 27 | F: block/curl.c |
23 | - * long as we can't query finer granularity. */ | 28 | |
24 | - start = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); | 29 | GLUSTER |
25 | - bytes = QEMU_ALIGN_UP(offset + bytes, BDRV_SECTOR_SIZE) - start; | 30 | L: qemu-block@nongnu.org |
26 | 31 | -S: Supported | |
27 | /* Clamp to image length, before checking status of underlying sectors */ | 32 | +L: integration@gluster.org |
28 | - if (start + bytes > bs->total_sectors * BDRV_SECTOR_SIZE) { | 33 | +S: Odd Fixes |
29 | - bytes = bs->total_sectors * BDRV_SECTOR_SIZE - start; | 34 | F: block/gluster.c |
30 | + if (offset + bytes > bs->total_sectors * BDRV_SECTOR_SIZE) { | 35 | |
31 | + bytes = bs->total_sectors * BDRV_SECTOR_SIZE - offset; | 36 | Null Block Driver |
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 | -- | 37 | -- |
43 | 2.13.6 | 38 | 2.20.1 |
44 | 39 | ||
45 | 40 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | qemu-img commit invalidates all images between base and top. This | 3 | Step in to maintain it, since I have some familiarity with |
4 | should be mentioned in the man page. | 4 | the technology. |
5 | 5 | ||
6 | Suggested-by: Ping Li <pingl@redhat.com> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Acked-by: Laszlo Ersek <lersek@redhat.com> |
8 | Reviewed-by: Jeff Cody <jcody@redhat.com> | 8 | Acked-by: Michael S. Tsirkin <mst@redhat.com> |
9 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | --- | 11 | --- |
11 | qemu-img.texi | 9 ++++----- | 12 | MAINTAINERS | 7 +++++++ |
12 | 1 file changed, 4 insertions(+), 5 deletions(-) | 13 | 1 file changed, 7 insertions(+) |
13 | 14 | ||
14 | diff --git a/qemu-img.texi b/qemu-img.texi | 15 | diff --git a/MAINTAINERS b/MAINTAINERS |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/qemu-img.texi | 17 | --- a/MAINTAINERS |
17 | +++ b/qemu-img.texi | 18 | +++ b/MAINTAINERS |
18 | @@ -XXX,XX +XXX,XX @@ If the backing chain of the given image file @var{filename} has more than one | 19 | @@ -XXX,XX +XXX,XX @@ F: include/hw/net/ |
19 | layer, the backing file into which the changes will be committed may be | 20 | F: tests/virtio-net-test.c |
20 | specified as @var{base} (which has to be part of @var{filename}'s backing | 21 | T: git https://github.com/jasowang/qemu.git net |
21 | chain). If @var{base} is not specified, the immediate backing file of the top | 22 | |
22 | -image (which is @var{filename}) will be used. For reasons of consistency, | 23 | +Parallel NOR Flash devices |
23 | -explicitly specifying @var{base} will always imply @code{-d} (since emptying an | 24 | +M: Philippe Mathieu-Daudé <philmd@redhat.com> |
24 | -image after committing to an indirect backing file would lead to different data | 25 | +T: git https://gitlab.com/philmd/qemu.git pflash-next |
25 | -being read from the image due to content in the intermediate backing chain | 26 | +S: Maintained |
26 | -overruling the commit target). | 27 | +F: hw/block/pflash_cfi*.c |
27 | +image (which is @var{filename}) will be used. Note that after a commit operation | 28 | +F: include/hw/block/flash.h |
28 | +all images between @var{base} and the top image will be invalid and may return | 29 | + |
29 | +garbage data when read. For this reason, @code{-b} implies @code{-d} (so that | 30 | SCSI |
30 | +the top image stays valid). | 31 | M: Paolo Bonzini <pbonzini@redhat.com> |
31 | 32 | R: Fam Zheng <fam@euphon.net> | |
32 | @item compare [-f @var{fmt}] [-F @var{fmt}] [-T @var{src_cache}] [-p] [-s] [-q] @var{filename1} @var{filename2} | ||
33 | |||
34 | -- | 33 | -- |
35 | 2.13.6 | 34 | 2.20.1 |
36 | 35 | ||
37 | 36 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | Test case 192 calls _launch_qemu, so it also needs to _cleanup_qemu when |
---|---|---|---|
2 | it's done, otherwise the QMP FIFOs stay around in scratch/. It also | ||
3 | creates a temporary NBD socket that needs to be removed as well at the | ||
4 | end of the test case. | ||
2 | 5 | ||
3 | In the continuing quest to make more things byte-based, change | 6 | Reported-by: Thomas Huth <thuth@redhat.com> |
4 | the internal iteration of img_compare(). We can finally drop the | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | TODO assertions added earlier, now that the entire algorithm is | 8 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
6 | byte-based and no longer has to shift from bytes to sectors. | 9 | Tested-by: Thomas Huth <thuth@redhat.com> |
10 | --- | ||
11 | tests/qemu-iotests/192 | 4 +++- | ||
12 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
7 | 13 | ||
8 | Most of the change is mechanical ('total_sectors' becomes | 14 | diff --git a/tests/qemu-iotests/192 b/tests/qemu-iotests/192 |
9 | 'total_size', 'sector_num' becomes 'offset', 'nb_sectors' becomes | 15 | index XXXXXXX..XXXXXXX 100755 |
10 | 'chunk', 'progress_base' goes from sectors to bytes); some of it | 16 | --- a/tests/qemu-iotests/192 |
11 | is also a cleanup (sectors_to_bytes() is now unused, loss of | 17 | +++ b/tests/qemu-iotests/192 |
12 | variable 'count' added earlier in commit 51b0a488). | 18 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
13 | 19 | ||
14 | Signed-off-by: Eric Blake <eblake@redhat.com> | 20 | _cleanup() |
15 | Reviewed-by: John Snow <jsnow@redhat.com> | 21 | { |
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 22 | - _cleanup_test_img |
17 | --- | 23 | + _cleanup_qemu |
18 | qemu-img.c | 124 ++++++++++++++++++++++++------------------------------------- | 24 | + _cleanup_test_img |
19 | 1 file changed, 48 insertions(+), 76 deletions(-) | 25 | + rm -f "$TEST_DIR/nbd" |
20 | 26 | } | |
21 | diff --git a/qemu-img.c b/qemu-img.c | 27 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
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 | 28 | ||
272 | -- | 29 | -- |
273 | 2.13.6 | 30 | 2.20.1 |
274 | 31 | ||
275 | 32 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | Commit 463e0be10 ('blockjob: add AioContext attached callback') tried to |
---|---|---|---|
2 | make block jobs robust against AioContext changes of their main node, | ||
3 | but it never made sure that the job coroutine actually runs in the new | ||
4 | thread. | ||
2 | 5 | ||
3 | Previously, the alloc command required that input parameters be | 6 | Instead of waking up the job coroutine in whatever thread it ran before, |
4 | sector-aligned and clamped to 32 bits, because the underlying | 7 | let's always pass the AioContext where it should be running now. |
5 | bdrv_is_allocated used a 32-bit parameter and asserted aligned | ||
6 | inputs. But now that we have fixed block status to report a | ||
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 | 8 | ||
12 | Update iotest 177 to intentionally probe block status at | ||
13 | unaligned boundaries as well as with a bytes value that does not | ||
14 | map to 32-bit sectors, which also required tweaking the image | ||
15 | prep to leave an unallocated portion to the image under test. | ||
16 | |||
17 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
18 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
19 | --- | 10 | --- |
20 | qemu-io-cmds.c | 13 ------------- | 11 | job.c | 2 +- |
21 | tests/qemu-iotests/177 | 12 ++++++++++-- | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
22 | tests/qemu-iotests/177.out | 19 ++++++++++++++----- | ||
23 | 3 files changed, 24 insertions(+), 20 deletions(-) | ||
24 | 13 | ||
25 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | 14 | diff --git a/job.c b/job.c |
26 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/qemu-io-cmds.c | 16 | --- a/job.c |
28 | +++ b/qemu-io-cmds.c | 17 | +++ b/job.c |
29 | @@ -XXX,XX +XXX,XX @@ static int alloc_f(BlockBackend *blk, int argc, char **argv) | 18 | @@ -XXX,XX +XXX,XX @@ void job_enter_cond(Job *job, bool(*fn)(Job *job)) |
30 | if (offset < 0) { | 19 | timer_del(&job->sleep_timer); |
31 | print_cvtnum_err(offset, argv[1]); | 20 | job->busy = true; |
32 | return 0; | 21 | job_unlock(); |
33 | - } else if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { | 22 | - aio_co_wake(job->co); |
34 | - printf("%" PRId64 " is not a sector-aligned value for 'offset'\n", | 23 | + aio_co_enter(job->aio_context, job->co); |
35 | - offset); | ||
36 | - return 0; | ||
37 | } | ||
38 | |||
39 | if (argc == 3) { | ||
40 | @@ -XXX,XX +XXX,XX @@ static int alloc_f(BlockBackend *blk, int argc, char **argv) | ||
41 | if (count < 0) { | ||
42 | print_cvtnum_err(count, argv[2]); | ||
43 | return 0; | ||
44 | - } else if (count > INT_MAX * BDRV_SECTOR_SIZE) { | ||
45 | - printf("length argument cannot exceed %llu, given %s\n", | ||
46 | - INT_MAX * BDRV_SECTOR_SIZE, argv[2]); | ||
47 | - return 0; | ||
48 | } | ||
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 | + | ||
83 | +echo | ||
84 | echo "== verify image content ==" | ||
85 | |||
86 | function verify_io() | ||
87 | @@ -XXX,XX +XXX,XX @@ function verify_io() | ||
88 | echo read -P 0 32M 32M | ||
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 | } | 24 | } |
95 | 25 | ||
96 | verify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io | 26 | void job_enter(Job *job) |
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 | -- | 27 | -- |
145 | 2.13.6 | 28 | 2.20.1 |
146 | 29 | ||
147 | 30 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | This tests that a job coroutine always runs in the right iothread after |
---|---|---|---|
2 | the AioContext of its main node has changed. | ||
2 | 3 | ||
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> | 4 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
33 | --- | 5 | --- |
34 | include/block/block_int.h | 3 +- | 6 | tests/test-block-iothread.c | 107 ++++++++++++++++++++++++++++++++++++ |
35 | block/blkdebug.c | 13 ++++++++- | 7 | 1 file changed, 107 insertions(+) |
36 | block/io.c | 71 ++++++++++++++++++++++++++++++----------------- | ||
37 | 3 files changed, 59 insertions(+), 28 deletions(-) | ||
38 | 8 | ||
39 | diff --git a/include/block/block_int.h b/include/block/block_int.h | 9 | diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c |
40 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/include/block/block_int.h | 11 | --- a/tests/test-block-iothread.c |
42 | +++ b/include/block/block_int.h | 12 | +++ b/tests/test-block-iothread.c |
43 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | 13 | @@ -XXX,XX +XXX,XX @@ static void test_sync_op(const void *opaque) |
44 | * according to the current layer, and should not set | 14 | blk_unref(blk); |
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 | } | 15 | } |
60 | 16 | ||
61 | +static int64_t coroutine_fn blkdebug_co_get_block_status( | 17 | +typedef struct TestBlockJob { |
62 | + BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, | 18 | + BlockJob common; |
63 | + BlockDriverState **file) | 19 | + bool should_complete; |
20 | + int n; | ||
21 | +} TestBlockJob; | ||
22 | + | ||
23 | +static int test_job_prepare(Job *job) | ||
64 | +{ | 24 | +{ |
65 | + assert(QEMU_IS_ALIGNED(sector_num | nb_sectors, | 25 | + g_assert(qemu_get_current_aio_context() == qemu_get_aio_context()); |
66 | + DIV_ROUND_UP(bs->bl.request_alignment, | 26 | + return 0; |
67 | + BDRV_SECTOR_SIZE))); | ||
68 | + return bdrv_co_get_block_status_from_file(bs, sector_num, nb_sectors, | ||
69 | + pnum, file); | ||
70 | +} | 27 | +} |
71 | + | 28 | + |
72 | static void blkdebug_close(BlockDriverState *bs) | 29 | +static int coroutine_fn test_job_run(Job *job, Error **errp) |
73 | { | 30 | +{ |
74 | BDRVBlkdebugState *s = bs->opaque; | 31 | + TestBlockJob *s = container_of(job, TestBlockJob, common.job); |
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 | + | 32 | + |
107 | + /* Round out to request_alignment boundaries */ | 33 | + job_transition_to_ready(&s->common.job); |
108 | + /* TODO: until we have a byte-based driver callback, we also have to | 34 | + while (!s->should_complete) { |
109 | + * round out to sectors, even if that is bigger than request_alignment */ | 35 | + s->n++; |
110 | + align = MAX(bs->bl.request_alignment, BDRV_SECTOR_SIZE); | 36 | + g_assert(qemu_get_current_aio_context() == job->aio_context); |
111 | + aligned_offset = QEMU_ALIGN_DOWN(offset, align); | ||
112 | + aligned_bytes = ROUND_UP(offset + bytes, align) - aligned_offset; | ||
113 | + | 37 | + |
114 | + { | 38 | + /* Avoid job_sleep_ns() because it marks the job as !busy. We want to |
115 | + int count; /* sectors */ | 39 | + * emulate some actual activity (probably some I/O) here so that the |
116 | + int64_t longret; | 40 | + * drain involved in AioContext switches has to wait for this activity |
41 | + * to stop. */ | ||
42 | + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 1000000); | ||
117 | + | 43 | + |
118 | + assert(QEMU_IS_ALIGNED(aligned_offset | aligned_bytes, | 44 | + job_pause_point(&s->common.job); |
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 | + } | 45 | + } |
140 | + | 46 | + |
141 | /* | 47 | + g_assert(qemu_get_current_aio_context() == job->aio_context); |
142 | - * TODO: Rather than require aligned offsets, we could instead | 48 | + return 0; |
143 | - * round to the driver's request_alignment here, then touch up | 49 | +} |
144 | - * count afterwards back to the caller's expectations. | 50 | + |
145 | - */ | 51 | +static void test_job_complete(Job *job, Error **errp) |
146 | - assert(QEMU_IS_ALIGNED(offset | bytes, BDRV_SECTOR_SIZE)); | 52 | +{ |
147 | - /* | 53 | + TestBlockJob *s = container_of(job, TestBlockJob, common.job); |
148 | - * The contract allows us to return pnum smaller than bytes, even | 54 | + s->should_complete = true; |
149 | - * if the next query would see the same status; we truncate the | 55 | +} |
150 | - * request to avoid overflowing the driver's 32-bit interface. | 56 | + |
151 | + * The driver's result must be a multiple of request_alignment. | 57 | +BlockJobDriver test_job_driver = { |
152 | + * Clamp pnum and adjust map to original request. | 58 | + .job_driver = { |
153 | */ | 59 | + .instance_size = sizeof(TestBlockJob), |
154 | - bytes = MIN(bytes, BDRV_REQUEST_MAX_BYTES); | 60 | + .free = block_job_free, |
155 | - ret = bs->drv->bdrv_co_get_block_status(bs, offset >> BDRV_SECTOR_BITS, | 61 | + .user_resume = block_job_user_resume, |
156 | - bytes >> BDRV_SECTOR_BITS, &count, | 62 | + .drain = block_job_drain, |
157 | - &local_file); | 63 | + .run = test_job_run, |
158 | - if (ret < 0) { | 64 | + .complete = test_job_complete, |
159 | - goto out; | 65 | + .prepare = test_job_prepare, |
160 | + assert(QEMU_IS_ALIGNED(*pnum, align) && align > offset - aligned_offset); | 66 | + }, |
161 | + *pnum -= offset - aligned_offset; | 67 | +}; |
162 | + if (*pnum > bytes) { | 68 | + |
163 | + *pnum = bytes; | 69 | +static void test_attach_blockjob(void) |
70 | +{ | ||
71 | + IOThread *iothread = iothread_new(); | ||
72 | + AioContext *ctx = iothread_get_aio_context(iothread); | ||
73 | + BlockBackend *blk; | ||
74 | + BlockDriverState *bs; | ||
75 | + TestBlockJob *tjob; | ||
76 | + | ||
77 | + blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL); | ||
78 | + bs = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort); | ||
79 | + blk_insert_bs(blk, bs, &error_abort); | ||
80 | + | ||
81 | + tjob = block_job_create("job0", &test_job_driver, NULL, bs, | ||
82 | + 0, BLK_PERM_ALL, | ||
83 | + 0, 0, NULL, NULL, &error_abort); | ||
84 | + job_start(&tjob->common.job); | ||
85 | + | ||
86 | + while (tjob->n == 0) { | ||
87 | + aio_poll(qemu_get_aio_context(), false); | ||
88 | + } | ||
89 | + | ||
90 | + blk_set_aio_context(blk, ctx); | ||
91 | + | ||
92 | + tjob->n = 0; | ||
93 | + while (tjob->n == 0) { | ||
94 | + aio_poll(qemu_get_aio_context(), false); | ||
95 | + } | ||
96 | + | ||
97 | + aio_context_acquire(ctx); | ||
98 | + blk_set_aio_context(blk, qemu_get_aio_context()); | ||
99 | + aio_context_release(ctx); | ||
100 | + | ||
101 | + tjob->n = 0; | ||
102 | + while (tjob->n == 0) { | ||
103 | + aio_poll(qemu_get_aio_context(), false); | ||
104 | + } | ||
105 | + | ||
106 | + blk_set_aio_context(blk, ctx); | ||
107 | + | ||
108 | + tjob->n = 0; | ||
109 | + while (tjob->n == 0) { | ||
110 | + aio_poll(qemu_get_aio_context(), false); | ||
111 | + } | ||
112 | + | ||
113 | + aio_context_acquire(ctx); | ||
114 | + job_complete_sync(&tjob->common.job, &error_abort); | ||
115 | + blk_set_aio_context(blk, qemu_get_aio_context()); | ||
116 | + aio_context_release(ctx); | ||
117 | + | ||
118 | + bdrv_unref(bs); | ||
119 | + blk_unref(blk); | ||
120 | +} | ||
121 | + | ||
122 | int main(int argc, char **argv) | ||
123 | { | ||
124 | int i; | ||
125 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
126 | g_test_add_data_func(t->name, t, test_sync_op); | ||
164 | } | 127 | } |
165 | if (ret & BDRV_BLOCK_OFFSET_VALID) { | 128 | |
166 | - local_map = ret & BDRV_BLOCK_OFFSET_MASK; | 129 | + g_test_add_func("/attach/blockjob", test_attach_blockjob); |
167 | + local_map += offset - aligned_offset; | 130 | + |
168 | } | 131 | return g_test_run(); |
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 | } | 132 | } |
191 | |||
192 | -- | 133 | -- |
193 | 2.13.6 | 134 | 2.20.1 |
194 | 135 | ||
195 | 136 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Stefano Garzarella <sgarzare@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | As long as we are querying the status for a chunk smaller than | 3 | Using IEC binary prefixes in order to make the code more readable. |
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 | 4 | ||
13 | With these changes in place, sectors_to_process() is now dead code, | 5 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> |
14 | and can be removed. | ||
15 | |||
16 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 6 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
18 | --- | 7 | --- |
19 | qemu-img.c | 38 +++++++++++--------------------------- | 8 | qemu-img.c | 5 +++-- |
20 | 1 file changed, 11 insertions(+), 27 deletions(-) | 9 | 1 file changed, 3 insertions(+), 2 deletions(-) |
21 | 10 | ||
22 | diff --git a/qemu-img.c b/qemu-img.c | 11 | diff --git a/qemu-img.c b/qemu-img.c |
23 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/qemu-img.c | 13 | --- a/qemu-img.c |
25 | +++ b/qemu-img.c | 14 | +++ b/qemu-img.c |
26 | @@ -XXX,XX +XXX,XX @@ static int64_t sectors_to_bytes(int64_t sectors) | 15 | @@ -XXX,XX +XXX,XX @@ |
27 | return sectors << BDRV_SECTOR_BITS; | 16 | #include "qemu/option.h" |
17 | #include "qemu/error-report.h" | ||
18 | #include "qemu/log.h" | ||
19 | +#include "qemu/units.h" | ||
20 | #include "qom/object_interfaces.h" | ||
21 | #include "sysemu/sysemu.h" | ||
22 | #include "sysemu/block-backend.h" | ||
23 | @@ -XXX,XX +XXX,XX @@ static int compare_buffers(const uint8_t *buf1, const uint8_t *buf2, | ||
24 | return res; | ||
28 | } | 25 | } |
29 | 26 | ||
30 | -static int64_t sectors_to_process(int64_t total, int64_t from) | 27 | -#define IO_BUF_SIZE (2 * 1024 * 1024) |
31 | -{ | 28 | +#define IO_BUF_SIZE (2 * MiB) |
32 | - return MIN(total - from, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | 29 | |
33 | -} | ||
34 | - | ||
35 | /* | 30 | /* |
36 | * Check if passed sectors are empty (not allocated or contain only 0 bytes) | 31 | * Check if passed sectors are empty (not allocated or contain only 0 bytes) |
37 | * | 32 | @@ -XXX,XX +XXX,XX @@ static int img_map(int argc, char **argv) |
38 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | 33 | int64_t n; |
39 | goto out; | 34 | |
40 | } | 35 | /* Probe up to 1 GiB at a time. */ |
41 | 36 | - n = MIN(1 << 30, length - offset); | |
42 | - for (;;) { | 37 | + n = MIN(1 * GiB, length - offset); |
43 | + while (sector_num < total_sectors) { | 38 | ret = get_block_status(bs, offset, n, &next); |
44 | int status1, status2; | 39 | |
45 | 40 | if (ret < 0) { | |
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 | -- | 41 | -- |
133 | 2.13.6 | 42 | 2.20.1 |
134 | 43 | ||
135 | 44 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | Compare the following images with all-zero contents: | 3 | There's only one bdrv_write() call left in the qcow2 code, and it can |
4 | $ truncate --size 1M A | 4 | be trivially replaced with the byte-based bdrv_pwrite(). |
5 | $ qemu-img create -f qcow2 -o preallocation=off B 1G | ||
6 | $ qemu-img create -f qcow2 -o preallocation=metadata C 1G | ||
7 | 5 | ||
8 | On my machine, the difference is noticeable for pre-patch speeds, | 6 | Signed-off-by: Alberto Garcia <berto@igalia.com> |
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> | 7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
48 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
49 | --- | 9 | --- |
50 | qemu-img.c | 8 ++++---- | 10 | block/qcow2-refcount.c | 4 ++-- |
51 | 1 file changed, 4 insertions(+), 4 deletions(-) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
52 | 12 | ||
53 | diff --git a/qemu-img.c b/qemu-img.c | 13 | diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c |
54 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/qemu-img.c | 15 | --- a/block/qcow2-refcount.c |
56 | +++ b/qemu-img.c | 16 | +++ b/block/qcow2-refcount.c |
57 | @@ -XXX,XX +XXX,XX @@ static int img_compare(int argc, char **argv) | 17 | @@ -XXX,XX +XXX,XX @@ write_refblocks: |
58 | while (sector_num < progress_base) { | 18 | on_disk_refblock = (void *)((char *) *refcount_table + |
59 | int64_t count; | 19 | refblock_index * s->cluster_size); |
60 | 20 | ||
61 | - ret = bdrv_is_allocated_above(blk_bs(blk_over), NULL, | 21 | - ret = bdrv_write(bs->file, refblock_offset / BDRV_SECTOR_SIZE, |
62 | + ret = bdrv_block_status_above(blk_bs(blk_over), NULL, | 22 | - on_disk_refblock, s->cluster_sectors); |
63 | sector_num * BDRV_SECTOR_SIZE, | 23 | + ret = bdrv_pwrite(bs->file, refblock_offset, on_disk_refblock, |
64 | (progress_base - sector_num) * | 24 | + s->cluster_size); |
65 | BDRV_SECTOR_SIZE, | 25 | if (ret < 0) { |
66 | - &count); | 26 | fprintf(stderr, "ERROR writing refblock: %s\n", strerror(-ret)); |
67 | + &count, NULL, NULL); | 27 | goto fail; |
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 | -- | 28 | -- |
86 | 2.13.6 | 29 | 2.20.1 |
87 | 30 | ||
88 | 31 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | Not all callers care about which BDS owns the mapping for a given | 3 | There's only a couple of bdrv_read() and bdrv_write() calls left in |
4 | range of the file, or where the zeroes lie within that mapping. In | 4 | the vdi code, and they can be trivially replaced with the byte-based |
5 | particular, bdrv_is_allocated() cares more about finding the | 5 | bdrv_pread() and bdrv_pwrite(). |
6 | largest run of allocated data from the guest perspective, whether | ||
7 | or not that data is consecutive from the host perspective, and | ||
8 | whether or not the data reads as zero. Therefore, doing subsequent | ||
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 | 6 | ||
17 | This patch only optimizes the block layer (no behavior change when | 7 | Signed-off-by: Alberto Garcia <berto@igalia.com> |
18 | want_zero is true, but skip unnecessary effort when it is false). | 8 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
19 | Then when subsequent patches tweak the driver callback to be | ||
20 | byte-based, we can also pass this hint through to the driver. | ||
21 | |||
22 | Tweak BdrvCoGetBlockStatusData to declare arguments in parameter | ||
23 | order, rather than mixing things up (minimizing padding is not | ||
24 | necessary here). | ||
25 | |||
26 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
27 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
28 | --- | 10 | --- |
29 | block/io.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- | 11 | block/vdi.c | 15 +++++++++------ |
30 | 1 file changed, 41 insertions(+), 16 deletions(-) | 12 | 1 file changed, 9 insertions(+), 6 deletions(-) |
31 | 13 | ||
32 | diff --git a/block/io.c b/block/io.c | 14 | diff --git a/block/vdi.c b/block/vdi.c |
33 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/block/io.c | 16 | --- a/block/vdi.c |
35 | +++ b/block/io.c | 17 | +++ b/block/vdi.c |
36 | @@ -XXX,XX +XXX,XX @@ int bdrv_flush_all(void) | 18 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
37 | typedef struct BdrvCoGetBlockStatusData { | 19 | uint64_t unused2[7]; |
38 | BlockDriverState *bs; | 20 | } QEMU_PACKED VdiHeader; |
39 | BlockDriverState *base; | 21 | |
40 | - BlockDriverState **file; | 22 | +QEMU_BUILD_BUG_ON(sizeof(VdiHeader) != 512); |
41 | + bool want_zero; | 23 | + |
42 | int64_t sector_num; | 24 | typedef struct { |
43 | int nb_sectors; | 25 | /* The block map entries are little endian (even in memory). */ |
44 | int *pnum; | 26 | uint32_t *bmap; |
45 | + BlockDriverState **file; | 27 | @@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, |
46 | int64_t ret; | 28 | |
47 | bool done; | 29 | logout("\n"); |
48 | } BdrvCoGetBlockStatusData; | 30 | |
49 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs, | 31 | - ret = bdrv_read(bs->file, 0, (uint8_t *)&header, 1); |
50 | * Drivers not implementing the functionality are assumed to not support | 32 | + ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); |
51 | * backing files, hence all their sectors are reported as allocated. | 33 | if (ret < 0) { |
52 | * | 34 | goto fail; |
53 | + * If 'want_zero' is true, the caller is querying for mapping purposes, | ||
54 | + * and the result should include BDRV_BLOCK_OFFSET_VALID and | ||
55 | + * BDRV_BLOCK_ZERO where possible; otherwise, the result may omit those | ||
56 | + * bits particularly if it allows for a larger value in 'pnum'. | ||
57 | + * | ||
58 | * If 'sector_num' is beyond the end of the disk image the return value is | ||
59 | * BDRV_BLOCK_EOF and 'pnum' is set to 0. | ||
60 | * | ||
61 | @@ -XXX,XX +XXX,XX @@ int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs, | ||
62 | * is allocated in. | ||
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 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | ||
70 | |||
71 | if (ret & BDRV_BLOCK_RAW) { | ||
72 | assert(ret & BDRV_BLOCK_OFFSET_VALID && local_file); | ||
73 | - ret = bdrv_co_get_block_status(local_file, ret >> BDRV_SECTOR_BITS, | ||
74 | + ret = bdrv_co_get_block_status(local_file, want_zero, | ||
75 | + ret >> BDRV_SECTOR_BITS, | ||
76 | *pnum, pnum, &local_file); | ||
77 | goto out; | ||
78 | } | 35 | } |
79 | 36 | @@ -XXX,XX +XXX,XX @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, | |
80 | if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { | 37 | goto fail; |
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 | } | ||
94 | } | 38 | } |
95 | 39 | ||
96 | - if (local_file && local_file != bs && | 40 | - ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, |
97 | + if (want_zero && local_file && local_file != bs && | 41 | - bmap_size); |
98 | (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && | 42 | + ret = bdrv_pread(bs->file, header.offset_bmap, s->bmap, |
99 | (ret & BDRV_BLOCK_OFFSET_VALID)) { | 43 | + bmap_size * SECTOR_SIZE); |
100 | int file_pnum; | 44 | if (ret < 0) { |
101 | 45 | goto fail_free_bmap; | |
102 | - ret2 = bdrv_co_get_block_status(local_file, ret >> BDRV_SECTOR_BITS, | 46 | } |
103 | + ret2 = bdrv_co_get_block_status(local_file, want_zero, | 47 | @@ -XXX,XX +XXX,XX @@ nonallocating_write: |
104 | + ret >> BDRV_SECTOR_BITS, | 48 | assert(VDI_IS_ALLOCATED(bmap_first)); |
105 | *pnum, &file_pnum, NULL); | 49 | *header = s->header; |
106 | if (ret2 >= 0) { | 50 | vdi_header_to_le(header); |
107 | /* Ignore errors. This is just providing extra information, it | 51 | - ret = bdrv_write(bs->file, 0, block, 1); |
108 | @@ -XXX,XX +XXX,XX @@ early_out: | 52 | + ret = bdrv_pwrite(bs->file, 0, block, sizeof(VdiHeader)); |
109 | 53 | g_free(block); | |
110 | static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | 54 | block = NULL; |
111 | BlockDriverState *base, | 55 | |
112 | + bool want_zero, | 56 | @@ -XXX,XX +XXX,XX @@ nonallocating_write: |
113 | int64_t sector_num, | 57 | base = ((uint8_t *)&s->bmap[0]) + bmap_first * SECTOR_SIZE; |
114 | int nb_sectors, | 58 | logout("will write %u block map sectors starting from entry %u\n", |
115 | int *pnum, | 59 | n_sectors, bmap_first); |
116 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, | 60 | - ret = bdrv_write(bs->file, offset, base, n_sectors); |
117 | 61 | + ret = bdrv_pwrite(bs->file, offset * SECTOR_SIZE, base, | |
118 | assert(bs != base); | 62 | + n_sectors * SECTOR_SIZE); |
119 | for (p = bs; p != base; p = backing_bs(p)) { | 63 | } |
120 | - ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum, file); | 64 | |
121 | + ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors, | 65 | - return ret; |
122 | + pnum, file); | 66 | + return ret < 0 ? ret : 0; |
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 | { | ||
150 | Coroutine *co; | ||
151 | BdrvCoGetBlockStatusData data = { | ||
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 | } | 67 | } |
166 | 68 | ||
167 | +int64_t bdrv_get_block_status_above(BlockDriverState *bs, | 69 | static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options, |
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 | { | ||
184 | - int64_t sector_num = offset >> BDRV_SECTOR_BITS; | ||
185 | - int nb_sectors = bytes >> BDRV_SECTOR_BITS; | ||
186 | int64_t ret; | ||
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 | -- | 70 | -- |
201 | 2.13.6 | 71 | 2.20.1 |
202 | 72 | ||
203 | 73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | In the process of converting sector-based interfaces to bytes, | ||
4 | I'm finding it easier to represent a byte count as a 64-bit | ||
5 | integer at the block layer (even if we are internally capped | ||
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 | |||
16 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
17 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
18 | --- | ||
19 | include/block/block.h | 4 ++-- | ||
20 | block/io.c | 6 +++--- | ||
21 | block/mirror.c | 7 +++---- | ||
22 | block/trace-events | 2 +- | ||
23 | 4 files changed, 9 insertions(+), 10 deletions(-) | ||
24 | |||
25 | diff --git a/include/block/block.h b/include/block/block.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/include/block/block.h | ||
28 | +++ b/include/block/block.h | ||
29 | @@ -XXX,XX +XXX,XX @@ int bdrv_get_flags(BlockDriverState *bs); | ||
30 | int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); | ||
31 | ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs); | ||
32 | void bdrv_round_to_clusters(BlockDriverState *bs, | ||
33 | - int64_t offset, unsigned int bytes, | ||
34 | + int64_t offset, int64_t bytes, | ||
35 | int64_t *cluster_offset, | ||
36 | - unsigned int *cluster_bytes); | ||
37 | + int64_t *cluster_bytes); | ||
38 | |||
39 | const char *bdrv_get_encrypted_filename(BlockDriverState *bs); | ||
40 | void bdrv_get_backing_filename(BlockDriverState *bs, | ||
41 | diff --git a/block/io.c b/block/io.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/block/io.c | ||
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 | -- | ||
114 | 2.13.6 | ||
115 | |||
116 | 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 rename it to is_zero() in the | ||
6 | process. | ||
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 | block/qcow2.c | 33 +++++++++++++++++++-------------- | ||
14 | 1 file changed, 19 insertions(+), 14 deletions(-) | ||
15 | |||
16 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/block/qcow2.c | ||
19 | +++ b/block/qcow2.c | ||
20 | @@ -XXX,XX +XXX,XX @@ finish: | ||
21 | } | ||
22 | |||
23 | |||
24 | -static bool is_zero_sectors(BlockDriverState *bs, int64_t start, | ||
25 | - uint32_t count) | ||
26 | +static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes) | ||
27 | { | ||
28 | int nr; | ||
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 | } | ||
55 | |||
56 | static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, | ||
57 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, | ||
58 | } | ||
59 | |||
60 | if (head || tail) { | ||
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 | -- | ||
87 | 2.13.6 | ||
88 | |||
89 | 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 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() to | ||
10 | bdrv_block_status() ensures that the compiler enforces that all | ||
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 | |||
33 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
34 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | ||
35 | --- | ||
36 | include/block/block.h | 17 +++++++++-------- | ||
37 | block/io.c | 47 ++++++++++++++++++++++++++++++++++------------- | ||
38 | block/qcow2-cluster.c | 2 +- | ||
39 | qemu-img.c | 25 ++++++++++++++----------- | ||
40 | 4 files changed, 58 insertions(+), 33 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 @@ typedef struct HDGeometry { | ||
47 | #define BDRV_REQUEST_MAX_BYTES (BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS) | ||
48 | |||
49 | /* | ||
50 | - * Allocation status flags for bdrv_get_block_status() and friends. | ||
51 | + * Allocation status flags for bdrv_block_status() and friends. | ||
52 | * | ||
53 | * Public flags: | ||
54 | * BDRV_BLOCK_DATA: allocation for data at offset is tied to this layer | ||
55 | @@ -XXX,XX +XXX,XX @@ typedef struct HDGeometry { | ||
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 | ||
86 | --- a/block/io.c | ||
87 | +++ b/block/io.c | ||
88 | @@ -XXX,XX +XXX,XX @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, | ||
89 | */ | ||
90 | int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags) | ||
91 | { | ||
92 | - int64_t target_size, ret, bytes, offset = 0; | ||
93 | + int ret; | ||
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 | } | ||
128 | |||
129 | @@ -XXX,XX +XXX,XX @@ int64_t bdrv_get_block_status_above(BlockDriverState *bs, | ||
130 | nb_sectors, pnum, file); | ||
131 | } | ||
132 | |||
133 | -int64_t bdrv_get_block_status(BlockDriverState *bs, | ||
134 | - int64_t sector_num, | ||
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 | ||
173 | --- a/block/qcow2-cluster.c | ||
174 | +++ b/block/qcow2-cluster.c | ||
175 | @@ -XXX,XX +XXX,XX @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset, | ||
176 | * cluster is already marked as zero, or if it's unallocated and we | ||
177 | * don't have a backing file. | ||
178 | * | ||
179 | - * TODO We might want to use bdrv_get_block_status(bs) here, but we're | ||
180 | + * TODO We might want to use bdrv_block_status(bs) here, but we're | ||
181 | * holding s->lock, so that doesn't work today. | ||
182 | * | ||
183 | * If full_discard is true, the sector should not read back as zeroes, | ||
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 | -- | ||
251 | 2.13.6 | ||
252 | |||
253 | 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 |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | Now that bdrv_is_allocated accepts non-aligned inputs, we can | 3 | There's only a couple of bdrv_read() and bdrv_write() calls left in |
4 | remove the TODO added in commit d6a644bb. | 4 | the vvfat code, and they can be trivially replaced with the byte-based |
5 | bdrv_pread() and bdrv_pwrite(). | ||
5 | 6 | ||
6 | Signed-off-by: Eric Blake <eblake@redhat.com> | 7 | Signed-off-by: Alberto Garcia <berto@igalia.com> |
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
9 | --- | 9 | --- |
10 | block/io.c | 8 ++------ | 10 | block/vvfat.c | 12 +++++++----- |
11 | 1 file changed, 2 insertions(+), 6 deletions(-) | 11 | 1 file changed, 7 insertions(+), 5 deletions(-) |
12 | 12 | ||
13 | diff --git a/block/io.c b/block/io.c | 13 | diff --git a/block/vvfat.c b/block/vvfat.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block/io.c | 15 | --- a/block/vvfat.c |
16 | +++ b/block/io.c | 16 | +++ b/block/vvfat.c |
17 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, | 17 | @@ -XXX,XX +XXX,XX @@ static int vvfat_read(BlockDriverState *bs, int64_t sector_num, |
18 | } | 18 | DLOG(fprintf(stderr, "sectors %" PRId64 "+%" PRId64 |
19 | 19 | " allocated\n", sector_num, | |
20 | if (flags & BDRV_REQ_COPY_ON_READ) { | 20 | n >> BDRV_SECTOR_BITS)); |
21 | - /* TODO: Simplify further once bdrv_is_allocated no longer | 21 | - if (bdrv_read(s->qcow, sector_num, buf + i * 0x200, |
22 | - * requires sector alignment */ | 22 | - n >> BDRV_SECTOR_BITS)) { |
23 | - int64_t start = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); | 23 | + if (bdrv_pread(s->qcow, sector_num * BDRV_SECTOR_SIZE, |
24 | - int64_t end = QEMU_ALIGN_UP(offset + bytes, BDRV_SECTOR_SIZE); | 24 | + buf + i * 0x200, n) < 0) { |
25 | int64_t pnum; | 25 | return -1; |
26 | 26 | } | |
27 | - ret = bdrv_is_allocated(bs, start, end - start, &pnum); | 27 | i += (n >> BDRV_SECTOR_BITS) - 1; |
28 | + ret = bdrv_is_allocated(bs, offset, bytes, &pnum); | 28 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s, |
29 | if (ret < 0) { | 29 | if (res) { |
30 | goto out; | 30 | return -1; |
31 | } | 31 | } |
32 | 32 | - res = bdrv_write(s->qcow, offset, s->cluster_buffer, 1); | |
33 | - if (!ret || pnum != end - start) { | 33 | - if (res) { |
34 | + if (!ret || pnum != bytes) { | 34 | + res = bdrv_pwrite(s->qcow, offset * BDRV_SECTOR_SIZE, |
35 | ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov); | 35 | + s->cluster_buffer, BDRV_SECTOR_SIZE); |
36 | goto out; | 36 | + if (res < 0) { |
37 | } | 37 | return -2; |
38 | } | ||
39 | } | ||
40 | @@ -XXX,XX +XXX,XX @@ DLOG(checkpoint()); | ||
41 | * Use qcow backend. Commit later. | ||
42 | */ | ||
43 | DLOG(fprintf(stderr, "Write to qcow backend: %d + %d\n", (int)sector_num, nb_sectors)); | ||
44 | - ret = bdrv_write(s->qcow, sector_num, buf, nb_sectors); | ||
45 | + ret = bdrv_pwrite(s->qcow, sector_num * BDRV_SECTOR_SIZE, buf, | ||
46 | + nb_sectors * BDRV_SECTOR_SIZE); | ||
47 | if (ret < 0) { | ||
48 | fprintf(stderr, "Error writing to qcow backend\n"); | ||
49 | return ret; | ||
38 | -- | 50 | -- |
39 | 2.13.6 | 51 | 2.20.1 |
40 | 52 | ||
41 | 53 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | We are gradually moving away from sector-based interfaces, towards | 3 | No one is using these functions anymore, all callers have switched to |
4 | byte-based. In the common case, allocation is unlikely to ever use | 4 | the byte-based bdrv_pread() and bdrv_pwrite() |
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 | 5 | ||
9 | Changing the name of the function from bdrv_get_block_status_above() | 6 | Signed-off-by: Alberto Garcia <berto@igalia.com> |
10 | to bdrv_block_status_above() ensures that the compiler enforces that | 7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
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> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
34 | --- | 9 | --- |
35 | include/block/block.h | 8 +++----- | 10 | include/block/block.h | 4 ---- |
36 | block/io.c | 55 ++++++++------------------------------------------- | 11 | block/io.c | 43 +++++++------------------------------------ |
37 | block/mirror.c | 18 ++++++----------- | 12 | 2 files changed, 7 insertions(+), 40 deletions(-) |
38 | block/qcow2.c | 30 +++++++++++----------------- | ||
39 | qemu-img.c | 49 +++++++++++++++++++++++++-------------------- | ||
40 | 5 files changed, 57 insertions(+), 103 deletions(-) | ||
41 | 13 | ||
42 | diff --git a/include/block/block.h b/include/block/block.h | 14 | diff --git a/include/block/block.h b/include/block/block.h |
43 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/include/block/block.h | 16 | --- a/include/block/block.h |
45 | +++ b/include/block/block.h | 17 | +++ b/include/block/block.h |
46 | @@ -XXX,XX +XXX,XX @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs); | 18 | @@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, |
47 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, | 19 | BlockReopenQueue *queue, Error **errp); |
48 | int64_t bytes, int64_t *pnum, int64_t *map, | 20 | void bdrv_reopen_commit(BDRVReopenState *reopen_state); |
49 | BlockDriverState **file); | 21 | void bdrv_reopen_abort(BDRVReopenState *reopen_state); |
50 | -int64_t bdrv_get_block_status_above(BlockDriverState *bs, | 22 | -int bdrv_read(BdrvChild *child, int64_t sector_num, |
51 | - BlockDriverState *base, | 23 | - uint8_t *buf, int nb_sectors); |
52 | - int64_t sector_num, | 24 | -int bdrv_write(BdrvChild *child, int64_t sector_num, |
53 | - int nb_sectors, int *pnum, | 25 | - const uint8_t *buf, int nb_sectors); |
54 | - BlockDriverState **file); | 26 | int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, |
55 | +int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, | 27 | int bytes, BdrvRequestFlags flags); |
56 | + int64_t offset, int64_t bytes, int64_t *pnum, | 28 | int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags); |
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 | 29 | diff --git a/block/io.c b/block/io.c |
62 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/block/io.c | 31 | --- a/block/io.c |
64 | +++ b/block/io.c | 32 | +++ b/block/io.c |
65 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs, | 33 | @@ -XXX,XX +XXX,XX @@ static int bdrv_prwv_co(BdrvChild *child, int64_t offset, |
66 | return ret; | 34 | return rwco.ret; |
67 | } | 35 | } |
68 | 36 | ||
69 | -/* Coroutine wrapper for bdrv_get_block_status_above() */ | 37 | -/* |
70 | +/* Coroutine wrapper for bdrv_block_status_above() */ | 38 | - * Process a synchronous request using coroutines |
71 | static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque) | 39 | - */ |
40 | -static int bdrv_rw_co(BdrvChild *child, int64_t sector_num, uint8_t *buf, | ||
41 | - int nb_sectors, bool is_write, BdrvRequestFlags flags) | ||
42 | -{ | ||
43 | - QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, | ||
44 | - nb_sectors * BDRV_SECTOR_SIZE); | ||
45 | - | ||
46 | - if (nb_sectors < 0 || nb_sectors > BDRV_REQUEST_MAX_SECTORS) { | ||
47 | - return -EINVAL; | ||
48 | - } | ||
49 | - | ||
50 | - return bdrv_prwv_co(child, sector_num << BDRV_SECTOR_BITS, | ||
51 | - &qiov, is_write, flags); | ||
52 | -} | ||
53 | - | ||
54 | -/* return < 0 if error. See bdrv_write() for the return codes */ | ||
55 | -int bdrv_read(BdrvChild *child, int64_t sector_num, | ||
56 | - uint8_t *buf, int nb_sectors) | ||
57 | -{ | ||
58 | - return bdrv_rw_co(child, sector_num, buf, nb_sectors, false, 0); | ||
59 | -} | ||
60 | - | ||
61 | -/* Return < 0 if error. Important errors are: | ||
62 | - -EIO generic I/O error (may happen for all errors) | ||
63 | - -ENOMEDIUM No media inserted. | ||
64 | - -EINVAL Invalid sector number or nb_sectors | ||
65 | - -EACCES Trying to write a read-only device | ||
66 | -*/ | ||
67 | -int bdrv_write(BdrvChild *child, int64_t sector_num, | ||
68 | - const uint8_t *buf, int nb_sectors) | ||
69 | -{ | ||
70 | - return bdrv_rw_co(child, sector_num, (uint8_t *)buf, nb_sectors, true, 0); | ||
71 | -} | ||
72 | - | ||
73 | int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, | ||
74 | int bytes, BdrvRequestFlags flags) | ||
72 | { | 75 | { |
73 | BdrvCoBlockStatusData *data = opaque; | 76 | @@ -XXX,XX +XXX,XX @@ int bdrv_preadv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov) |
74 | @@ -XXX,XX +XXX,XX @@ static int bdrv_common_block_status_above(BlockDriverState *bs, | 77 | return qiov->size; |
75 | return data.ret; | ||
76 | } | 78 | } |
77 | 79 | ||
78 | -int64_t bdrv_get_block_status_above(BlockDriverState *bs, | 80 | +/* See bdrv_pwrite() for the return codes */ |
79 | - BlockDriverState *base, | 81 | int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes) |
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 | { | 82 | { |
87 | - int64_t ret; | 83 | QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); |
88 | - int64_t n; | 84 | @@ -XXX,XX +XXX,XX @@ int bdrv_pwritev(BdrvChild *child, int64_t offset, QEMUIOVector *qiov) |
89 | - int64_t map; | 85 | return qiov->size; |
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 | } | 86 | } |
105 | 87 | ||
106 | int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, | 88 | +/* Return no. of bytes on success or < 0 on error. Important errors are: |
107 | int64_t *pnum, int64_t *map, BlockDriverState **file) | 89 | + -EIO generic I/O error (may happen for all errors) |
90 | + -ENOMEDIUM No media inserted. | ||
91 | + -EINVAL Invalid offset or number of bytes | ||
92 | + -EACCES Trying to write a read-only device | ||
93 | +*/ | ||
94 | int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf, int bytes) | ||
108 | { | 95 | { |
109 | - int64_t ret; | 96 | QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes); |
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 | -- | 97 | -- |
387 | 2.13.6 | 98 | 2.20.1 |
388 | 99 | ||
389 | 100 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Blake <eblake@redhat.com> | ||
2 | 1 | ||
3 | During 'qemu-img compare', when we are checking that an allocated | ||
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 | |||
10 | The new interface intentionally uses bytes in its interface, even | ||
11 | though it still crawls the buffer a sector at a time; it is robust | ||
12 | to a partial sector at the end of the buffer. | ||
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 | 32 ++++++++++++++++++++++++++++---- | ||
19 | 1 file changed, 28 insertions(+), 4 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 @@ done: | ||
26 | } | ||
27 | |||
28 | /* | ||
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 | +{ | ||
36 | + int64_t i; | ||
37 | + int64_t end = QEMU_ALIGN_DOWN(n, BDRV_SECTOR_SIZE); | ||
38 | + | ||
39 | + for (i = 0; i < end; i += BDRV_SECTOR_SIZE) { | ||
40 | + if (!buffer_is_zero(buf + i, BDRV_SECTOR_SIZE)) { | ||
41 | + return i; | ||
42 | + } | ||
43 | + } | ||
44 | + if (i < n && !buffer_is_zero(buf + i, n - end)) { | ||
45 | + return i; | ||
46 | + } | ||
47 | + return -1; | ||
48 | +} | ||
49 | + | ||
50 | +/* | ||
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 | { | ||
58 | - int pnum, ret = 0; | ||
59 | + int ret = 0; | ||
60 | + int64_t idx; | ||
61 | + | ||
62 | ret = blk_pread(blk, sect_num << BDRV_SECTOR_BITS, buffer, | ||
63 | sect_count << BDRV_SECTOR_BITS); | ||
64 | if (ret < 0) { | ||
65 | @@ -XXX,XX +XXX,XX @@ static int check_empty_sectors(BlockBackend *blk, int64_t sect_num, | ||
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 | |||
79 | -- | ||
80 | 2.13.6 | ||
81 | |||
82 | 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 |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Alberto Garcia <berto@igalia.com> |
---|---|---|---|
2 | 2 | ||
3 | BDRV_SECTOR_BITS is defined to be 9 in block.h (and BDRV_SECTOR_SIZE | 3 | The last user of this field disappeared when we replace the |
4 | is calculated from that), but there are still a couple of places where | 4 | sector-based bdrv_write() with the byte-based bdrv_pwrite(). |
5 | we are using the literal value instead of the macro. | ||
6 | 5 | ||
7 | Signed-off-by: Alberto Garcia <berto@igalia.com> | 6 | Signed-off-by: Alberto Garcia <berto@igalia.com> |
8 | Message-id: 20171009153856.20387-1-berto@igalia.com | 7 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
10 | --- | 9 | --- |
11 | block/qcow2.c | 4 ++-- | 10 | block/qcow2.h | 1 - |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 11 | block/qcow2.c | 1 - |
12 | 2 files changed, 2 deletions(-) | ||
13 | 13 | ||
14 | diff --git a/block/qcow2.h b/block/qcow2.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/qcow2.h | ||
17 | +++ b/block/qcow2.h | ||
18 | @@ -XXX,XX +XXX,XX @@ typedef struct Qcow2BitmapHeaderExt { | ||
19 | typedef struct BDRVQcow2State { | ||
20 | int cluster_bits; | ||
21 | int cluster_size; | ||
22 | - int cluster_sectors; | ||
23 | int l2_slice_size; | ||
24 | int l2_bits; | ||
25 | int l2_size; | ||
14 | diff --git a/block/qcow2.c b/block/qcow2.c | 26 | diff --git a/block/qcow2.c b/block/qcow2.c |
15 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/block/qcow2.c | 28 | --- a/block/qcow2.c |
17 | +++ b/block/qcow2.c | 29 | +++ b/block/qcow2.c |
18 | @@ -XXX,XX +XXX,XX @@ static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags, | 30 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, |
19 | 31 | ||
20 | s->cluster_bits = header.cluster_bits; | 32 | s->cluster_bits = header.cluster_bits; |
21 | s->cluster_size = 1 << s->cluster_bits; | 33 | s->cluster_size = 1 << s->cluster_bits; |
22 | - s->cluster_sectors = 1 << (s->cluster_bits - 9); | 34 | - s->cluster_sectors = 1 << (s->cluster_bits - BDRV_SECTOR_BITS); |
23 | + s->cluster_sectors = 1 << (s->cluster_bits - BDRV_SECTOR_BITS); | ||
24 | 35 | ||
25 | /* Initialise version 3 header fields */ | 36 | /* Initialise version 3 header fields */ |
26 | if (header.version == 2) { | 37 | 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 | -- | 38 | -- |
37 | 2.13.6 | 39 | 2.20.1 |
38 | 40 | ||
39 | 41 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | In the continuing quest to make more things byte-based, change | 3 | Currently, without -u, you cannot add a backing file to an image when it |
4 | the internal iteration of img_rebase(). We can finally drop the | 4 | currently has none: |
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 | 5 | ||
8 | Most of the change is mechanical ('num_sectors' becomes 'size', | 6 | $ qemu-img rebase -b base.qcow2 foo.qcow2 |
9 | 'sector' becomes 'offset', 'n' goes from sectors to bytes); some | 7 | qemu-img: Could not open old backing file '': The 'file' block driver |
10 | of it is also a cleanup (use of MIN() instead of open-coding, | 8 | requires a file name |
11 | loss of variable 'count' added earlier in commit d6a644bb). | ||
12 | 9 | ||
13 | Signed-off-by: Eric Blake <eblake@redhat.com> | 10 | It is really simple to allow this, though (effectively by setting |
14 | Reviewed-by: John Snow <jsnow@redhat.com> | 11 | old_backing_size to 0), so this patch does just that. |
12 | |||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
14 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
15 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 15 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
16 | --- | 16 | --- |
17 | qemu-img.c | 84 +++++++++++++++++++++++++------------------------------------- | 17 | qemu-img.c | 61 ++++++++++++++++++++++++++++++------------------------ |
18 | 1 file changed, 34 insertions(+), 50 deletions(-) | 18 | 1 file changed, 34 insertions(+), 27 deletions(-) |
19 | 19 | ||
20 | diff --git a/qemu-img.c b/qemu-img.c | 20 | diff --git a/qemu-img.c b/qemu-img.c |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/qemu-img.c | 22 | --- a/qemu-img.c |
23 | +++ b/qemu-img.c | 23 | +++ b/qemu-img.c |
24 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | 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. | 25 | char backing_name[PATH_MAX]; |
26 | QDict *options = NULL; | ||
27 | |||
28 | - if (bs->backing_format[0] != '\0') { | ||
29 | - options = qdict_new(); | ||
30 | - qdict_put_str(options, "driver", bs->backing_format); | ||
31 | - } | ||
32 | - | ||
33 | - if (force_share) { | ||
34 | - if (!options) { | ||
35 | + if (bs->backing) { | ||
36 | + if (bs->backing_format[0] != '\0') { | ||
37 | options = qdict_new(); | ||
38 | + qdict_put_str(options, "driver", bs->backing_format); | ||
39 | } | ||
40 | - qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true); | ||
41 | - } | ||
42 | - bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); | ||
43 | - blk_old_backing = blk_new_open(backing_name, NULL, | ||
44 | - options, src_flags, &local_err); | ||
45 | - if (!blk_old_backing) { | ||
46 | - error_reportf_err(local_err, | ||
47 | - "Could not open old backing file '%s': ", | ||
48 | - backing_name); | ||
49 | - ret = -1; | ||
50 | - goto out; | ||
51 | + | ||
52 | + if (force_share) { | ||
53 | + if (!options) { | ||
54 | + options = qdict_new(); | ||
55 | + } | ||
56 | + qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true); | ||
57 | + } | ||
58 | + bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); | ||
59 | + blk_old_backing = blk_new_open(backing_name, NULL, | ||
60 | + options, src_flags, &local_err); | ||
61 | + if (!blk_old_backing) { | ||
62 | + error_reportf_err(local_err, | ||
63 | + "Could not open old backing file '%s': ", | ||
64 | + backing_name); | ||
65 | + ret = -1; | ||
66 | + goto out; | ||
67 | + } | ||
68 | + } else { | ||
69 | + blk_old_backing = NULL; | ||
70 | } | ||
71 | |||
72 | if (out_baseimg[0]) { | ||
73 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | ||
26 | */ | 74 | */ |
27 | if (!unsafe) { | 75 | if (!unsafe) { |
28 | - int64_t num_sectors; | 76 | int64_t size; |
29 | - int64_t old_backing_num_sectors; | 77 | - int64_t old_backing_size; |
30 | - int64_t new_backing_num_sectors = 0; | 78 | + int64_t old_backing_size = 0; |
31 | - uint64_t sector; | 79 | int64_t new_backing_size = 0; |
32 | - int n; | 80 | uint64_t offset; |
33 | - int64_t count; | 81 | int64_t n; |
34 | + int64_t size; | 82 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) |
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; | 83 | ret = -1; |
52 | goto out; | 84 | goto out; |
53 | } | 85 | } |
54 | - old_backing_num_sectors = blk_nb_sectors(blk_old_backing); | 86 | - old_backing_size = blk_getlength(blk_old_backing); |
55 | - if (old_backing_num_sectors < 0) { | 87 | - if (old_backing_size < 0) { |
56 | + old_backing_size = blk_getlength(blk_old_backing); | 88 | - char backing_name[PATH_MAX]; |
57 | + if (old_backing_size < 0) { | 89 | + if (blk_old_backing) { |
58 | char backing_name[PATH_MAX]; | 90 | + old_backing_size = blk_getlength(blk_old_backing); |
59 | 91 | + if (old_backing_size < 0) { | |
60 | bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); | 92 | + char backing_name[PATH_MAX]; |
61 | error_report("Could not get size of '%s': %s", | 93 | |
62 | - backing_name, strerror(-old_backing_num_sectors)); | 94 | - bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); |
63 | + backing_name, strerror(-old_backing_size)); | 95 | - error_report("Could not get size of '%s': %s", |
64 | ret = -1; | 96 | - backing_name, strerror(-old_backing_size)); |
65 | goto out; | 97 | - ret = -1; |
98 | - goto out; | ||
99 | + bdrv_get_backing_filename(bs, backing_name, | ||
100 | + sizeof(backing_name)); | ||
101 | + error_report("Could not get size of '%s': %s", | ||
102 | + backing_name, strerror(-old_backing_size)); | ||
103 | + ret = -1; | ||
104 | + goto out; | ||
105 | + } | ||
66 | } | 106 | } |
67 | if (blk_new_backing) { | 107 | if (blk_new_backing) { |
68 | - new_backing_num_sectors = blk_nb_sectors(blk_new_backing); | 108 | new_backing_size = blk_getlength(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 | -- | 109 | -- |
177 | 2.13.6 | 110 | 2.20.1 |
178 | 111 | ||
179 | 112 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | In the continuing quest to make more things byte-based, change | 3 | Past the end of the source backing file, we memset() buf_old to zero, so |
4 | compare_sectors(), renaming it to compare_buffers() in the | 4 | it is clearly easy to use blk_pwrite_zeroes() instead of blk_pwrite() |
5 | process. Note that one caller (qemu-img compare) only cares | 5 | then. |
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 | 6 | ||
14 | Signed-off-by: Eric Blake <eblake@redhat.com> | 7 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
15 | Reviewed-by: John Snow <jsnow@redhat.com> | 8 | Reviewed-by: Eric Blake <eblake@redhat.com> |
16 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
17 | --- | 10 | --- |
18 | qemu-img.c | 55 +++++++++++++++++++++++++++---------------------------- | 11 | qemu-img.c | 11 +++++++++-- |
19 | 1 file changed, 27 insertions(+), 28 deletions(-) | 12 | 1 file changed, 9 insertions(+), 2 deletions(-) |
20 | 13 | ||
21 | diff --git a/qemu-img.c b/qemu-img.c | 14 | diff --git a/qemu-img.c b/qemu-img.c |
22 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/qemu-img.c | 16 | --- a/qemu-img.c |
24 | +++ b/qemu-img.c | 17 | +++ b/qemu-img.c |
25 | @@ -XXX,XX +XXX,XX @@ static int is_allocated_sectors_min(const uint8_t *buf, int n, int *pnum, | 18 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) |
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 | } | 19 | } |
66 | + i += len; | 20 | |
67 | } | 21 | for (offset = 0; offset < size; offset += n) { |
68 | 22 | + bool buf_old_is_zero = false; | |
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 | + | 23 | + |
85 | nb_sectors = MIN(nb_sectors, IO_BUF_SIZE >> BDRV_SECTOR_BITS); | 24 | /* How many bytes can we handle with the next read? */ |
86 | ret = blk_pread(blk1, sector_num << BDRV_SECTOR_BITS, buf1, | 25 | n = MIN(IO_BUF_SIZE, size - offset); |
87 | nb_sectors << BDRV_SECTOR_BITS); | 26 | |
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) | 27 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) |
105 | /* If they differ, we need to write to the COW file */ | 28 | */ |
106 | uint64_t written = 0; | 29 | if (offset >= old_backing_size) { |
107 | 30 | memset(buf_old, 0, n); | |
108 | - while (written < n) { | 31 | + buf_old_is_zero = true; |
109 | - int pnum; | 32 | } else { |
110 | + while (written < n * BDRV_SECTOR_SIZE) { | 33 | if (offset + n > old_backing_size) { |
111 | + int64_t pnum; | 34 | n = old_backing_size - offset; |
112 | 35 | @@ -XXX,XX +XXX,XX @@ static int img_rebase(int argc, char **argv) | |
113 | - if (compare_sectors(buf_old + written * 512, | 36 | if (compare_buffers(buf_old + written, buf_new + written, |
114 | - buf_new + written * 512, n - written, &pnum)) | 37 | n - written, &pnum)) |
115 | + if (compare_buffers(buf_old + written, | ||
116 | + buf_new + written, | ||
117 | + n * BDRV_SECTOR_SIZE - written, &pnum)) | ||
118 | { | 38 | { |
119 | ret = blk_pwrite(blk, | 39 | - ret = blk_pwrite(blk, offset + written, |
120 | - (sector + written) << BDRV_SECTOR_BITS, | 40 | - buf_old + written, pnum, 0); |
121 | - buf_old + written * 512, | 41 | + if (buf_old_is_zero) { |
122 | - pnum << BDRV_SECTOR_BITS, 0); | 42 | + ret = blk_pwrite_zeroes(blk, offset + written, pnum, 0); |
123 | + (sector << BDRV_SECTOR_BITS) + written, | 43 | + } else { |
124 | + buf_old + written, pnum, 0); | 44 | + ret = blk_pwrite(blk, offset + written, |
45 | + buf_old + written, pnum, 0); | ||
46 | + } | ||
125 | if (ret < 0) { | 47 | if (ret < 0) { |
126 | error_report("Error while writing to COW image: %s", | 48 | error_report("Error while writing to COW image: %s", |
127 | strerror(-ret)); | 49 | strerror(-ret)); |
128 | -- | 50 | -- |
129 | 2.13.6 | 51 | 2.20.1 |
130 | 52 | ||
131 | 53 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Max Reitz <mreitz@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds a test for rebasing an image that currently does not | ||
4 | have a backing file. | ||
5 | |||
3 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | Message-id: 20170929170843.3711-1-mreitz@redhat.com | 7 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
5 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | --- | 8 | --- |
8 | tests/qemu-iotests/127 | 97 ++++++++++++++++++++++++++++++++++++++++++++++ | 9 | tests/qemu-iotests/252 | 124 +++++++++++++++++++++++++++++++++++++ |
9 | tests/qemu-iotests/127.out | 14 +++++++ | 10 | tests/qemu-iotests/252.out | 39 ++++++++++++ |
10 | tests/qemu-iotests/group | 1 + | 11 | tests/qemu-iotests/group | 1 + |
11 | 3 files changed, 112 insertions(+) | 12 | 3 files changed, 164 insertions(+) |
12 | create mode 100755 tests/qemu-iotests/127 | 13 | create mode 100755 tests/qemu-iotests/252 |
13 | create mode 100644 tests/qemu-iotests/127.out | 14 | create mode 100644 tests/qemu-iotests/252.out |
14 | 15 | ||
15 | diff --git a/tests/qemu-iotests/127 b/tests/qemu-iotests/127 | 16 | diff --git a/tests/qemu-iotests/252 b/tests/qemu-iotests/252 |
16 | new file mode 100755 | 17 | new file mode 100755 |
17 | index XXXXXXX..XXXXXXX | 18 | index XXXXXXX..XXXXXXX |
18 | --- /dev/null | 19 | --- /dev/null |
19 | +++ b/tests/qemu-iotests/127 | 20 | +++ b/tests/qemu-iotests/252 |
20 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
21 | +#!/bin/bash | 22 | +#!/usr/bin/env bash |
22 | +# | 23 | +# |
23 | +# Test case for mirroring with dataplane | 24 | +# Tests for rebasing COW images that require zero cluster support |
24 | +# | 25 | +# |
25 | +# Copyright (C) 2017 Red Hat, Inc. | 26 | +# Copyright (C) 2019 Red Hat, Inc. |
26 | +# | 27 | +# |
27 | +# This program is free software; you can redistribute it and/or modify | 28 | +# 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 | 29 | +# 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 | 30 | +# the Free Software Foundation; either version 2 of the License, or |
30 | +# (at your option) any later version. | 31 | +# (at your option) any later version. |
... | ... | ||
42 | +owner=mreitz@redhat.com | 43 | +owner=mreitz@redhat.com |
43 | + | 44 | + |
44 | +seq=$(basename $0) | 45 | +seq=$(basename $0) |
45 | +echo "QA output created by $seq" | 46 | +echo "QA output created by $seq" |
46 | + | 47 | + |
47 | +here=$PWD | 48 | +status=1 # failure is the default! |
48 | +status=1 # failure is the default! | ||
49 | + | 49 | + |
50 | +_cleanup() | 50 | +_cleanup() |
51 | +{ | 51 | +{ |
52 | + _cleanup_qemu | ||
53 | + _cleanup_test_img | 52 | + _cleanup_test_img |
54 | + _rm_test_img "$TEST_IMG.overlay0" | 53 | + rm -f "$TEST_IMG.base_new" |
55 | + _rm_test_img "$TEST_IMG.overlay1" | ||
56 | +} | 54 | +} |
57 | +trap "_cleanup; exit \$status" 0 1 2 3 15 | 55 | +trap "_cleanup; exit \$status" 0 1 2 3 15 |
58 | + | 56 | + |
59 | +# get standard environment, filters and qemu instance handling | 57 | +# get standard environment, filters and checks |
60 | +. ./common.rc | 58 | +. ./common.rc |
61 | +. ./common.filter | 59 | +. ./common.filter |
62 | +. ./common.qemu | 60 | +. ./common.pattern |
63 | + | 61 | + |
62 | +# Currently only qcow2 and qed support rebasing, and only qcow2 v3 has | ||
63 | +# zero cluster support | ||
64 | +_supported_fmt qcow2 | 64 | +_supported_fmt qcow2 |
65 | +_unsupported_imgopts 'compat=0.10' | ||
65 | +_supported_proto file | 66 | +_supported_proto file |
66 | +_supported_os Linux | 67 | +_supported_os Linux |
67 | + | 68 | + |
68 | +IMG_SIZE=64K | 69 | +CLUSTER_SIZE=65536 |
69 | + | 70 | + |
70 | +_make_test_img $IMG_SIZE | 71 | +echo |
71 | +TEST_IMG="$TEST_IMG.overlay0" _make_test_img -b "$TEST_IMG" $IMG_SIZE | 72 | +echo "=== Test rebase without input base ===" |
72 | +TEST_IMG="$TEST_IMG.overlay1" _make_test_img -b "$TEST_IMG" $IMG_SIZE | 73 | +echo |
73 | + | 74 | + |
74 | +# So that we actually have something to mirror and the job does not return | 75 | +# Cluster allocations to be tested: |
75 | +# immediately (which may be bad because then we cannot know whether the | 76 | +# |
76 | +# 'return' or the 'BLOCK_JOB_READY' comes first). | 77 | +# Backing (new) 11 -- 11 -- 11 -- |
77 | +$QEMU_IO -c 'write 0 42' "$TEST_IMG.overlay0" | _filter_qemu_io | 78 | +# COW image 22 22 11 11 -- -- |
78 | + | 79 | +# |
79 | +# We cannot use virtio-blk here because that does not actually set the attached | 80 | +# Expected result: |
80 | +# BB's AioContext in qtest mode | 81 | +# |
81 | +_launch_qemu \ | 82 | +# COW image 22 22 11 11 00 -- |
82 | + -object iothread,id=iothr \ | 83 | +# |
83 | + -blockdev node-name=source,driver=$IMGFMT,file.driver=file,file.filename="$TEST_IMG.overlay0" \ | 84 | +# (Cluster 2 might be "--" after the rebase, too, but rebase just |
84 | + -device virtio-scsi,id=scsi-bus,iothread=iothr \ | 85 | +# compares the new backing file to the old one and disregards the |
85 | + -device scsi-hd,bus=scsi-bus.0,drive=source | 86 | +# overlay. Therefore, it will never discard overlay clusters.) |
86 | + | 87 | + |
87 | +_send_qemu_cmd $QEMU_HANDLE \ | 88 | +_make_test_img $((6 * CLUSTER_SIZE)) |
88 | + "{ 'execute': 'qmp_capabilities' }" \ | 89 | +TEST_IMG="$TEST_IMG.base_new" _make_test_img $((6 * CLUSTER_SIZE)) |
89 | + 'return' | 90 | + |
90 | + | 91 | +echo |
91 | +_send_qemu_cmd $QEMU_HANDLE \ | 92 | + |
92 | + "{ 'execute': 'drive-mirror', | 93 | +$QEMU_IO "$TEST_IMG" \ |
93 | + 'arguments': { | 94 | + -c "write -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ |
94 | + 'job-id': 'mirror', | 95 | + -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ |
95 | + 'device': 'source', | 96 | + | _filter_qemu_io |
96 | + 'target': '$TEST_IMG.overlay1', | 97 | + |
97 | + 'mode': 'existing', | 98 | +$QEMU_IO "$TEST_IMG.base_new" \ |
98 | + 'sync': 'top' | 99 | + -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ |
99 | + } }" \ | 100 | + -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ |
100 | + 'BLOCK_JOB_READY' | 101 | + -c "write -P 0x11 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ |
101 | + | 102 | + | _filter_qemu_io |
102 | +# The backing BDS should be assigned the overlay's AioContext | 103 | + |
103 | +_send_qemu_cmd $QEMU_HANDLE \ | 104 | +echo |
104 | + "{ 'execute': 'block-job-complete', | 105 | + |
105 | + 'arguments': { 'device': 'mirror' } }" \ | 106 | +# This should be a no-op |
106 | + 'BLOCK_JOB_COMPLETED' | 107 | +$QEMU_IMG rebase -b "" "$TEST_IMG" |
107 | + | 108 | + |
108 | +_send_qemu_cmd $QEMU_HANDLE \ | 109 | +# Verify the data is correct |
109 | + "{ 'execute': 'quit' }" \ | 110 | +$QEMU_IO "$TEST_IMG" \ |
110 | + 'return' | 111 | + -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ |
111 | + | 112 | + -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ |
112 | +wait=yes _cleanup_qemu | 113 | + -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ |
114 | + | _filter_qemu_io | ||
115 | + | ||
116 | +echo | ||
117 | + | ||
118 | +# Verify the allocation status (first four cluster should be allocated | ||
119 | +# in TEST_IMG, clusters 4 and 5 should be unallocated (marked as zero | ||
120 | +# clusters here because there is no backing file)) | ||
121 | +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map | ||
122 | + | ||
123 | +echo | ||
124 | + | ||
125 | +$QEMU_IMG rebase -b "$TEST_IMG.base_new" "$TEST_IMG" | ||
126 | + | ||
127 | +# Verify the data is correct | ||
128 | +$QEMU_IO "$TEST_IMG" \ | ||
129 | + -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ | ||
130 | + -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ | ||
131 | + -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ | ||
132 | + | _filter_qemu_io | ||
133 | + | ||
134 | +echo | ||
135 | + | ||
136 | +# Verify the allocation status (first four cluster should be allocated | ||
137 | +# in TEST_IMG, cluster 4 should be zero, and cluster 5 should be | ||
138 | +# unallocated (signified by '"depth": 1')) | ||
139 | +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map | ||
140 | + | ||
113 | + | 141 | + |
114 | +# success, all done | 142 | +# success, all done |
115 | +echo '*** done' | 143 | +echo "*** done" |
116 | +rm -f $seq.full | 144 | +rm -f $seq.full |
117 | +status=0 | 145 | +status=0 |
118 | diff --git a/tests/qemu-iotests/127.out b/tests/qemu-iotests/127.out | 146 | diff --git a/tests/qemu-iotests/252.out b/tests/qemu-iotests/252.out |
119 | new file mode 100644 | 147 | new file mode 100644 |
120 | index XXXXXXX..XXXXXXX | 148 | index XXXXXXX..XXXXXXX |
121 | --- /dev/null | 149 | --- /dev/null |
122 | +++ b/tests/qemu-iotests/127.out | 150 | +++ b/tests/qemu-iotests/252.out |
123 | @@ -XXX,XX +XXX,XX @@ | 151 | @@ -XXX,XX +XXX,XX @@ |
124 | +QA output created by 127 | 152 | +QA output created by 252 |
125 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536 | 153 | + |
126 | +Formatting 'TEST_DIR/t.IMGFMT.overlay0', fmt=IMGFMT size=65536 backing_file=TEST_DIR/t.IMGFMT | 154 | +=== Test rebase without input base === |
127 | +Formatting 'TEST_DIR/t.IMGFMT.overlay1', fmt=IMGFMT size=65536 backing_file=TEST_DIR/t.IMGFMT | 155 | + |
128 | +wrote 42/42 bytes at offset 0 | 156 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=393216 |
129 | +42 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | 157 | +Formatting 'TEST_DIR/t.IMGFMT.base_new', fmt=IMGFMT size=393216 |
130 | +{"return": {}} | 158 | + |
131 | +{"return": {}} | 159 | +wrote 131072/131072 bytes at offset 0 |
132 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "mirror", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} | 160 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
133 | +{"return": {}} | 161 | +wrote 131072/131072 bytes at offset 131072 |
134 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "mirror", "len": 65536, "offset": 65536, "speed": 0, "type": "mirror"}} | 162 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
135 | +{"return": {}} | 163 | +wrote 65536/65536 bytes at offset 0 |
136 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | 164 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
165 | +wrote 65536/65536 bytes at offset 131072 | ||
166 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
167 | +wrote 65536/65536 bytes at offset 262144 | ||
168 | +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
169 | + | ||
170 | +read 131072/131072 bytes at offset 0 | ||
171 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
172 | +read 131072/131072 bytes at offset 131072 | ||
173 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
174 | +read 131072/131072 bytes at offset 262144 | ||
175 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
176 | + | ||
177 | +[{ "start": 0, "length": 262144, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
178 | +{ "start": 262144, "length": 131072, "depth": 0, "zero": true, "data": false}] | ||
179 | + | ||
180 | +read 131072/131072 bytes at offset 0 | ||
181 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
182 | +read 131072/131072 bytes at offset 131072 | ||
183 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
184 | +read 131072/131072 bytes at offset 262144 | ||
185 | +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
186 | + | ||
187 | +[{ "start": 0, "length": 262144, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
188 | +{ "start": 262144, "length": 65536, "depth": 0, "zero": true, "data": false}, | ||
189 | +{ "start": 327680, "length": 65536, "depth": 1, "zero": true, "data": false}] | ||
137 | +*** done | 190 | +*** done |
138 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | 191 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group |
139 | index XXXXXXX..XXXXXXX 100644 | 192 | index XXXXXXX..XXXXXXX 100644 |
140 | --- a/tests/qemu-iotests/group | 193 | --- a/tests/qemu-iotests/group |
141 | +++ b/tests/qemu-iotests/group | 194 | +++ b/tests/qemu-iotests/group |
142 | @@ -XXX,XX +XXX,XX @@ | 195 | @@ -XXX,XX +XXX,XX @@ |
143 | 124 rw auto backing | 196 | 247 rw auto quick |
144 | 125 rw auto | 197 | 248 rw auto quick |
145 | 126 rw auto backing | 198 | 249 rw auto quick |
146 | +127 rw auto backing quick | 199 | +252 rw auto backing quick |
147 | 128 rw auto quick | ||
148 | 129 rw auto quick | ||
149 | 130 rw auto quick | ||
150 | -- | 200 | -- |
151 | 2.13.6 | 201 | 2.20.1 |
152 | 202 | ||
153 | 203 | 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 | A qcow2 image file's length is not required to have a length that is a | ||
4 | multiple of the cluster size. However, qcow2_refcount_area() expects an | ||
5 | aligned value for its @start_offset parameter, so we need to round | ||
6 | @old_file_size up to the next cluster boundary. | ||
7 | |||
8 | Reported-by: Ping Li <pingl@redhat.com> | ||
9 | Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1414049 | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | Message-id: 20171009215533.12530-2-mreitz@redhat.com | ||
12 | Cc: qemu-stable@nongnu.org | ||
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
14 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
15 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | ||
18 | block/qcow2.c | 1 + | ||
19 | 1 file changed, 1 insertion(+) | ||
20 | |||
21 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/block/qcow2.c | ||
24 | +++ b/block/qcow2.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset, | ||
26 | "Failed to inquire current file length"); | ||
27 | return old_file_size; | ||
28 | } | ||
29 | + old_file_size = ROUND_UP(old_file_size, s->cluster_size); | ||
30 | |||
31 | nb_new_data_clusters = DIV_ROUND_UP(offset - old_length, | ||
32 | s->cluster_size); | ||
33 | -- | ||
34 | 2.13.6 | ||
35 | |||
36 | 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 |