1 | The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4: | 1 | The following changes since commit dac03af5d5482ec7ee9c23db467bb7230b33c0d9: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100) | 3 | Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20190825' into staging (2019-08-27 10:00:51 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27 | 7 | https://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c: | 9 | for you to fetch changes up to 5396234b96a2ac743f48644529771498e036e698: |
10 | 10 | ||
11 | iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200) | 11 | block/qcow2: implement .bdrv_co_pwritev(_compressed)_part (2019-08-27 14:58:42 +0100) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | 14 | Pull request |
15 | - qemu-io now accepts a file to read a write pattern from | ||
16 | - Ensure that raw files have their first block allocated so we can probe | ||
17 | the O_DIRECT alignment if necessary | ||
18 | - Various fixes | ||
19 | 15 | ||
20 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
21 | Denis Plotnikov (1): | ||
22 | qemu-io: add pattern file for write command | ||
23 | 17 | ||
24 | Max Reitz (7): | 18 | Vladimir Sementsov-Ogievskiy (12): |
25 | iotests: Fix _filter_img_create() | 19 | util/iov: introduce qemu_iovec_init_extended |
26 | vmdk: Use bdrv_dirname() for relative extent paths | 20 | util/iov: improve qemu_iovec_is_zero |
27 | iotests: Keep testing broken relative extent paths | 21 | block/io: refactor padding |
28 | vmdk: Reject invalid compressed writes | 22 | block: define .*_part io handlers in BlockDriver |
29 | iotests: Disable broken streamOptimized tests | 23 | block/io: bdrv_co_do_copy_on_readv: use and support qiov_offset |
30 | iotests: Disable 110 for vmdk.twoGbMaxExtentSparse | 24 | block/io: bdrv_co_do_copy_on_readv: lazy allocation |
31 | iotests: Disable 126 for flat vmdk subformats | 25 | block/io: bdrv_aligned_preadv: use and support qiov_offset |
26 | block/io: bdrv_aligned_pwritev: use and support qiov_offset | ||
27 | block/io: introduce bdrv_co_p{read, write}v_part | ||
28 | block/qcow2: refactor qcow2_co_preadv to use buffer-based io | ||
29 | block/qcow2: implement .bdrv_co_preadv_part | ||
30 | block/qcow2: implement .bdrv_co_pwritev(_compressed)_part | ||
32 | 31 | ||
33 | Nir Soffer (3): | 32 | block/qcow2.h | 1 + |
34 | block: posix: Always allocate the first block | 33 | include/block/block_int.h | 21 ++ |
35 | iotests: Test allocate_first_block() with O_DIRECT | 34 | include/qemu/iov.h | 10 +- |
36 | iotests: Unify cache mode quoting | 35 | block/backup.c | 2 +- |
37 | 36 | block/io.c | 541 +++++++++++++++++++++++--------------- | |
38 | Stefan Hajnoczi (1): | 37 | block/qcow2-cluster.c | 14 +- |
39 | file-posix: fix request_alignment typo | 38 | block/qcow2.c | 131 +++++---- |
40 | 39 | qemu-img.c | 4 +- | |
41 | Thomas Huth (2): | 40 | util/iov.c | 153 +++++++++-- |
42 | iotests: Check for enabled drivers before testing them | 41 | 9 files changed, 568 insertions(+), 309 deletions(-) |
43 | tests/check-block: Skip iotests when sanitizers are enabled | ||
44 | |||
45 | Vladimir Sementsov-Ogievskiy (1): | ||
46 | block: fix permission update in bdrv_replace_node | ||
47 | |||
48 | block.c | 5 +- | ||
49 | block/file-posix.c | 53 +++++++++- | ||
50 | block/vmdk.c | 64 ++++++++---- | ||
51 | qemu-io-cmds.c | 99 +++++++++++++++++-- | ||
52 | tests/check-block.sh | 5 + | ||
53 | tests/qemu-iotests/002 | 1 + | ||
54 | tests/qemu-iotests/003 | 1 + | ||
55 | tests/qemu-iotests/005 | 3 +- | ||
56 | tests/qemu-iotests/009 | 1 + | ||
57 | tests/qemu-iotests/010 | 1 + | ||
58 | tests/qemu-iotests/011 | 1 + | ||
59 | tests/qemu-iotests/017 | 3 +- | ||
60 | tests/qemu-iotests/018 | 3 +- | ||
61 | tests/qemu-iotests/019 | 3 +- | ||
62 | tests/qemu-iotests/020 | 3 +- | ||
63 | tests/qemu-iotests/026 | 4 +- | ||
64 | tests/qemu-iotests/027 | 1 + | ||
65 | tests/qemu-iotests/032 | 1 + | ||
66 | tests/qemu-iotests/033 | 1 + | ||
67 | tests/qemu-iotests/034 | 3 +- | ||
68 | tests/qemu-iotests/037 | 3 +- | ||
69 | tests/qemu-iotests/039 | 4 +- | ||
70 | tests/qemu-iotests/052 | 2 +- | ||
71 | tests/qemu-iotests/059 | 34 ++++++- | ||
72 | tests/qemu-iotests/059.out | 26 +++-- | ||
73 | tests/qemu-iotests/063 | 3 +- | ||
74 | tests/qemu-iotests/071 | 1 + | ||
75 | tests/qemu-iotests/072 | 1 + | ||
76 | tests/qemu-iotests/081 | 4 +- | ||
77 | tests/qemu-iotests/091 | 4 +- | ||
78 | tests/qemu-iotests/099 | 1 + | ||
79 | tests/qemu-iotests/105 | 3 +- | ||
80 | tests/qemu-iotests/110 | 3 +- | ||
81 | tests/qemu-iotests/120 | 1 + | ||
82 | tests/qemu-iotests/126 | 2 + | ||
83 | tests/qemu-iotests/{150.out => 150.out.qcow2} | 0 | ||
84 | tests/qemu-iotests/150.out.raw | 12 +++ | ||
85 | tests/qemu-iotests/162 | 4 +- | ||
86 | tests/qemu-iotests/175 | 47 +++++++-- | ||
87 | tests/qemu-iotests/175.out | 16 ++- | ||
88 | tests/qemu-iotests/178.out.qcow2 | 4 +- | ||
89 | tests/qemu-iotests/184 | 1 + | ||
90 | tests/qemu-iotests/186 | 1 + | ||
91 | tests/qemu-iotests/197 | 1 + | ||
92 | tests/qemu-iotests/215 | 1 + | ||
93 | tests/qemu-iotests/221.out | 12 ++- | ||
94 | tests/qemu-iotests/251 | 1 + | ||
95 | tests/qemu-iotests/253.out | 12 ++- | ||
96 | tests/qemu-iotests/common.filter | 4 +- | ||
97 | tests/qemu-iotests/common.rc | 14 +++ | ||
98 | 50 files changed, 391 insertions(+), 87 deletions(-) | ||
99 | rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%) | ||
100 | create mode 100644 tests/qemu-iotests/150.out.raw | ||
101 | 42 | ||
102 | -- | 43 | -- |
103 | 2.21.0 | 44 | 2.21.0 |
104 | 45 | ||
105 | 46 | diff view generated by jsdifflib |
1 | From: Denis Plotnikov <dplotnikov@virtuozzo.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | The patch allows to provide a pattern file for write | 3 | Introduce new initialization API, to create requests with padding. Will |
4 | command. There was no similar ability before. | 4 | be used in the following patch. New API uses qemu_iovec_init_buf if |
5 | resulting io vector has only one element, to avoid extra allocations. | ||
6 | So, we need to update qemu_iovec_destroy to support destroying such | ||
7 | QIOVs. | ||
5 | 8 | ||
6 | Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com> | 9 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
7 | Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com | 10 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | 11 | Message-id: 20190604161514.262241-2-vsementsov@virtuozzo.com |
9 | [mreitz: Keep optstring in alphabetical order] | 12 | Message-Id: <20190604161514.262241-2-vsementsov@virtuozzo.com> |
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
11 | --- | 14 | --- |
12 | qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++--- | 15 | include/qemu/iov.h | 7 +++ |
13 | 1 file changed, 93 insertions(+), 6 deletions(-) | 16 | util/iov.c | 112 +++++++++++++++++++++++++++++++++++++++++++-- |
17 | 2 files changed, 114 insertions(+), 5 deletions(-) | ||
14 | 18 | ||
15 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | 19 | diff --git a/include/qemu/iov.h b/include/qemu/iov.h |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/qemu-io-cmds.c | 21 | --- a/include/qemu/iov.h |
18 | +++ b/qemu-io-cmds.c | 22 | +++ b/include/qemu/iov.h |
19 | @@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p) | 23 | @@ -XXX,XX +XXX,XX @@ static inline void *qemu_iovec_buf(QEMUIOVector *qiov) |
20 | qemu_vfree(p); | 24 | |
25 | void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); | ||
26 | void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov); | ||
27 | +void qemu_iovec_init_extended( | ||
28 | + QEMUIOVector *qiov, | ||
29 | + void *head_buf, size_t head_len, | ||
30 | + QEMUIOVector *mid_qiov, size_t mid_offset, size_t mid_len, | ||
31 | + void *tail_buf, size_t tail_len); | ||
32 | +void qemu_iovec_init_slice(QEMUIOVector *qiov, QEMUIOVector *source, | ||
33 | + size_t offset, size_t len); | ||
34 | void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); | ||
35 | void qemu_iovec_concat(QEMUIOVector *dst, | ||
36 | QEMUIOVector *src, size_t soffset, size_t sbytes); | ||
37 | diff --git a/util/iov.c b/util/iov.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/util/iov.c | ||
40 | +++ b/util/iov.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void qemu_iovec_concat(QEMUIOVector *dst, | ||
42 | qemu_iovec_concat_iov(dst, src->iov, src->niov, soffset, sbytes); | ||
21 | } | 43 | } |
22 | 44 | ||
23 | +/* | 45 | +/* |
24 | + * qemu_io_alloc_from_file() | 46 | + * qiov_find_iov |
25 | + * | 47 | + * |
26 | + * Allocates the buffer and populates it with the content of the given file | 48 | + * Return pointer to iovec structure, where byte at @offset in original vector |
27 | + * up to @len bytes. If the file length is less than @len, then the buffer | 49 | + * @iov exactly is. |
28 | + * is populated with the file content cyclically. | 50 | + * Set @remaining_offset to be offset inside that iovec to the same byte. |
51 | + */ | ||
52 | +static struct iovec *iov_skip_offset(struct iovec *iov, size_t offset, | ||
53 | + size_t *remaining_offset) | ||
54 | +{ | ||
55 | + while (offset > 0 && offset >= iov->iov_len) { | ||
56 | + offset -= iov->iov_len; | ||
57 | + iov++; | ||
58 | + } | ||
59 | + *remaining_offset = offset; | ||
60 | + | ||
61 | + return iov; | ||
62 | +} | ||
63 | + | ||
64 | +/* | ||
65 | + * qiov_slice | ||
29 | + * | 66 | + * |
30 | + * @blk - the block backend where the buffer content is going to be written to | 67 | + * Find subarray of iovec's, containing requested range. @head would |
31 | + * @len - the buffer length | 68 | + * be offset in first iov (returned by the function), @tail would be |
32 | + * @file_name - the file to read the content from | 69 | + * count of extra bytes in last iovec (returned iov + @niov - 1). |
33 | + * | ||
34 | + * Returns: the buffer pointer on success | ||
35 | + * NULL on error | ||
36 | + */ | 70 | + */ |
37 | +static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len, | 71 | +static struct iovec *qiov_slice(QEMUIOVector *qiov, |
38 | + const char *file_name) | 72 | + size_t offset, size_t len, |
73 | + size_t *head, size_t *tail, int *niov) | ||
39 | +{ | 74 | +{ |
40 | + char *buf, *buf_origin; | 75 | + struct iovec *iov, *end_iov; |
41 | + FILE *f = fopen(file_name, "r"); | ||
42 | + int pattern_len; | ||
43 | + | 76 | + |
44 | + if (!f) { | 77 | + assert(offset + len <= qiov->size); |
45 | + perror(file_name); | 78 | + |
46 | + return NULL; | 79 | + iov = iov_skip_offset(qiov->iov, offset, head); |
80 | + end_iov = iov_skip_offset(iov, *head + len, tail); | ||
81 | + | ||
82 | + if (*tail > 0) { | ||
83 | + assert(*tail < end_iov->iov_len); | ||
84 | + *tail = end_iov->iov_len - *tail; | ||
85 | + end_iov++; | ||
47 | + } | 86 | + } |
48 | + | 87 | + |
49 | + if (qemuio_misalign) { | 88 | + *niov = end_iov - iov; |
50 | + len += MISALIGN_OFFSET; | 89 | + |
90 | + return iov; | ||
91 | +} | ||
92 | + | ||
93 | +/* | ||
94 | + * Compile new iovec, combining @head_buf buffer, sub-qiov of @mid_qiov, | ||
95 | + * and @tail_buf buffer into new qiov. | ||
96 | + */ | ||
97 | +void qemu_iovec_init_extended( | ||
98 | + QEMUIOVector *qiov, | ||
99 | + void *head_buf, size_t head_len, | ||
100 | + QEMUIOVector *mid_qiov, size_t mid_offset, size_t mid_len, | ||
101 | + void *tail_buf, size_t tail_len) | ||
102 | +{ | ||
103 | + size_t mid_head, mid_tail; | ||
104 | + int total_niov, mid_niov = 0; | ||
105 | + struct iovec *p, *mid_iov; | ||
106 | + | ||
107 | + if (mid_len) { | ||
108 | + mid_iov = qiov_slice(mid_qiov, mid_offset, mid_len, | ||
109 | + &mid_head, &mid_tail, &mid_niov); | ||
51 | + } | 110 | + } |
52 | + | 111 | + |
53 | + buf_origin = buf = blk_blockalign(blk, len); | 112 | + total_niov = !!head_len + mid_niov + !!tail_len; |
54 | + | 113 | + if (total_niov == 1) { |
55 | + if (qemuio_misalign) { | 114 | + qemu_iovec_init_buf(qiov, NULL, 0); |
56 | + buf_origin += MISALIGN_OFFSET; | 115 | + p = &qiov->local_iov; |
57 | + buf += MISALIGN_OFFSET; | 116 | + } else { |
58 | + len -= MISALIGN_OFFSET; | 117 | + qiov->niov = qiov->nalloc = total_niov; |
118 | + qiov->size = head_len + mid_len + tail_len; | ||
119 | + p = qiov->iov = g_new(struct iovec, qiov->niov); | ||
59 | + } | 120 | + } |
60 | + | 121 | + |
61 | + pattern_len = fread(buf_origin, 1, len, f); | 122 | + if (head_len) { |
62 | + | 123 | + p->iov_base = head_buf; |
63 | + if (ferror(f)) { | 124 | + p->iov_len = head_len; |
64 | + perror(file_name); | 125 | + p++; |
65 | + goto error; | ||
66 | + } | 126 | + } |
67 | + | 127 | + |
68 | + if (pattern_len == 0) { | 128 | + if (mid_len) { |
69 | + fprintf(stderr, "%s: file is empty\n", file_name); | 129 | + memcpy(p, mid_iov, mid_niov * sizeof(*p)); |
70 | + goto error; | 130 | + p[0].iov_base = (uint8_t *)p[0].iov_base + mid_head; |
131 | + p[0].iov_len -= mid_head; | ||
132 | + p[mid_niov - 1].iov_len -= mid_tail; | ||
133 | + p += mid_niov; | ||
71 | + } | 134 | + } |
72 | + | 135 | + |
73 | + fclose(f); | 136 | + if (tail_len) { |
74 | + | 137 | + p->iov_base = tail_buf; |
75 | + if (len > pattern_len) { | 138 | + p->iov_len = tail_len; |
76 | + len -= pattern_len; | ||
77 | + buf += pattern_len; | ||
78 | + | ||
79 | + while (len > 0) { | ||
80 | + size_t len_to_copy = MIN(pattern_len, len); | ||
81 | + | ||
82 | + memcpy(buf, buf_origin, len_to_copy); | ||
83 | + | ||
84 | + len -= len_to_copy; | ||
85 | + buf += len_to_copy; | ||
86 | + } | ||
87 | + } | 139 | + } |
88 | + | ||
89 | + return buf_origin; | ||
90 | + | ||
91 | +error: | ||
92 | + qemu_io_free(buf_origin); | ||
93 | + return NULL; | ||
94 | +} | 140 | +} |
95 | + | 141 | + |
96 | static void dump_buffer(const void *buffer, int64_t offset, int64_t len) | 142 | /* |
143 | * Check if the contents of the iovecs are all zero | ||
144 | */ | ||
145 | @@ -XXX,XX +XXX,XX @@ bool qemu_iovec_is_zero(QEMUIOVector *qiov) | ||
146 | return true; | ||
147 | } | ||
148 | |||
149 | +void qemu_iovec_init_slice(QEMUIOVector *qiov, QEMUIOVector *source, | ||
150 | + size_t offset, size_t len) | ||
151 | +{ | ||
152 | + qemu_iovec_init_extended(qiov, NULL, 0, source, offset, len, NULL, 0); | ||
153 | +} | ||
154 | + | ||
155 | void qemu_iovec_destroy(QEMUIOVector *qiov) | ||
97 | { | 156 | { |
98 | uint64_t i; | 157 | - assert(qiov->nalloc != -1); |
99 | @@ -XXX,XX +XXX,XX @@ static void write_help(void) | 158 | + if (qiov->nalloc != -1) { |
100 | " -n, -- with -z, don't allow slow fallback\n" | 159 | + g_free(qiov->iov); |
101 | " -p, -- ignored for backwards compatibility\n" | 160 | + } |
102 | " -P, -- use different pattern to fill file\n" | 161 | |
103 | +" -s, -- use a pattern file to fill the write buffer\n" | 162 | - qemu_iovec_reset(qiov); |
104 | " -C, -- report statistics in a machine parsable format\n" | 163 | - g_free(qiov->iov); |
105 | " -q, -- quiet mode, do not show I/O statistics\n" | 164 | - qiov->nalloc = 0; |
106 | " -u, -- with -z, allow unmapping\n" | 165 | - qiov->iov = NULL; |
107 | @@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = { | 166 | + memset(qiov, 0, sizeof(*qiov)); |
108 | .perm = BLK_PERM_WRITE, | 167 | } |
109 | .argmin = 2, | 168 | |
110 | .argmax = -1, | 169 | void qemu_iovec_reset(QEMUIOVector *qiov) |
111 | - .args = "[-bcCfnquz] [-P pattern] off len", | ||
112 | + .args = "[-bcCfnquz] [-P pattern | -s source_file] off len", | ||
113 | .oneline = "writes a number of bytes at a specified offset", | ||
114 | .help = write_help, | ||
115 | }; | ||
116 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
117 | { | ||
118 | struct timespec t1, t2; | ||
119 | bool Cflag = false, qflag = false, bflag = false; | ||
120 | - bool Pflag = false, zflag = false, cflag = false; | ||
121 | + bool Pflag = false, zflag = false, cflag = false, sflag = false; | ||
122 | int flags = 0; | ||
123 | int c, cnt, ret; | ||
124 | char *buf = NULL; | ||
125 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
126 | /* Some compilers get confused and warn if this is not initialized. */ | ||
127 | int64_t total = 0; | ||
128 | int pattern = 0xcd; | ||
129 | + const char *file_name = NULL; | ||
130 | |||
131 | - while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) { | ||
132 | + while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) { | ||
133 | switch (c) { | ||
134 | case 'b': | ||
135 | bflag = true; | ||
136 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
137 | case 'q': | ||
138 | qflag = true; | ||
139 | break; | ||
140 | + case 's': | ||
141 | + sflag = true; | ||
142 | + file_name = optarg; | ||
143 | + break; | ||
144 | case 'u': | ||
145 | flags |= BDRV_REQ_MAY_UNMAP; | ||
146 | break; | ||
147 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
148 | return -EINVAL; | ||
149 | } | ||
150 | |||
151 | - if (zflag && Pflag) { | ||
152 | - printf("-z and -P cannot be specified at the same time\n"); | ||
153 | + if (zflag + Pflag + sflag > 1) { | ||
154 | + printf("Only one of -z, -P, and -s " | ||
155 | + "can be specified at the same time\n"); | ||
156 | return -EINVAL; | ||
157 | } | ||
158 | |||
159 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
160 | } | ||
161 | |||
162 | if (!zflag) { | ||
163 | - buf = qemu_io_alloc(blk, count, pattern); | ||
164 | + if (sflag) { | ||
165 | + buf = qemu_io_alloc_from_file(blk, count, file_name); | ||
166 | + if (!buf) { | ||
167 | + return -EINVAL; | ||
168 | + } | ||
169 | + } else { | ||
170 | + buf = qemu_io_alloc(blk, count, pattern); | ||
171 | + } | ||
172 | } | ||
173 | |||
174 | clock_gettime(CLOCK_MONOTONIC, &t1); | ||
175 | -- | 170 | -- |
176 | 2.21.0 | 171 | 2.21.0 |
177 | 172 | ||
178 | 173 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | The sanitizers (especially the address sanitizer from Clang) are | 3 | We'll need to check a part of qiov soon, so implement it now. |
4 | sometimes printing out warnings or false positives - this spoils | ||
5 | the output of the iotests, causing some of the tests to fail. | ||
6 | Thus let's skip the automatic iotests during "make check" when the | ||
7 | user configured QEMU with --enable-sanitizers. | ||
8 | 4 | ||
9 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 5 | Optimization with align down to 4 * sizeof(long) is dropped due to: |
10 | Message-id: 20190823084203.29734-1-thuth@redhat.com | 6 | 1. It is strange: it aligns length of the buffer, but where is a |
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | guarantee that buffer pointer is aligned itself? |
8 | 2. buffer_is_zero() is a better place for optimizations and it has | ||
9 | them. | ||
10 | |||
11 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
12 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | Message-id: 20190604161514.262241-3-vsementsov@virtuozzo.com | ||
14 | Message-Id: <20190604161514.262241-3-vsementsov@virtuozzo.com> | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | --- | 16 | --- |
13 | tests/check-block.sh | 5 +++++ | 17 | include/qemu/iov.h | 2 +- |
14 | 1 file changed, 5 insertions(+) | 18 | block/io.c | 2 +- |
19 | util/iov.c | 31 +++++++++++++++++++------------ | ||
20 | 3 files changed, 21 insertions(+), 14 deletions(-) | ||
15 | 21 | ||
16 | diff --git a/tests/check-block.sh b/tests/check-block.sh | 22 | diff --git a/include/qemu/iov.h b/include/qemu/iov.h |
17 | index XXXXXXX..XXXXXXX 100755 | 23 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/tests/check-block.sh | 24 | --- a/include/qemu/iov.h |
19 | +++ b/tests/check-block.sh | 25 | +++ b/include/qemu/iov.h |
20 | @@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then | 26 | @@ -XXX,XX +XXX,XX @@ void qemu_iovec_concat(QEMUIOVector *dst, |
21 | exit 0 | 27 | size_t qemu_iovec_concat_iov(QEMUIOVector *dst, |
22 | fi | 28 | struct iovec *src_iov, unsigned int src_cnt, |
23 | 29 | size_t soffset, size_t sbytes); | |
24 | +if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then | 30 | -bool qemu_iovec_is_zero(QEMUIOVector *qiov); |
25 | + echo "Sanitizers are enabled ==> Not running the qemu-iotests." | 31 | +bool qemu_iovec_is_zero(QEMUIOVector *qiov, size_t qiov_offeset, size_t bytes); |
26 | + exit 0 | 32 | void qemu_iovec_destroy(QEMUIOVector *qiov); |
27 | +fi | 33 | void qemu_iovec_reset(QEMUIOVector *qiov); |
34 | size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, | ||
35 | diff --git a/block/io.c b/block/io.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/block/io.c | ||
38 | +++ b/block/io.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, | ||
40 | |||
41 | if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF && | ||
42 | !(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes && | ||
43 | - qemu_iovec_is_zero(qiov)) { | ||
44 | + qemu_iovec_is_zero(qiov, 0, qiov->size)) { | ||
45 | flags |= BDRV_REQ_ZERO_WRITE; | ||
46 | if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) { | ||
47 | flags |= BDRV_REQ_MAY_UNMAP; | ||
48 | diff --git a/util/iov.c b/util/iov.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/util/iov.c | ||
51 | +++ b/util/iov.c | ||
52 | @@ -XXX,XX +XXX,XX @@ void qemu_iovec_init_extended( | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | - * Check if the contents of the iovecs are all zero | ||
57 | + * Check if the contents of subrange of qiov data is all zeroes. | ||
58 | */ | ||
59 | -bool qemu_iovec_is_zero(QEMUIOVector *qiov) | ||
60 | +bool qemu_iovec_is_zero(QEMUIOVector *qiov, size_t offset, size_t bytes) | ||
61 | { | ||
62 | - int i; | ||
63 | - for (i = 0; i < qiov->niov; i++) { | ||
64 | - size_t offs = QEMU_ALIGN_DOWN(qiov->iov[i].iov_len, 4 * sizeof(long)); | ||
65 | - uint8_t *ptr = qiov->iov[i].iov_base; | ||
66 | - if (offs && !buffer_is_zero(qiov->iov[i].iov_base, offs)) { | ||
67 | + struct iovec *iov; | ||
68 | + size_t current_offset; | ||
28 | + | 69 | + |
29 | if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then | 70 | + assert(offset + bytes <= qiov->size); |
30 | echo "No qemu-system binary available ==> Not running the qemu-iotests." | 71 | + |
31 | exit 0 | 72 | + iov = iov_skip_offset(qiov->iov, offset, ¤t_offset); |
73 | + | ||
74 | + while (bytes) { | ||
75 | + uint8_t *base = (uint8_t *)iov->iov_base + current_offset; | ||
76 | + size_t len = MIN(iov->iov_len - current_offset, bytes); | ||
77 | + | ||
78 | + if (!buffer_is_zero(base, len)) { | ||
79 | return false; | ||
80 | } | ||
81 | - for (; offs < qiov->iov[i].iov_len; offs++) { | ||
82 | - if (ptr[offs]) { | ||
83 | - return false; | ||
84 | - } | ||
85 | - } | ||
86 | + | ||
87 | + current_offset = 0; | ||
88 | + bytes -= len; | ||
89 | + iov++; | ||
90 | } | ||
91 | + | ||
92 | return true; | ||
93 | } | ||
94 | |||
32 | -- | 95 | -- |
33 | 2.21.0 | 96 | 2.21.0 |
34 | 97 | ||
35 | 98 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | It's wrong to OR shared permissions. It may lead to crash on further | 3 | We have similar padding code in bdrv_co_pwritev, |
4 | permission updates. | 4 | bdrv_co_do_pwrite_zeroes and bdrv_co_preadv. Let's combine and unify |
5 | Also, no needs to consider previously calculated permissions, as at | 5 | it. |
6 | this point we already bind all new parents and bdrv_get_cumulative_perm | 6 | |
7 | result is enough. So fix the bug by just set permissions by | 7 | [Squashed in Vladimir's qemu-iotests 077 fix |
8 | bdrv_get_cumulative_perm result. | 8 | --Stefan] |
9 | |||
10 | Bug was introduced in long ago 234ac1a9025, in 2.9. | ||
11 | 9 | ||
12 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 10 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
13 | Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com | 11 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Message-id: 20190604161514.262241-4-vsementsov@virtuozzo.com |
13 | Message-Id: <20190604161514.262241-4-vsementsov@virtuozzo.com> | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | --- | 15 | --- |
16 | block.c | 5 ++--- | 16 | block/io.c | 365 +++++++++++++++++++++++++++++------------------------ |
17 | 1 file changed, 2 insertions(+), 3 deletions(-) | 17 | 1 file changed, 200 insertions(+), 165 deletions(-) |
18 | 18 | ||
19 | diff --git a/block.c b/block.c | 19 | diff --git a/block/io.c b/block/io.c |
20 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/block.c | 21 | --- a/block/io.c |
22 | +++ b/block.c | 22 | +++ b/block/io.c |
23 | @@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, | 23 | @@ -XXX,XX +XXX,XX @@ out: |
24 | } | ||
25 | |||
26 | /* | ||
27 | - * Handle a read request in coroutine context | ||
28 | + * Request padding | ||
29 | + * | ||
30 | + * |<---- align ----->| |<----- align ---->| | ||
31 | + * |<- head ->|<------------- bytes ------------->|<-- tail -->| | ||
32 | + * | | | | | | | ||
33 | + * -*----------$-------*-------- ... --------*-----$------------*--- | ||
34 | + * | | | | | | | ||
35 | + * | offset | | end | | ||
36 | + * ALIGN_DOWN(offset) ALIGN_UP(offset) ALIGN_DOWN(end) ALIGN_UP(end) | ||
37 | + * [buf ... ) [tail_buf ) | ||
38 | + * | ||
39 | + * @buf is an aligned allocation needed to store @head and @tail paddings. @head | ||
40 | + * is placed at the beginning of @buf and @tail at the @end. | ||
41 | + * | ||
42 | + * @tail_buf is a pointer to sub-buffer, corresponding to align-sized chunk | ||
43 | + * around tail, if tail exists. | ||
44 | + * | ||
45 | + * @merge_reads is true for small requests, | ||
46 | + * if @buf_len == @head + bytes + @tail. In this case it is possible that both | ||
47 | + * head and tail exist but @buf_len == align and @tail_buf == @buf. | ||
48 | */ | ||
49 | +typedef struct BdrvRequestPadding { | ||
50 | + uint8_t *buf; | ||
51 | + size_t buf_len; | ||
52 | + uint8_t *tail_buf; | ||
53 | + size_t head; | ||
54 | + size_t tail; | ||
55 | + bool merge_reads; | ||
56 | + QEMUIOVector local_qiov; | ||
57 | +} BdrvRequestPadding; | ||
58 | + | ||
59 | +static bool bdrv_init_padding(BlockDriverState *bs, | ||
60 | + int64_t offset, int64_t bytes, | ||
61 | + BdrvRequestPadding *pad) | ||
62 | +{ | ||
63 | + uint64_t align = bs->bl.request_alignment; | ||
64 | + size_t sum; | ||
65 | + | ||
66 | + memset(pad, 0, sizeof(*pad)); | ||
67 | + | ||
68 | + pad->head = offset & (align - 1); | ||
69 | + pad->tail = ((offset + bytes) & (align - 1)); | ||
70 | + if (pad->tail) { | ||
71 | + pad->tail = align - pad->tail; | ||
72 | + } | ||
73 | + | ||
74 | + if ((!pad->head && !pad->tail) || !bytes) { | ||
75 | + return false; | ||
76 | + } | ||
77 | + | ||
78 | + sum = pad->head + bytes + pad->tail; | ||
79 | + pad->buf_len = (sum > align && pad->head && pad->tail) ? 2 * align : align; | ||
80 | + pad->buf = qemu_blockalign(bs, pad->buf_len); | ||
81 | + pad->merge_reads = sum == pad->buf_len; | ||
82 | + if (pad->tail) { | ||
83 | + pad->tail_buf = pad->buf + pad->buf_len - align; | ||
84 | + } | ||
85 | + | ||
86 | + return true; | ||
87 | +} | ||
88 | + | ||
89 | +static int bdrv_padding_rmw_read(BdrvChild *child, | ||
90 | + BdrvTrackedRequest *req, | ||
91 | + BdrvRequestPadding *pad, | ||
92 | + bool zero_middle) | ||
93 | +{ | ||
94 | + QEMUIOVector local_qiov; | ||
95 | + BlockDriverState *bs = child->bs; | ||
96 | + uint64_t align = bs->bl.request_alignment; | ||
97 | + int ret; | ||
98 | + | ||
99 | + assert(req->serialising && pad->buf); | ||
100 | + | ||
101 | + if (pad->head || pad->merge_reads) { | ||
102 | + uint64_t bytes = pad->merge_reads ? pad->buf_len : align; | ||
103 | + | ||
104 | + qemu_iovec_init_buf(&local_qiov, pad->buf, bytes); | ||
105 | + | ||
106 | + if (pad->head) { | ||
107 | + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); | ||
108 | + } | ||
109 | + if (pad->merge_reads && pad->tail) { | ||
110 | + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); | ||
111 | + } | ||
112 | + ret = bdrv_aligned_preadv(child, req, req->overlap_offset, bytes, | ||
113 | + align, &local_qiov, 0); | ||
114 | + if (ret < 0) { | ||
115 | + return ret; | ||
116 | + } | ||
117 | + if (pad->head) { | ||
118 | + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); | ||
119 | + } | ||
120 | + if (pad->merge_reads && pad->tail) { | ||
121 | + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); | ||
122 | + } | ||
123 | + | ||
124 | + if (pad->merge_reads) { | ||
125 | + goto zero_mem; | ||
126 | + } | ||
127 | + } | ||
128 | + | ||
129 | + if (pad->tail) { | ||
130 | + qemu_iovec_init_buf(&local_qiov, pad->tail_buf, align); | ||
131 | + | ||
132 | + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); | ||
133 | + ret = bdrv_aligned_preadv( | ||
134 | + child, req, | ||
135 | + req->overlap_offset + req->overlap_bytes - align, | ||
136 | + align, align, &local_qiov, 0); | ||
137 | + if (ret < 0) { | ||
138 | + return ret; | ||
139 | + } | ||
140 | + bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); | ||
141 | + } | ||
142 | + | ||
143 | +zero_mem: | ||
144 | + if (zero_middle) { | ||
145 | + memset(pad->buf + pad->head, 0, pad->buf_len - pad->head - pad->tail); | ||
146 | + } | ||
147 | + | ||
148 | + return 0; | ||
149 | +} | ||
150 | + | ||
151 | +static void bdrv_padding_destroy(BdrvRequestPadding *pad) | ||
152 | +{ | ||
153 | + if (pad->buf) { | ||
154 | + qemu_vfree(pad->buf); | ||
155 | + qemu_iovec_destroy(&pad->local_qiov); | ||
156 | + } | ||
157 | +} | ||
158 | + | ||
159 | +/* | ||
160 | + * bdrv_pad_request | ||
161 | + * | ||
162 | + * Exchange request parameters with padded request if needed. Don't include RMW | ||
163 | + * read of padding, bdrv_padding_rmw_read() should be called separately if | ||
164 | + * needed. | ||
165 | + * | ||
166 | + * All parameters except @bs are in-out: they represent original request at | ||
167 | + * function call and padded (if padding needed) at function finish. | ||
168 | + * | ||
169 | + * Function always succeeds. | ||
170 | + */ | ||
171 | +static bool bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, | ||
172 | + int64_t *offset, unsigned int *bytes, | ||
173 | + BdrvRequestPadding *pad) | ||
174 | +{ | ||
175 | + if (!bdrv_init_padding(bs, *offset, *bytes, pad)) { | ||
176 | + return false; | ||
177 | + } | ||
178 | + | ||
179 | + qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head, | ||
180 | + *qiov, 0, *bytes, | ||
181 | + pad->buf + pad->buf_len - pad->tail, pad->tail); | ||
182 | + *bytes += pad->head + pad->tail; | ||
183 | + *offset -= pad->head; | ||
184 | + *qiov = &pad->local_qiov; | ||
185 | + | ||
186 | + return true; | ||
187 | +} | ||
188 | + | ||
189 | int coroutine_fn bdrv_co_preadv(BdrvChild *child, | ||
190 | int64_t offset, unsigned int bytes, QEMUIOVector *qiov, | ||
191 | BdrvRequestFlags flags) | ||
24 | { | 192 | { |
25 | BdrvChild *c, *next; | 193 | BlockDriverState *bs = child->bs; |
26 | GSList *list = NULL, *p; | 194 | - BlockDriver *drv = bs->drv; |
27 | - uint64_t old_perm, old_shared; | 195 | BdrvTrackedRequest req; |
28 | uint64_t perm = 0, shared = BLK_PERM_ALL; | 196 | - |
197 | - uint64_t align = bs->bl.request_alignment; | ||
198 | - uint8_t *head_buf = NULL; | ||
199 | - uint8_t *tail_buf = NULL; | ||
200 | - QEMUIOVector local_qiov; | ||
201 | - bool use_local_qiov = false; | ||
202 | + BdrvRequestPadding pad; | ||
29 | int ret; | 203 | int ret; |
30 | 204 | ||
31 | @@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, | 205 | - trace_bdrv_co_preadv(child->bs, offset, bytes, flags); |
32 | bdrv_unref(from); | 206 | - |
207 | - if (!drv) { | ||
208 | - return -ENOMEDIUM; | ||
209 | - } | ||
210 | + trace_bdrv_co_preadv(bs, offset, bytes, flags); | ||
211 | |||
212 | ret = bdrv_check_byte_request(bs, offset, bytes); | ||
213 | if (ret < 0) { | ||
214 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, | ||
215 | flags |= BDRV_REQ_COPY_ON_READ; | ||
33 | } | 216 | } |
34 | 217 | ||
35 | - bdrv_get_cumulative_perm(to, &old_perm, &old_shared); | 218 | - /* Align read if necessary by padding qiov */ |
36 | - bdrv_set_perm(to, old_perm | perm, old_shared | shared); | 219 | - if (offset & (align - 1)) { |
37 | + bdrv_get_cumulative_perm(to, &perm, &shared); | 220 | - head_buf = qemu_blockalign(bs, align); |
38 | + bdrv_set_perm(to, perm, shared); | 221 | - qemu_iovec_init(&local_qiov, qiov->niov + 2); |
39 | 222 | - qemu_iovec_add(&local_qiov, head_buf, offset & (align - 1)); | |
223 | - qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size); | ||
224 | - use_local_qiov = true; | ||
225 | - | ||
226 | - bytes += offset & (align - 1); | ||
227 | - offset = offset & ~(align - 1); | ||
228 | - } | ||
229 | - | ||
230 | - if ((offset + bytes) & (align - 1)) { | ||
231 | - if (!use_local_qiov) { | ||
232 | - qemu_iovec_init(&local_qiov, qiov->niov + 1); | ||
233 | - qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size); | ||
234 | - use_local_qiov = true; | ||
235 | - } | ||
236 | - tail_buf = qemu_blockalign(bs, align); | ||
237 | - qemu_iovec_add(&local_qiov, tail_buf, | ||
238 | - align - ((offset + bytes) & (align - 1))); | ||
239 | - | ||
240 | - bytes = ROUND_UP(bytes, align); | ||
241 | - } | ||
242 | + bdrv_pad_request(bs, &qiov, &offset, &bytes, &pad); | ||
243 | |||
244 | tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ); | ||
245 | - ret = bdrv_aligned_preadv(child, &req, offset, bytes, align, | ||
246 | - use_local_qiov ? &local_qiov : qiov, | ||
247 | - flags); | ||
248 | + ret = bdrv_aligned_preadv(child, &req, offset, bytes, | ||
249 | + bs->bl.request_alignment, | ||
250 | + qiov, flags); | ||
251 | tracked_request_end(&req); | ||
252 | bdrv_dec_in_flight(bs); | ||
253 | |||
254 | - if (use_local_qiov) { | ||
255 | - qemu_iovec_destroy(&local_qiov); | ||
256 | - qemu_vfree(head_buf); | ||
257 | - qemu_vfree(tail_buf); | ||
258 | - } | ||
259 | + bdrv_padding_destroy(&pad); | ||
260 | |||
261 | return ret; | ||
262 | } | ||
263 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, | ||
264 | BdrvTrackedRequest *req) | ||
265 | { | ||
266 | BlockDriverState *bs = child->bs; | ||
267 | - uint8_t *buf = NULL; | ||
268 | QEMUIOVector local_qiov; | ||
269 | uint64_t align = bs->bl.request_alignment; | ||
270 | - unsigned int head_padding_bytes, tail_padding_bytes; | ||
271 | int ret = 0; | ||
272 | + bool padding; | ||
273 | + BdrvRequestPadding pad; | ||
274 | |||
275 | - head_padding_bytes = offset & (align - 1); | ||
276 | - tail_padding_bytes = (align - (offset + bytes)) & (align - 1); | ||
277 | - | ||
278 | - | ||
279 | - assert(flags & BDRV_REQ_ZERO_WRITE); | ||
280 | - if (head_padding_bytes || tail_padding_bytes) { | ||
281 | - buf = qemu_blockalign(bs, align); | ||
282 | - qemu_iovec_init_buf(&local_qiov, buf, align); | ||
283 | - } | ||
284 | - if (head_padding_bytes) { | ||
285 | - uint64_t zero_bytes = MIN(bytes, align - head_padding_bytes); | ||
286 | - | ||
287 | - /* RMW the unaligned part before head. */ | ||
288 | + padding = bdrv_init_padding(bs, offset, bytes, &pad); | ||
289 | + if (padding) { | ||
290 | mark_request_serialising(req, align); | ||
291 | wait_serialising_requests(req); | ||
292 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); | ||
293 | - ret = bdrv_aligned_preadv(child, req, offset & ~(align - 1), align, | ||
294 | - align, &local_qiov, 0); | ||
295 | - if (ret < 0) { | ||
296 | - goto fail; | ||
297 | - } | ||
298 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); | ||
299 | |||
300 | - memset(buf + head_padding_bytes, 0, zero_bytes); | ||
301 | - ret = bdrv_aligned_pwritev(child, req, offset & ~(align - 1), align, | ||
302 | - align, &local_qiov, | ||
303 | - flags & ~BDRV_REQ_ZERO_WRITE); | ||
304 | - if (ret < 0) { | ||
305 | - goto fail; | ||
306 | + bdrv_padding_rmw_read(child, req, &pad, true); | ||
307 | + | ||
308 | + if (pad.head || pad.merge_reads) { | ||
309 | + int64_t aligned_offset = offset & ~(align - 1); | ||
310 | + int64_t write_bytes = pad.merge_reads ? pad.buf_len : align; | ||
311 | + | ||
312 | + qemu_iovec_init_buf(&local_qiov, pad.buf, write_bytes); | ||
313 | + ret = bdrv_aligned_pwritev(child, req, aligned_offset, write_bytes, | ||
314 | + align, &local_qiov, | ||
315 | + flags & ~BDRV_REQ_ZERO_WRITE); | ||
316 | + if (ret < 0 || pad.merge_reads) { | ||
317 | + /* Error or all work is done */ | ||
318 | + goto out; | ||
319 | + } | ||
320 | + offset += write_bytes - pad.head; | ||
321 | + bytes -= write_bytes - pad.head; | ||
322 | } | ||
323 | - offset += zero_bytes; | ||
324 | - bytes -= zero_bytes; | ||
325 | } | ||
326 | |||
327 | assert(!bytes || (offset & (align - 1)) == 0); | ||
328 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, | ||
329 | ret = bdrv_aligned_pwritev(child, req, offset, aligned_bytes, align, | ||
330 | NULL, flags); | ||
331 | if (ret < 0) { | ||
332 | - goto fail; | ||
333 | + goto out; | ||
334 | } | ||
335 | bytes -= aligned_bytes; | ||
336 | offset += aligned_bytes; | ||
337 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, | ||
338 | |||
339 | assert(!bytes || (offset & (align - 1)) == 0); | ||
340 | if (bytes) { | ||
341 | - assert(align == tail_padding_bytes + bytes); | ||
342 | - /* RMW the unaligned part after tail. */ | ||
343 | - mark_request_serialising(req, align); | ||
344 | - wait_serialising_requests(req); | ||
345 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); | ||
346 | - ret = bdrv_aligned_preadv(child, req, offset, align, | ||
347 | - align, &local_qiov, 0); | ||
348 | - if (ret < 0) { | ||
349 | - goto fail; | ||
350 | - } | ||
351 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); | ||
352 | + assert(align == pad.tail + bytes); | ||
353 | |||
354 | - memset(buf, 0, bytes); | ||
355 | + qemu_iovec_init_buf(&local_qiov, pad.tail_buf, align); | ||
356 | ret = bdrv_aligned_pwritev(child, req, offset, align, align, | ||
357 | &local_qiov, flags & ~BDRV_REQ_ZERO_WRITE); | ||
358 | } | ||
359 | -fail: | ||
360 | - qemu_vfree(buf); | ||
361 | + | ||
362 | +out: | ||
363 | + bdrv_padding_destroy(&pad); | ||
364 | + | ||
365 | return ret; | ||
366 | - | ||
367 | } | ||
368 | |||
369 | /* | ||
370 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, | ||
371 | BlockDriverState *bs = child->bs; | ||
372 | BdrvTrackedRequest req; | ||
373 | uint64_t align = bs->bl.request_alignment; | ||
374 | - uint8_t *head_buf = NULL; | ||
375 | - uint8_t *tail_buf = NULL; | ||
376 | - QEMUIOVector local_qiov; | ||
377 | - bool use_local_qiov = false; | ||
378 | + BdrvRequestPadding pad; | ||
379 | int ret; | ||
380 | |||
381 | trace_bdrv_co_pwritev(child->bs, offset, bytes, flags); | ||
382 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, | ||
383 | goto out; | ||
384 | } | ||
385 | |||
386 | - if (offset & (align - 1)) { | ||
387 | - QEMUIOVector head_qiov; | ||
388 | - | ||
389 | + if (bdrv_pad_request(bs, &qiov, &offset, &bytes, &pad)) { | ||
390 | mark_request_serialising(&req, align); | ||
391 | wait_serialising_requests(&req); | ||
392 | - | ||
393 | - head_buf = qemu_blockalign(bs, align); | ||
394 | - qemu_iovec_init_buf(&head_qiov, head_buf, align); | ||
395 | - | ||
396 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_HEAD); | ||
397 | - ret = bdrv_aligned_preadv(child, &req, offset & ~(align - 1), align, | ||
398 | - align, &head_qiov, 0); | ||
399 | - if (ret < 0) { | ||
400 | - goto fail; | ||
401 | - } | ||
402 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_HEAD); | ||
403 | - | ||
404 | - qemu_iovec_init(&local_qiov, qiov->niov + 2); | ||
405 | - qemu_iovec_add(&local_qiov, head_buf, offset & (align - 1)); | ||
406 | - qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size); | ||
407 | - use_local_qiov = true; | ||
408 | - | ||
409 | - bytes += offset & (align - 1); | ||
410 | - offset = offset & ~(align - 1); | ||
411 | - | ||
412 | - /* We have read the tail already if the request is smaller | ||
413 | - * than one aligned block. | ||
414 | - */ | ||
415 | - if (bytes < align) { | ||
416 | - qemu_iovec_add(&local_qiov, head_buf + bytes, align - bytes); | ||
417 | - bytes = align; | ||
418 | - } | ||
419 | - } | ||
420 | - | ||
421 | - if ((offset + bytes) & (align - 1)) { | ||
422 | - QEMUIOVector tail_qiov; | ||
423 | - size_t tail_bytes; | ||
424 | - bool waited; | ||
425 | - | ||
426 | - mark_request_serialising(&req, align); | ||
427 | - waited = wait_serialising_requests(&req); | ||
428 | - assert(!waited || !use_local_qiov); | ||
429 | - | ||
430 | - tail_buf = qemu_blockalign(bs, align); | ||
431 | - qemu_iovec_init_buf(&tail_qiov, tail_buf, align); | ||
432 | - | ||
433 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); | ||
434 | - ret = bdrv_aligned_preadv(child, &req, (offset + bytes) & ~(align - 1), | ||
435 | - align, align, &tail_qiov, 0); | ||
436 | - if (ret < 0) { | ||
437 | - goto fail; | ||
438 | - } | ||
439 | - bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_AFTER_TAIL); | ||
440 | - | ||
441 | - if (!use_local_qiov) { | ||
442 | - qemu_iovec_init(&local_qiov, qiov->niov + 1); | ||
443 | - qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size); | ||
444 | - use_local_qiov = true; | ||
445 | - } | ||
446 | - | ||
447 | - tail_bytes = (offset + bytes) & (align - 1); | ||
448 | - qemu_iovec_add(&local_qiov, tail_buf + tail_bytes, align - tail_bytes); | ||
449 | - | ||
450 | - bytes = ROUND_UP(bytes, align); | ||
451 | + bdrv_padding_rmw_read(child, &req, &pad, false); | ||
452 | } | ||
453 | |||
454 | ret = bdrv_aligned_pwritev(child, &req, offset, bytes, align, | ||
455 | - use_local_qiov ? &local_qiov : qiov, | ||
456 | - flags); | ||
457 | + qiov, flags); | ||
458 | |||
459 | -fail: | ||
460 | + bdrv_padding_destroy(&pad); | ||
461 | |||
462 | - if (use_local_qiov) { | ||
463 | - qemu_iovec_destroy(&local_qiov); | ||
464 | - } | ||
465 | - qemu_vfree(head_buf); | ||
466 | - qemu_vfree(tail_buf); | ||
40 | out: | 467 | out: |
41 | g_slist_free(list); | 468 | tracked_request_end(&req); |
469 | bdrv_dec_in_flight(bs); | ||
470 | + | ||
471 | return ret; | ||
472 | } | ||
473 | |||
42 | -- | 474 | -- |
43 | 2.21.0 | 475 | 2.21.0 |
44 | 476 | ||
45 | 477 | diff view generated by jsdifflib |
1 | This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | turns a former error in 059 into success. | 2 | |
3 | 3 | Add handlers supporting qiov_offset parameter: | |
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 4 | bdrv_co_preadv_part |
5 | Message-id: 20190815153638.4600-3-mreitz@redhat.com | 5 | bdrv_co_pwritev_part |
6 | Reviewed-by: John Snow <jsnow@redhat.com> | 6 | bdrv_co_pwritev_compressed_part |
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | This is used to reduce need of defining local_qiovs and hd_qiovs in all |
8 | corners of block layer code. The following patches will increase usage | ||
9 | of this new API part by part. | ||
10 | |||
11 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
12 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | Message-id: 20190604161514.262241-5-vsementsov@virtuozzo.com | ||
14 | Message-Id: <20190604161514.262241-5-vsementsov@virtuozzo.com> | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | --- | 16 | --- |
9 | block/vmdk.c | 54 ++++++++++++++++++++++++-------------- | 17 | include/block/block_int.h | 15 ++++++ |
10 | tests/qemu-iotests/059 | 7 +++-- | 18 | block/backup.c | 2 +- |
11 | tests/qemu-iotests/059.out | 4 ++- | 19 | block/io.c | 96 +++++++++++++++++++++++++++++++-------- |
12 | 3 files changed, 42 insertions(+), 23 deletions(-) | 20 | qemu-img.c | 4 +- |
13 | 21 | 4 files changed, 95 insertions(+), 22 deletions(-) | |
14 | diff --git a/block/vmdk.c b/block/vmdk.c | 22 | |
23 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/block/vmdk.c | 25 | --- a/include/block/block_int.h |
17 | +++ b/block/vmdk.c | 26 | +++ b/include/block/block_int.h |
18 | @@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s) | 27 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { |
19 | } | 28 | */ |
20 | 29 | int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs, | |
21 | static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | 30 | uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); |
22 | - const char *desc_file_path, QDict *options, | 31 | + int coroutine_fn (*bdrv_co_preadv_part)(BlockDriverState *bs, |
23 | - Error **errp) | 32 | + uint64_t offset, uint64_t bytes, |
24 | + QDict *options, Error **errp) | 33 | + QEMUIOVector *qiov, size_t qiov_offset, int flags); |
34 | int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, | ||
35 | int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); | ||
36 | /** | ||
37 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
38 | */ | ||
39 | int coroutine_fn (*bdrv_co_pwritev)(BlockDriverState *bs, | ||
40 | uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); | ||
41 | + int coroutine_fn (*bdrv_co_pwritev_part)(BlockDriverState *bs, | ||
42 | + uint64_t offset, uint64_t bytes, | ||
43 | + QEMUIOVector *qiov, size_t qiov_offset, int flags); | ||
44 | |||
45 | /* | ||
46 | * Efficiently zero a region of the disk image. Typically an image format | ||
47 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
48 | |||
49 | int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs, | ||
50 | uint64_t offset, uint64_t bytes, QEMUIOVector *qiov); | ||
51 | + int coroutine_fn (*bdrv_co_pwritev_compressed_part)(BlockDriverState *bs, | ||
52 | + uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, | ||
53 | + size_t qiov_offset); | ||
54 | |||
55 | int (*bdrv_snapshot_create)(BlockDriverState *bs, | ||
56 | QEMUSnapshotInfo *sn_info); | ||
57 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
58 | const char *const *strong_runtime_opts; | ||
59 | }; | ||
60 | |||
61 | +static inline bool block_driver_can_compress(BlockDriver *drv) | ||
62 | +{ | ||
63 | + return drv->bdrv_co_pwritev_compressed || | ||
64 | + drv->bdrv_co_pwritev_compressed_part; | ||
65 | +} | ||
66 | + | ||
67 | typedef struct BlockLimits { | ||
68 | /* Alignment requirement, in bytes, for offset/length of I/O | ||
69 | * requests. Must be a power of 2 less than INT_MAX; defaults to | ||
70 | diff --git a/block/backup.c b/block/backup.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/block/backup.c | ||
73 | +++ b/block/backup.c | ||
74 | @@ -XXX,XX +XXX,XX @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, | ||
75 | return NULL; | ||
76 | } | ||
77 | |||
78 | - if (compress && target->drv->bdrv_co_pwritev_compressed == NULL) { | ||
79 | + if (compress && !block_driver_can_compress(target->drv)) { | ||
80 | error_setg(errp, "Compression is not supported for this drive %s", | ||
81 | bdrv_get_device_name(target)); | ||
82 | return NULL; | ||
83 | diff --git a/block/io.c b/block/io.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/block/io.c | ||
86 | +++ b/block/io.c | ||
87 | @@ -XXX,XX +XXX,XX @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) | ||
88 | |||
89 | /* Default alignment based on whether driver has byte interface */ | ||
90 | bs->bl.request_alignment = (drv->bdrv_co_preadv || | ||
91 | - drv->bdrv_aio_preadv) ? 1 : 512; | ||
92 | + drv->bdrv_aio_preadv || | ||
93 | + drv->bdrv_co_preadv_part) ? 1 : 512; | ||
94 | |||
95 | /* Take some limits from the children as a default */ | ||
96 | if (bs->file) { | ||
97 | @@ -XXX,XX +XXX,XX @@ static void bdrv_co_io_em_complete(void *opaque, int ret) | ||
98 | |||
99 | static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, | ||
100 | uint64_t offset, uint64_t bytes, | ||
101 | - QEMUIOVector *qiov, int flags) | ||
102 | + QEMUIOVector *qiov, | ||
103 | + size_t qiov_offset, int flags) | ||
25 | { | 104 | { |
26 | int ret; | 105 | BlockDriver *drv = bs->drv; |
27 | int matches; | 106 | int64_t sector_num; |
28 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | 107 | unsigned int nb_sectors; |
29 | const char *p, *np; | 108 | + QEMUIOVector local_qiov; |
30 | int64_t sectors = 0; | 109 | + int ret; |
31 | int64_t flat_offset; | 110 | |
32 | + char *desc_file_dir = NULL; | 111 | assert(!(flags & ~BDRV_REQ_MASK)); |
33 | char *extent_path; | 112 | assert(!(flags & BDRV_REQ_NO_FALLBACK)); |
34 | BdrvChild *extent_file; | 113 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, |
35 | BDRVVmdkState *s = bs->opaque; | 114 | return -ENOMEDIUM; |
36 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | 115 | } |
37 | continue; | 116 | |
38 | } | 117 | + if (drv->bdrv_co_preadv_part) { |
39 | 118 | + return drv->bdrv_co_preadv_part(bs, offset, bytes, qiov, qiov_offset, | |
40 | - if (!path_is_absolute(fname) && !path_has_protocol(fname) && | 119 | + flags); |
41 | - !desc_file_path[0]) | 120 | + } |
42 | - { | 121 | + |
43 | - bdrv_refresh_filename(bs->file->bs); | 122 | + if (qiov_offset > 0 || bytes != qiov->size) { |
44 | - error_setg(errp, "Cannot use relative extent paths with VMDK " | 123 | + qemu_iovec_init_slice(&local_qiov, qiov, qiov_offset, bytes); |
45 | - "descriptor file '%s'", bs->file->bs->filename); | 124 | + qiov = &local_qiov; |
46 | - return -EINVAL; | 125 | + } |
47 | - } | 126 | + |
48 | + if (path_is_absolute(fname)) { | 127 | if (drv->bdrv_co_preadv) { |
49 | + extent_path = g_strdup(fname); | 128 | - return drv->bdrv_co_preadv(bs, offset, bytes, qiov, flags); |
50 | + } else { | 129 | + ret = drv->bdrv_co_preadv(bs, offset, bytes, qiov, flags); |
51 | + if (!desc_file_dir) { | 130 | + goto out; |
52 | + desc_file_dir = bdrv_dirname(bs->file->bs, errp); | 131 | } |
53 | + if (!desc_file_dir) { | 132 | |
54 | + bdrv_refresh_filename(bs->file->bs); | 133 | if (drv->bdrv_aio_preadv) { |
55 | + error_prepend(errp, "Cannot use relative paths with VMDK " | 134 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, |
56 | + "descriptor file '%s': ", | 135 | acb = drv->bdrv_aio_preadv(bs, offset, bytes, qiov, flags, |
57 | + bs->file->bs->filename); | 136 | bdrv_co_io_em_complete, &co); |
58 | + ret = -EINVAL; | 137 | if (acb == NULL) { |
59 | + goto out; | 138 | - return -EIO; |
60 | + } | 139 | + ret = -EIO; |
61 | + } | 140 | + goto out; |
62 | 141 | } else { | |
63 | - extent_path = path_combine(desc_file_path, fname); | 142 | qemu_coroutine_yield(); |
64 | + extent_path = g_strconcat(desc_file_dir, fname, NULL); | 143 | - return co.ret; |
65 | + } | 144 | + ret = co.ret; |
66 | |||
67 | ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents); | ||
68 | assert(ret < 32); | ||
69 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
70 | g_free(extent_path); | ||
71 | if (local_err) { | ||
72 | error_propagate(errp, local_err); | ||
73 | - return -EINVAL; | ||
74 | + ret = -EINVAL; | ||
75 | + goto out; | 145 | + goto out; |
76 | } | 146 | } |
77 | 147 | } | |
78 | /* save to extents array */ | 148 | |
79 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | 149 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, |
80 | 0, 0, 0, 0, 0, &extent, errp); | 150 | assert(bytes <= BDRV_REQUEST_MAX_BYTES); |
81 | if (ret < 0) { | 151 | assert(drv->bdrv_co_readv); |
82 | bdrv_unref_child(bs, extent_file); | 152 | |
83 | - return ret; | 153 | - return drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); |
84 | + goto out; | 154 | + ret = drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); |
85 | } | ||
86 | extent->flat_start_offset = flat_offset << 9; | ||
87 | } else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) { | ||
88 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
89 | g_free(buf); | ||
90 | if (ret) { | ||
91 | bdrv_unref_child(bs, extent_file); | ||
92 | - return ret; | ||
93 | + goto out; | ||
94 | } | ||
95 | extent = &s->extents[s->num_extents - 1]; | ||
96 | } else if (!strcmp(type, "SESPARSE")) { | ||
97 | ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp); | ||
98 | if (ret) { | ||
99 | bdrv_unref_child(bs, extent_file); | ||
100 | - return ret; | ||
101 | + goto out; | ||
102 | } | ||
103 | extent = &s->extents[s->num_extents - 1]; | ||
104 | } else { | ||
105 | error_setg(errp, "Unsupported extent type '%s'", type); | ||
106 | bdrv_unref_child(bs, extent_file); | ||
107 | - return -ENOTSUP; | ||
108 | + ret = -ENOTSUP; | ||
109 | + goto out; | ||
110 | } | ||
111 | extent->type = g_strdup(type); | ||
112 | } | ||
113 | - return 0; | ||
114 | + | ||
115 | + ret = 0; | ||
116 | + goto out; | ||
117 | |||
118 | invalid: | ||
119 | np = next_line(p); | ||
120 | @@ -XXX,XX +XXX,XX @@ invalid: | ||
121 | np--; | ||
122 | } | ||
123 | error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p); | ||
124 | - return -EINVAL; | ||
125 | + ret = -EINVAL; | ||
126 | + | 155 | + |
127 | +out: | 156 | +out: |
128 | + g_free(desc_file_dir); | 157 | + if (qiov == &local_qiov) { |
158 | + qemu_iovec_destroy(&local_qiov); | ||
159 | + } | ||
160 | + | ||
129 | + return ret; | 161 | + return ret; |
130 | } | 162 | } |
131 | 163 | ||
132 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | 164 | static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, |
133 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | 165 | uint64_t offset, uint64_t bytes, |
134 | } | 166 | - QEMUIOVector *qiov, int flags) |
135 | s->create_type = g_strdup(ct); | 167 | + QEMUIOVector *qiov, |
136 | s->desc_offset = 0; | 168 | + size_t qiov_offset, int flags) |
137 | - ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options, | 169 | { |
138 | - errp); | 170 | BlockDriver *drv = bs->drv; |
139 | + ret = vmdk_parse_extents(buf, bs, options, errp); | 171 | int64_t sector_num; |
140 | exit: | 172 | unsigned int nb_sectors; |
173 | + QEMUIOVector local_qiov; | ||
174 | int ret; | ||
175 | |||
176 | assert(!(flags & ~BDRV_REQ_MASK)); | ||
177 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, | ||
178 | return -ENOMEDIUM; | ||
179 | } | ||
180 | |||
181 | + if (drv->bdrv_co_pwritev_part) { | ||
182 | + ret = drv->bdrv_co_pwritev_part(bs, offset, bytes, qiov, qiov_offset, | ||
183 | + flags & bs->supported_write_flags); | ||
184 | + flags &= ~bs->supported_write_flags; | ||
185 | + goto emulate_flags; | ||
186 | + } | ||
187 | + | ||
188 | + if (qiov_offset > 0 || bytes != qiov->size) { | ||
189 | + qemu_iovec_init_slice(&local_qiov, qiov, qiov_offset, bytes); | ||
190 | + qiov = &local_qiov; | ||
191 | + } | ||
192 | + | ||
193 | if (drv->bdrv_co_pwritev) { | ||
194 | ret = drv->bdrv_co_pwritev(bs, offset, bytes, qiov, | ||
195 | flags & bs->supported_write_flags); | ||
196 | @@ -XXX,XX +XXX,XX @@ emulate_flags: | ||
197 | ret = bdrv_co_flush(bs); | ||
198 | } | ||
199 | |||
200 | + if (qiov == &local_qiov) { | ||
201 | + qemu_iovec_destroy(&local_qiov); | ||
202 | + } | ||
203 | + | ||
141 | return ret; | 204 | return ret; |
142 | } | 205 | } |
143 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | 206 | |
144 | index XXXXXXX..XXXXXXX 100755 | 207 | static int coroutine_fn |
145 | --- a/tests/qemu-iotests/059 | 208 | bdrv_driver_pwritev_compressed(BlockDriverState *bs, uint64_t offset, |
146 | +++ b/tests/qemu-iotests/059 | 209 | - uint64_t bytes, QEMUIOVector *qiov) |
147 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 | 210 | + uint64_t bytes, QEMUIOVector *qiov, |
148 | 211 | + size_t qiov_offset) | |
149 | echo | 212 | { |
150 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" | 213 | BlockDriver *drv = bs->drv; |
151 | +# Should work, because bdrv_dirname() works fine with blkdebug | 214 | + QEMUIOVector local_qiov; |
152 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | 215 | + int ret; |
153 | -$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \ | 216 | |
154 | - | _filter_testdir | _filter_imgfmt | 217 | if (!drv) { |
155 | +$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | 218 | return -ENOMEDIUM; |
156 | + -c info \ | 219 | } |
157 | + 2>&1 \ | 220 | |
158 | + | _filter_testdir | _filter_imgfmt | _filter_img_info | 221 | - if (!drv->bdrv_co_pwritev_compressed) { |
159 | _cleanup_test_img | 222 | + if (!block_driver_can_compress(drv)) { |
160 | 223 | return -ENOTSUP; | |
161 | echo | 224 | } |
162 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | 225 | |
226 | - return drv->bdrv_co_pwritev_compressed(bs, offset, bytes, qiov); | ||
227 | + if (drv->bdrv_co_pwritev_compressed_part) { | ||
228 | + return drv->bdrv_co_pwritev_compressed_part(bs, offset, bytes, | ||
229 | + qiov, qiov_offset); | ||
230 | + } | ||
231 | + | ||
232 | + if (qiov_offset == 0) { | ||
233 | + return drv->bdrv_co_pwritev_compressed(bs, offset, bytes, qiov); | ||
234 | + } | ||
235 | + | ||
236 | + qemu_iovec_init_slice(&local_qiov, qiov, qiov_offset, bytes); | ||
237 | + ret = drv->bdrv_co_pwritev_compressed(bs, offset, bytes, &local_qiov); | ||
238 | + qemu_iovec_destroy(&local_qiov); | ||
239 | + | ||
240 | + return ret; | ||
241 | } | ||
242 | |||
243 | static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
244 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
245 | qemu_iovec_init_buf(&local_qiov, bounce_buffer, pnum); | ||
246 | |||
247 | ret = bdrv_driver_preadv(bs, cluster_offset, pnum, | ||
248 | - &local_qiov, 0); | ||
249 | + &local_qiov, 0, 0); | ||
250 | if (ret < 0) { | ||
251 | goto err; | ||
252 | } | ||
253 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
254 | * necessary to flush even in cache=writethrough mode. | ||
255 | */ | ||
256 | ret = bdrv_driver_pwritev(bs, cluster_offset, pnum, | ||
257 | - &local_qiov, | ||
258 | + &local_qiov, 0, | ||
259 | BDRV_REQ_WRITE_UNCHANGED); | ||
260 | } | ||
261 | |||
262 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
263 | qemu_iovec_init(&local_qiov, qiov->niov); | ||
264 | qemu_iovec_concat(&local_qiov, qiov, progress, pnum - skip_bytes); | ||
265 | ret = bdrv_driver_preadv(bs, offset + progress, local_qiov.size, | ||
266 | - &local_qiov, 0); | ||
267 | + &local_qiov, 0, 0); | ||
268 | qemu_iovec_destroy(&local_qiov); | ||
269 | if (ret < 0) { | ||
270 | goto err; | ||
271 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, | ||
272 | |||
273 | max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align); | ||
274 | if (bytes <= max_bytes && bytes <= max_transfer) { | ||
275 | - ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0); | ||
276 | + ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0, 0); | ||
277 | goto out; | ||
278 | } | ||
279 | |||
280 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, | ||
281 | qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num); | ||
282 | |||
283 | ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining, | ||
284 | - num, &local_qiov, 0); | ||
285 | + num, &local_qiov, 0, 0); | ||
286 | max_bytes -= num; | ||
287 | qemu_iovec_destroy(&local_qiov); | ||
288 | } else { | ||
289 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, | ||
290 | } | ||
291 | qemu_iovec_init_buf(&qiov, buf, num); | ||
292 | |||
293 | - ret = bdrv_driver_pwritev(bs, offset, num, &qiov, write_flags); | ||
294 | + ret = bdrv_driver_pwritev(bs, offset, num, &qiov, 0, write_flags); | ||
295 | |||
296 | /* Keep bounce buffer around if it is big enough for all | ||
297 | * all future requests. | ||
298 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, | ||
299 | bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO); | ||
300 | ret = bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags); | ||
301 | } else if (flags & BDRV_REQ_WRITE_COMPRESSED) { | ||
302 | - ret = bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov); | ||
303 | + ret = bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov, 0); | ||
304 | } else if (bytes <= max_transfer) { | ||
305 | bdrv_debug_event(bs, BLKDBG_PWRITEV); | ||
306 | - ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, flags); | ||
307 | + ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, 0, flags); | ||
308 | } else { | ||
309 | bdrv_debug_event(bs, BLKDBG_PWRITEV); | ||
310 | while (bytes_remaining) { | ||
311 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, | ||
312 | qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num); | ||
313 | |||
314 | ret = bdrv_driver_pwritev(bs, offset + bytes - bytes_remaining, | ||
315 | - num, &local_qiov, local_flags); | ||
316 | + num, &local_qiov, 0, local_flags); | ||
317 | qemu_iovec_destroy(&local_qiov); | ||
318 | if (ret < 0) { | ||
319 | break; | ||
320 | diff --git a/qemu-img.c b/qemu-img.c | ||
163 | index XXXXXXX..XXXXXXX 100644 | 321 | index XXXXXXX..XXXXXXX 100644 |
164 | --- a/tests/qemu-iotests/059.out | 322 | --- a/qemu-img.c |
165 | +++ b/tests/qemu-iotests/059.out | 323 | +++ b/qemu-img.c |
166 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | 324 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) |
167 | 325 | const char *preallocation = | |
168 | === Testing monolithicFlat with internally generated JSON file name === | 326 | qemu_opt_get(opts, BLOCK_OPT_PREALLOC); |
169 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | 327 | |
170 | -qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' | 328 | - if (drv && !drv->bdrv_co_pwritev_compressed) { |
171 | +format name: IMGFMT | 329 | + if (drv && !block_driver_can_compress(drv)) { |
172 | +cluster size: 0 bytes | 330 | error_report("Compression not supported for this file format"); |
173 | +vm state offset: 0 bytes | 331 | ret = -1; |
174 | 332 | goto out; | |
175 | === Testing version 3 === | 333 | @@ -XXX,XX +XXX,XX @@ static int img_convert(int argc, char **argv) |
176 | image: TEST_DIR/iotest-version3.IMGFMT | 334 | } |
335 | out_bs = blk_bs(s.target); | ||
336 | |||
337 | - if (s.compressed && !out_bs->drv->bdrv_co_pwritev_compressed) { | ||
338 | + if (s.compressed && !block_driver_can_compress(out_bs->drv)) { | ||
339 | error_report("Compression not supported for this file format"); | ||
340 | ret = -1; | ||
341 | goto out; | ||
177 | -- | 342 | -- |
178 | 2.21.0 | 343 | 2.21.0 |
179 | 344 | ||
180 | 345 | diff view generated by jsdifflib |
1 | Compressed writes generally have to write full clusters, not just in | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | theory but also in practice when it comes to vmdk's streamOptimized | ||
3 | subformat. It currently is just silently broken for writes with | ||
4 | non-zero in-cluster offsets: | ||
5 | 2 | ||
6 | $ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M | 3 | Use and support new API in bdrv_co_do_copy_on_readv. Note that in case |
7 | $ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk | 4 | of allocated-in-top we need to shrink read size to MIN(..) by hand, as |
8 | wrote 4096/4096 bytes at offset 4096 | 5 | pre-patch this was actually done implicitly by qemu_iovec_concat (and |
9 | 4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec) | 6 | we used local_qiov.size). |
10 | read failed: Invalid argument | ||
11 | 7 | ||
12 | (The technical reason is that vmdk_write_extent() just writes the | 8 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
13 | incomplete compressed data actually to offset 4k. When reading the | 9 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
14 | data, vmdk_read_extent() looks at offset 0 and finds the compressed data | 10 | Message-id: 20190604161514.262241-6-vsementsov@virtuozzo.com |
15 | size to be 0, because that is what it reads from there. This yields an | 11 | Message-Id: <20190604161514.262241-6-vsementsov@virtuozzo.com> |
16 | error.) | 12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
13 | --- | ||
14 | block/io.c | 18 +++++++++--------- | ||
15 | 1 file changed, 9 insertions(+), 9 deletions(-) | ||
17 | 16 | ||
18 | For incomplete writes with zero in-cluster offsets, the error path when | 17 | diff --git a/block/io.c b/block/io.c |
19 | reading the rest of the cluster is a bit different, but the result is | ||
20 | the same: | ||
21 | |||
22 | $ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M | ||
23 | $ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk | ||
24 | wrote 4096/4096 bytes at offset 0 | ||
25 | 4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec) | ||
26 | read failed: Invalid argument | ||
27 | |||
28 | (Here, vmdk_read_extent() finds the data and then sees that the | ||
29 | uncompressed data is short.) | ||
30 | |||
31 | It is better to reject invalid writes than to make the user believe they | ||
32 | might have succeeded and then fail when trying to read it back. | ||
33 | |||
34 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
35 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
36 | Message-id: 20190815153638.4600-5-mreitz@redhat.com | ||
37 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
38 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
39 | --- | ||
40 | block/vmdk.c | 10 ++++++++++ | ||
41 | 1 file changed, 10 insertions(+) | ||
42 | |||
43 | diff --git a/block/vmdk.c b/block/vmdk.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/block/vmdk.c | 19 | --- a/block/io.c |
46 | +++ b/block/vmdk.c | 20 | +++ b/block/io.c |
47 | @@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, | 21 | @@ -XXX,XX +XXX,XX @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, uint64_t offset, |
48 | if (extent->compressed) { | 22 | |
49 | void *compressed_data; | 23 | static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, |
50 | 24 | int64_t offset, unsigned int bytes, QEMUIOVector *qiov, | |
51 | + /* Only whole clusters */ | 25 | - int flags) |
52 | + if (offset_in_cluster || | 26 | + size_t qiov_offset, int flags) |
53 | + n_bytes > (extent->cluster_sectors * SECTOR_SIZE) || | 27 | { |
54 | + (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) && | 28 | BlockDriverState *bs = child->bs; |
55 | + offset + n_bytes != extent->end_sector * SECTOR_SIZE)) | 29 | |
56 | + { | 30 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, |
57 | + ret = -EINVAL; | 31 | void *bounce_buffer; |
58 | + goto out; | 32 | |
59 | + } | 33 | BlockDriver *drv = bs->drv; |
34 | - QEMUIOVector local_qiov; | ||
35 | int64_t cluster_offset; | ||
36 | int64_t cluster_bytes; | ||
37 | size_t skip_bytes; | ||
38 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
39 | assert(skip_bytes < pnum); | ||
40 | |||
41 | if (ret <= 0) { | ||
42 | + QEMUIOVector local_qiov; | ||
60 | + | 43 | + |
61 | if (!extent->has_marker) { | 44 | /* Must copy-on-read; use the bounce buffer */ |
62 | ret = -EINVAL; | 45 | pnum = MIN(pnum, MAX_BOUNCE_BUFFER); |
46 | qemu_iovec_init_buf(&local_qiov, bounce_buffer, pnum); | ||
47 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
48 | } | ||
49 | |||
50 | if (!(flags & BDRV_REQ_PREFETCH)) { | ||
51 | - qemu_iovec_from_buf(qiov, progress, bounce_buffer + skip_bytes, | ||
52 | + qemu_iovec_from_buf(qiov, qiov_offset + progress, | ||
53 | + bounce_buffer + skip_bytes, | ||
54 | pnum - skip_bytes); | ||
55 | } | ||
56 | } else if (!(flags & BDRV_REQ_PREFETCH)) { | ||
57 | /* Read directly into the destination */ | ||
58 | - qemu_iovec_init(&local_qiov, qiov->niov); | ||
59 | - qemu_iovec_concat(&local_qiov, qiov, progress, pnum - skip_bytes); | ||
60 | - ret = bdrv_driver_preadv(bs, offset + progress, local_qiov.size, | ||
61 | - &local_qiov, 0, 0); | ||
62 | - qemu_iovec_destroy(&local_qiov); | ||
63 | + ret = bdrv_driver_preadv(bs, offset + progress, | ||
64 | + MIN(pnum - skip_bytes, bytes - progress), | ||
65 | + qiov, qiov_offset + progress, 0); | ||
66 | if (ret < 0) { | ||
67 | goto err; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, | ||
70 | } | ||
71 | |||
72 | if (!ret || pnum != bytes) { | ||
73 | - ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, flags); | ||
74 | + ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, 0, flags); | ||
75 | goto out; | ||
76 | } else if (flags & BDRV_REQ_PREFETCH) { | ||
63 | goto out; | 77 | goto out; |
64 | -- | 78 | -- |
65 | 2.21.0 | 79 | 2.21.0 |
66 | 80 | ||
67 | 81 | diff view generated by jsdifflib |
1 | iotest 126 requires backing file support, which flat vmdks cannot offer. | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | Skip this test for such subformats. | ||
3 | 2 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | Allocate bounce_buffer only if it is really needed. Also, sub-optimize |
5 | Message-id: 20190815153638.4600-8-mreitz@redhat.com | 4 | allocation size (why not?). |
6 | Reviewed-by: John Snow <jsnow@redhat.com> | 5 | |
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
7 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Message-id: 20190604161514.262241-7-vsementsov@virtuozzo.com | ||
9 | Message-Id: <20190604161514.262241-7-vsementsov@virtuozzo.com> | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | --- | 11 | --- |
9 | tests/qemu-iotests/126 | 2 ++ | 12 | block/io.c | 21 ++++++++++++--------- |
10 | 1 file changed, 2 insertions(+) | 13 | 1 file changed, 12 insertions(+), 9 deletions(-) |
11 | 14 | ||
12 | diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126 | 15 | diff --git a/block/io.c b/block/io.c |
13 | index XXXXXXX..XXXXXXX 100755 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/tests/qemu-iotests/126 | 17 | --- a/block/io.c |
15 | +++ b/tests/qemu-iotests/126 | 18 | +++ b/block/io.c |
16 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | 19 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, |
17 | 20 | * modifying the image file. This is critical for zero-copy guest I/O | |
18 | # Needs backing file support | 21 | * where anything might happen inside guest memory. |
19 | _supported_fmt qcow qcow2 qed vmdk | 22 | */ |
20 | +_unsupported_imgopts "subformat=monolithicFlat" \ | 23 | - void *bounce_buffer; |
21 | + "subformat=twoGbMaxExtentFlat" | 24 | + void *bounce_buffer = NULL; |
22 | # This is the default protocol (and we want to test the difference between | 25 | |
23 | # colons which separate a protocol prefix from the rest and colons which are | 26 | BlockDriver *drv = bs->drv; |
24 | # just part of the filename, so we cannot test protocols which require a prefix) | 27 | int64_t cluster_offset; |
28 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
29 | trace_bdrv_co_do_copy_on_readv(bs, offset, bytes, | ||
30 | cluster_offset, cluster_bytes); | ||
31 | |||
32 | - bounce_buffer = qemu_try_blockalign(bs, | ||
33 | - MIN(MIN(max_transfer, cluster_bytes), | ||
34 | - MAX_BOUNCE_BUFFER)); | ||
35 | - if (bounce_buffer == NULL) { | ||
36 | - ret = -ENOMEM; | ||
37 | - goto err; | ||
38 | - } | ||
39 | - | ||
40 | while (cluster_bytes) { | ||
41 | int64_t pnum; | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | ||
44 | |||
45 | /* Must copy-on-read; use the bounce buffer */ | ||
46 | pnum = MIN(pnum, MAX_BOUNCE_BUFFER); | ||
47 | + if (!bounce_buffer) { | ||
48 | + int64_t max_we_need = MAX(pnum, cluster_bytes - pnum); | ||
49 | + int64_t max_allowed = MIN(max_transfer, MAX_BOUNCE_BUFFER); | ||
50 | + int64_t bounce_buffer_len = MIN(max_we_need, max_allowed); | ||
51 | + | ||
52 | + bounce_buffer = qemu_try_blockalign(bs, bounce_buffer_len); | ||
53 | + if (!bounce_buffer) { | ||
54 | + ret = -ENOMEM; | ||
55 | + goto err; | ||
56 | + } | ||
57 | + } | ||
58 | qemu_iovec_init_buf(&local_qiov, bounce_buffer, pnum); | ||
59 | |||
60 | ret = bdrv_driver_preadv(bs, cluster_offset, pnum, | ||
25 | -- | 61 | -- |
26 | 2.21.0 | 62 | 2.21.0 |
27 | 63 | ||
28 | 64 | diff view generated by jsdifflib |
1 | From: Nir Soffer <nirsof@gmail.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Quoting cache mode is not needed, and most tests use unquoted values. | 3 | Use and support new API in bdrv_co_do_copy_on_readv. |
4 | Unify all test to use the same style. | ||
5 | 4 | ||
6 | Message-id: 20190827173432.7656-1-nsoffer@redhat.com | 5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
7 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | 6 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Message-id: 20190604161514.262241-8-vsementsov@virtuozzo.com |
8 | Message-Id: <20190604161514.262241-8-vsementsov@virtuozzo.com> | ||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | --- | 10 | --- |
10 | tests/qemu-iotests/026 | 4 ++-- | 11 | block/io.c | 21 ++++++++------------- |
11 | tests/qemu-iotests/039 | 4 ++-- | 12 | 1 file changed, 8 insertions(+), 13 deletions(-) |
12 | tests/qemu-iotests/052 | 2 +- | ||
13 | tests/qemu-iotests/091 | 4 ++-- | ||
14 | 4 files changed, 7 insertions(+), 7 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 | 14 | diff --git a/block/io.c b/block/io.c |
17 | index XXXXXXX..XXXXXXX 100755 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/tests/qemu-iotests/026 | 16 | --- a/block/io.c |
19 | +++ b/tests/qemu-iotests/026 | 17 | +++ b/block/io.c |
20 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 18 | @@ -XXX,XX +XXX,XX @@ err: |
21 | # Currently only qcow2 supports rebasing | 19 | */ |
22 | _supported_fmt qcow2 | 20 | static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, |
23 | _supported_proto file | 21 | BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, |
24 | -_default_cache_mode "writethrough" | 22 | - int64_t align, QEMUIOVector *qiov, int flags) |
25 | -_supported_cache_modes "writethrough" "none" | 23 | + int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) |
26 | +_default_cache_mode writethrough | 24 | { |
27 | +_supported_cache_modes writethrough none | 25 | BlockDriverState *bs = child->bs; |
28 | # The refcount table tests expect a certain minimum width for refcount entries | 26 | int64_t total_bytes, max_bytes; |
29 | # (so that the refcount table actually needs to grow); that minimum is 16 bits, | 27 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, |
30 | # being the default refcount entry width. | 28 | assert(is_power_of_2(align)); |
31 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 | 29 | assert((offset & (align - 1)) == 0); |
32 | index XXXXXXX..XXXXXXX 100755 | 30 | assert((bytes & (align - 1)) == 0); |
33 | --- a/tests/qemu-iotests/039 | 31 | - assert(!qiov || bytes == qiov->size); |
34 | +++ b/tests/qemu-iotests/039 | 32 | assert((bs->open_flags & BDRV_O_NO_IO) == 0); |
35 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 33 | max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX), |
36 | _supported_fmt qcow2 | 34 | align); |
37 | _supported_proto file | 35 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, |
38 | _supported_os Linux | 36 | } |
39 | -_default_cache_mode "writethrough" | 37 | |
40 | -_supported_cache_modes "writethrough" | 38 | if (!ret || pnum != bytes) { |
41 | +_default_cache_mode writethrough | 39 | - ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov, 0, flags); |
42 | +_supported_cache_modes writethrough | 40 | + ret = bdrv_co_do_copy_on_readv(child, offset, bytes, |
43 | 41 | + qiov, qiov_offset, flags); | |
44 | size=128M | 42 | goto out; |
45 | 43 | } else if (flags & BDRV_REQ_PREFETCH) { | |
46 | diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052 | 44 | goto out; |
47 | index XXXXXXX..XXXXXXX 100755 | 45 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, |
48 | --- a/tests/qemu-iotests/052 | 46 | |
49 | +++ b/tests/qemu-iotests/052 | 47 | max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align); |
50 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | 48 | if (bytes <= max_bytes && bytes <= max_transfer) { |
51 | _supported_proto file | 49 | - ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0, 0); |
52 | 50 | + ret = bdrv_driver_preadv(bs, offset, bytes, qiov, qiov_offset, 0); | |
53 | # Don't do O_DIRECT on tmpfs | 51 | goto out; |
54 | -_supported_cache_modes "writeback" "writethrough" "unsafe" | 52 | } |
55 | +_supported_cache_modes writeback writethrough unsafe | 53 | |
56 | 54 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, | |
57 | size=128M | 55 | int num; |
58 | _make_test_img $size | 56 | |
59 | diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 | 57 | if (max_bytes) { |
60 | index XXXXXXX..XXXXXXX 100755 | 58 | - QEMUIOVector local_qiov; |
61 | --- a/tests/qemu-iotests/091 | 59 | - |
62 | +++ b/tests/qemu-iotests/091 | 60 | num = MIN(bytes_remaining, MIN(max_bytes, max_transfer)); |
63 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 61 | assert(num); |
64 | _supported_fmt qcow2 | 62 | - qemu_iovec_init(&local_qiov, qiov->niov); |
65 | _supported_proto file | 63 | - qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num); |
66 | _supported_os Linux | 64 | |
67 | -_default_cache_mode "none" | 65 | ret = bdrv_driver_preadv(bs, offset + bytes - bytes_remaining, |
68 | -_supported_cache_modes "writethrough" "none" "writeback" | 66 | - num, &local_qiov, 0, 0); |
69 | +_default_cache_mode none | 67 | + num, qiov, bytes - bytes_remaining, 0); |
70 | +_supported_cache_modes writethrough none writeback | 68 | max_bytes -= num; |
71 | 69 | - qemu_iovec_destroy(&local_qiov); | |
72 | size=1G | 70 | } else { |
71 | num = bytes_remaining; | ||
72 | ret = qemu_iovec_memset(qiov, bytes - bytes_remaining, 0, | ||
73 | @@ -XXX,XX +XXX,XX @@ static int bdrv_padding_rmw_read(BdrvChild *child, | ||
74 | bdrv_debug_event(bs, BLKDBG_PWRITEV_RMW_TAIL); | ||
75 | } | ||
76 | ret = bdrv_aligned_preadv(child, req, req->overlap_offset, bytes, | ||
77 | - align, &local_qiov, 0); | ||
78 | + align, &local_qiov, 0, 0); | ||
79 | if (ret < 0) { | ||
80 | return ret; | ||
81 | } | ||
82 | @@ -XXX,XX +XXX,XX @@ static int bdrv_padding_rmw_read(BdrvChild *child, | ||
83 | ret = bdrv_aligned_preadv( | ||
84 | child, req, | ||
85 | req->overlap_offset + req->overlap_bytes - align, | ||
86 | - align, align, &local_qiov, 0); | ||
87 | + align, align, &local_qiov, 0, 0); | ||
88 | if (ret < 0) { | ||
89 | return ret; | ||
90 | } | ||
91 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, | ||
92 | tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ); | ||
93 | ret = bdrv_aligned_preadv(child, &req, offset, bytes, | ||
94 | bs->bl.request_alignment, | ||
95 | - qiov, flags); | ||
96 | + qiov, 0, flags); | ||
97 | tracked_request_end(&req); | ||
98 | bdrv_dec_in_flight(bs); | ||
73 | 99 | ||
74 | -- | 100 | -- |
75 | 2.21.0 | 101 | 2.21.0 |
76 | 102 | ||
77 | 103 | diff view generated by jsdifflib |
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Fixes: a6b257a08e3d72219f03e461a52152672fec0612 | 3 | Use and support new API in bdrv_aligned_pwritev. |
4 | ("file-posix: Handle undetectable alignment") | 4 | |
5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
6 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
7 | Message-id: 20190604161514.262241-9-vsementsov@virtuozzo.com | ||
8 | Message-Id: <20190604161514.262241-9-vsementsov@virtuozzo.com> | ||
5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
6 | Message-id: 20190827101328.4062-1-stefanha@redhat.com | ||
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | 10 | --- |
10 | block/file-posix.c | 2 +- | 11 | block/io.c | 27 +++++++++++++-------------- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 13 insertions(+), 14 deletions(-) |
12 | 13 | ||
13 | diff --git a/block/file-posix.c b/block/file-posix.c | 14 | diff --git a/block/io.c b/block/io.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/block/file-posix.c | 16 | --- a/block/io.c |
16 | +++ b/block/file-posix.c | 17 | +++ b/block/io.c |
17 | @@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) | 18 | @@ -XXX,XX +XXX,XX @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, uint64_t bytes, |
18 | for (i = 0; i < ARRAY_SIZE(alignments); i++) { | 19 | */ |
19 | align = alignments[i]; | 20 | static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, |
20 | if (raw_is_io_aligned(fd, buf + align, max_align)) { | 21 | BdrvTrackedRequest *req, int64_t offset, unsigned int bytes, |
21 | - /* Fallback to request_aligment. */ | 22 | - int64_t align, QEMUIOVector *qiov, int flags) |
22 | + /* Fallback to request_alignment. */ | 23 | + int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags) |
23 | s->buf_align = (align != 1) ? align : bs->bl.request_alignment; | 24 | { |
25 | BlockDriverState *bs = child->bs; | ||
26 | BlockDriver *drv = bs->drv; | ||
27 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, | ||
28 | assert(is_power_of_2(align)); | ||
29 | assert((offset & (align - 1)) == 0); | ||
30 | assert((bytes & (align - 1)) == 0); | ||
31 | - assert(!qiov || bytes == qiov->size); | ||
32 | + assert(!qiov || qiov_offset + bytes <= qiov->size); | ||
33 | max_transfer = QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_transfer, INT_MAX), | ||
34 | align); | ||
35 | |||
36 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, | ||
37 | |||
38 | if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF && | ||
39 | !(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_pwrite_zeroes && | ||
40 | - qemu_iovec_is_zero(qiov, 0, qiov->size)) { | ||
41 | + qemu_iovec_is_zero(qiov, qiov_offset, bytes)) { | ||
42 | flags |= BDRV_REQ_ZERO_WRITE; | ||
43 | if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) { | ||
44 | flags |= BDRV_REQ_MAY_UNMAP; | ||
45 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, | ||
46 | bdrv_debug_event(bs, BLKDBG_PWRITEV_ZERO); | ||
47 | ret = bdrv_co_do_pwrite_zeroes(bs, offset, bytes, flags); | ||
48 | } else if (flags & BDRV_REQ_WRITE_COMPRESSED) { | ||
49 | - ret = bdrv_driver_pwritev_compressed(bs, offset, bytes, qiov, 0); | ||
50 | + ret = bdrv_driver_pwritev_compressed(bs, offset, bytes, | ||
51 | + qiov, qiov_offset); | ||
52 | } else if (bytes <= max_transfer) { | ||
53 | bdrv_debug_event(bs, BLKDBG_PWRITEV); | ||
54 | - ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, 0, flags); | ||
55 | + ret = bdrv_driver_pwritev(bs, offset, bytes, qiov, qiov_offset, flags); | ||
56 | } else { | ||
57 | bdrv_debug_event(bs, BLKDBG_PWRITEV); | ||
58 | while (bytes_remaining) { | ||
59 | int num = MIN(bytes_remaining, max_transfer); | ||
60 | - QEMUIOVector local_qiov; | ||
61 | int local_flags = flags; | ||
62 | |||
63 | assert(num); | ||
64 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child, | ||
65 | * need to flush on the last iteration */ | ||
66 | local_flags &= ~BDRV_REQ_FUA; | ||
67 | } | ||
68 | - qemu_iovec_init(&local_qiov, qiov->niov); | ||
69 | - qemu_iovec_concat(&local_qiov, qiov, bytes - bytes_remaining, num); | ||
70 | |||
71 | ret = bdrv_driver_pwritev(bs, offset + bytes - bytes_remaining, | ||
72 | - num, &local_qiov, 0, local_flags); | ||
73 | - qemu_iovec_destroy(&local_qiov); | ||
74 | + num, qiov, bytes - bytes_remaining, | ||
75 | + local_flags); | ||
76 | if (ret < 0) { | ||
24 | break; | 77 | break; |
25 | } | 78 | } |
79 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, | ||
80 | |||
81 | qemu_iovec_init_buf(&local_qiov, pad.buf, write_bytes); | ||
82 | ret = bdrv_aligned_pwritev(child, req, aligned_offset, write_bytes, | ||
83 | - align, &local_qiov, | ||
84 | + align, &local_qiov, 0, | ||
85 | flags & ~BDRV_REQ_ZERO_WRITE); | ||
86 | if (ret < 0 || pad.merge_reads) { | ||
87 | /* Error or all work is done */ | ||
88 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, | ||
89 | /* Write the aligned part in the middle. */ | ||
90 | uint64_t aligned_bytes = bytes & ~(align - 1); | ||
91 | ret = bdrv_aligned_pwritev(child, req, offset, aligned_bytes, align, | ||
92 | - NULL, flags); | ||
93 | + NULL, 0, flags); | ||
94 | if (ret < 0) { | ||
95 | goto out; | ||
96 | } | ||
97 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, | ||
98 | |||
99 | qemu_iovec_init_buf(&local_qiov, pad.tail_buf, align); | ||
100 | ret = bdrv_aligned_pwritev(child, req, offset, align, align, | ||
101 | - &local_qiov, flags & ~BDRV_REQ_ZERO_WRITE); | ||
102 | + &local_qiov, 0, | ||
103 | + flags & ~BDRV_REQ_ZERO_WRITE); | ||
104 | } | ||
105 | |||
106 | out: | ||
107 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, | ||
108 | } | ||
109 | |||
110 | ret = bdrv_aligned_pwritev(child, &req, offset, bytes, align, | ||
111 | - qiov, flags); | ||
112 | + qiov, 0, flags); | ||
113 | |||
114 | bdrv_padding_destroy(&pad); | ||
115 | |||
26 | -- | 116 | -- |
27 | 2.21.0 | 117 | 2.21.0 |
28 | 118 | ||
29 | 119 | diff view generated by jsdifflib |
1 | From: Nir Soffer <nirsof@gmail.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Using block_resize we can test allocate_first_block() with file | 3 | Introduce extended variants of bdrv_co_preadv and bdrv_co_pwritev |
4 | descriptor opened with O_DIRECT, ensuring that it works for any size | 4 | with qiov_offset parameter. |
5 | larger than 4096 bytes. | ||
6 | 5 | ||
7 | Testing smaller sizes is tricky as the result depends on the filesystem | 6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
8 | used for testing. For example on NFS any size will work since O_DIRECT | 7 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
9 | does not require any alignment. | 8 | Message-id: 20190604161514.262241-10-vsementsov@virtuozzo.com |
9 | Message-Id: <20190604161514.262241-10-vsementsov@virtuozzo.com> | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | --- | ||
12 | include/block/block_int.h | 6 ++++++ | ||
13 | block/io.c | 29 +++++++++++++++++++++++------ | ||
14 | 2 files changed, 29 insertions(+), 6 deletions(-) | ||
10 | 15 | ||
11 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | 16 | diff --git a/include/block/block_int.h b/include/block/block_int.h |
12 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | Message-id: 20190827010528.8818-3-nsoffer@redhat.com | 18 | --- a/include/block/block_int.h |
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 19 | +++ b/include/block/block_int.h |
15 | --- | 20 | @@ -XXX,XX +XXX,XX @@ extern BlockDriver bdrv_qcow2; |
16 | tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++ | 21 | int coroutine_fn bdrv_co_preadv(BdrvChild *child, |
17 | tests/qemu-iotests/175.out | 8 ++++++++ | 22 | int64_t offset, unsigned int bytes, QEMUIOVector *qiov, |
18 | 2 files changed, 36 insertions(+) | 23 | BdrvRequestFlags flags); |
19 | 24 | +int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, | |
20 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 | 25 | + int64_t offset, unsigned int bytes, |
21 | index XXXXXXX..XXXXXXX 100755 | 26 | + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); |
22 | --- a/tests/qemu-iotests/175 | 27 | int coroutine_fn bdrv_co_pwritev(BdrvChild *child, |
23 | +++ b/tests/qemu-iotests/175 | 28 | int64_t offset, unsigned int bytes, QEMUIOVector *qiov, |
24 | @@ -XXX,XX +XXX,XX @@ _filter_blocks() | 29 | BdrvRequestFlags flags); |
25 | -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/" | 30 | +int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, |
31 | + int64_t offset, unsigned int bytes, | ||
32 | + QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags); | ||
33 | |||
34 | static inline int coroutine_fn bdrv_co_pread(BdrvChild *child, | ||
35 | int64_t offset, unsigned int bytes, void *buf, BdrvRequestFlags flags) | ||
36 | diff --git a/block/io.c b/block/io.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/block/io.c | ||
39 | +++ b/block/io.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void bdrv_padding_destroy(BdrvRequestPadding *pad) | ||
41 | * | ||
42 | * Function always succeeds. | ||
43 | */ | ||
44 | -static bool bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, | ||
45 | +static bool bdrv_pad_request(BlockDriverState *bs, | ||
46 | + QEMUIOVector **qiov, size_t *qiov_offset, | ||
47 | int64_t *offset, unsigned int *bytes, | ||
48 | BdrvRequestPadding *pad) | ||
49 | { | ||
50 | @@ -XXX,XX +XXX,XX @@ static bool bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, | ||
51 | } | ||
52 | |||
53 | qemu_iovec_init_extended(&pad->local_qiov, pad->buf, pad->head, | ||
54 | - *qiov, 0, *bytes, | ||
55 | + *qiov, *qiov_offset, *bytes, | ||
56 | pad->buf + pad->buf_len - pad->tail, pad->tail); | ||
57 | *bytes += pad->head + pad->tail; | ||
58 | *offset -= pad->head; | ||
59 | *qiov = &pad->local_qiov; | ||
60 | + *qiov_offset = 0; | ||
61 | |||
62 | return true; | ||
26 | } | 63 | } |
27 | 64 | @@ -XXX,XX +XXX,XX @@ static bool bdrv_pad_request(BlockDriverState *bs, QEMUIOVector **qiov, | |
28 | +# Resize image using block_resize. | 65 | int coroutine_fn bdrv_co_preadv(BdrvChild *child, |
29 | +# Parameter 1: image path | 66 | int64_t offset, unsigned int bytes, QEMUIOVector *qiov, |
30 | +# Parameter 2: new size | 67 | BdrvRequestFlags flags) |
31 | +_block_resize() | ||
32 | +{ | 68 | +{ |
33 | + local path=$1 | 69 | + return bdrv_co_preadv_part(child, offset, bytes, qiov, 0, flags); |
34 | + local size=$2 | ||
35 | + | ||
36 | + $QEMU -qmp stdio -nographic -nodefaults \ | ||
37 | + -blockdev file,node-name=file,filename=$path,cache.direct=on \ | ||
38 | + <<EOF | ||
39 | +{'execute': 'qmp_capabilities'} | ||
40 | +{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}} | ||
41 | +{'execute': 'quit'} | ||
42 | +EOF | ||
43 | +} | 70 | +} |
44 | + | 71 | + |
45 | # get standard environment, filters and checks | 72 | +int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, |
46 | . ./common.rc | 73 | + int64_t offset, unsigned int bytes, |
47 | . ./common.filter | 74 | + QEMUIOVector *qiov, size_t qiov_offset, |
48 | @@ -XXX,XX +XXX,XX @@ _supported_fmt raw | 75 | + BdrvRequestFlags flags) |
49 | _supported_proto file | 76 | { |
50 | _supported_os Linux | 77 | BlockDriverState *bs = child->bs; |
51 | 78 | BdrvTrackedRequest req; | |
52 | +_default_cache_mode none | 79 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child, |
53 | +_supported_cache_modes none directsync | 80 | flags |= BDRV_REQ_COPY_ON_READ; |
81 | } | ||
82 | |||
83 | - bdrv_pad_request(bs, &qiov, &offset, &bytes, &pad); | ||
84 | + bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad); | ||
85 | |||
86 | tracked_request_begin(&req, bs, offset, bytes, BDRV_TRACKED_READ); | ||
87 | ret = bdrv_aligned_preadv(child, &req, offset, bytes, | ||
88 | bs->bl.request_alignment, | ||
89 | - qiov, 0, flags); | ||
90 | + qiov, qiov_offset, flags); | ||
91 | tracked_request_end(&req); | ||
92 | bdrv_dec_in_flight(bs); | ||
93 | |||
94 | @@ -XXX,XX +XXX,XX @@ out: | ||
95 | int coroutine_fn bdrv_co_pwritev(BdrvChild *child, | ||
96 | int64_t offset, unsigned int bytes, QEMUIOVector *qiov, | ||
97 | BdrvRequestFlags flags) | ||
98 | +{ | ||
99 | + return bdrv_co_pwritev_part(child, offset, bytes, qiov, 0, flags); | ||
100 | +} | ||
54 | + | 101 | + |
55 | size=$((1 * 1024 * 1024)) | 102 | +int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, |
56 | 103 | + int64_t offset, unsigned int bytes, QEMUIOVector *qiov, size_t qiov_offset, | |
57 | touch "$TEST_DIR/empty" | 104 | + BdrvRequestFlags flags) |
58 | @@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do | 105 | { |
59 | stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | 106 | BlockDriverState *bs = child->bs; |
60 | done | 107 | BdrvTrackedRequest req; |
61 | 108 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child, | |
62 | +for new_size in 4096 1048576; do | 109 | goto out; |
63 | + echo | 110 | } |
64 | + echo "== resize empty image with block_resize ==" | 111 | |
65 | + _make_test_img 0 | _filter_imgfmt | 112 | - if (bdrv_pad_request(bs, &qiov, &offset, &bytes, &pad)) { |
66 | + _block_resize $TEST_IMG $new_size >/dev/null | 113 | + if (bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad)) { |
67 | + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size | 114 | mark_request_serialising(&req, align); |
68 | +done | 115 | wait_serialising_requests(&req); |
69 | + | 116 | bdrv_padding_rmw_read(child, &req, &pad, false); |
70 | # success, all done | 117 | } |
71 | echo "*** done" | 118 | |
72 | rm -f $seq.full | 119 | ret = bdrv_aligned_pwritev(child, &req, offset, bytes, align, |
73 | diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out | 120 | - qiov, 0, flags); |
74 | index XXXXXXX..XXXXXXX 100644 | 121 | + qiov, qiov_offset, flags); |
75 | --- a/tests/qemu-iotests/175.out | 122 | |
76 | +++ b/tests/qemu-iotests/175.out | 123 | bdrv_padding_destroy(&pad); |
77 | @@ -XXX,XX +XXX,XX @@ size=1048576, max allocation | 124 | |
78 | == creating image with preallocation falloc == | ||
79 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc | ||
80 | size=1048576, max allocation | ||
81 | + | ||
82 | +== resize empty image with block_resize == | ||
83 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0 | ||
84 | +size=4096, min allocation | ||
85 | + | ||
86 | +== resize empty image with block_resize == | ||
87 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0 | ||
88 | +size=1048576, min allocation | ||
89 | *** done | ||
90 | -- | 125 | -- |
91 | 2.21.0 | 126 | 2.21.0 |
92 | 127 | ||
93 | 128 | diff view generated by jsdifflib |
1 | The error message for the test case where we have a quorum node for | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | which no directory name can be generated is different: For | ||
3 | twoGbMaxExtentSparse, it complains that it cannot open the extent file. | ||
4 | For other (sub)formats, it just notes that it cannot determine the | ||
5 | backing file path. Both are fine, but just disable twoGbMaxExtentSparse | ||
6 | for simplicity's sake. | ||
7 | 2 | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 3 | Use buffer based io in encrypted case. |
9 | Reviewed-by: John Snow <jsnow@redhat.com> | 4 | |
10 | Message-id: 20190815153638.4600-7-mreitz@redhat.com | 5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
11 | Reviewed-by: John Snow <jsnow@redhat.com> | 6 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Message-id: 20190604161514.262241-11-vsementsov@virtuozzo.com |
8 | Message-Id: <20190604161514.262241-11-vsementsov@virtuozzo.com> | ||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | --- | 10 | --- |
14 | tests/qemu-iotests/110 | 3 ++- | 11 | block/qcow2.c | 28 ++++++++++++++++------------ |
15 | 1 file changed, 2 insertions(+), 1 deletion(-) | 12 | 1 file changed, 16 insertions(+), 12 deletions(-) |
16 | 13 | ||
17 | diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 | 14 | diff --git a/block/qcow2.c b/block/qcow2.c |
18 | index XXXXXXX..XXXXXXX 100755 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/qemu-iotests/110 | 16 | --- a/block/qcow2.c |
20 | +++ b/tests/qemu-iotests/110 | 17 | +++ b/block/qcow2.c |
21 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 18 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, |
22 | # Any format supporting backing files | 19 | } |
23 | _supported_fmt qed qcow qcow2 vmdk | 20 | |
24 | _supported_proto file | 21 | assert(cur_bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); |
25 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | 22 | - qemu_iovec_reset(&hd_qiov); |
26 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | 23 | - qemu_iovec_add(&hd_qiov, cluster_data, cur_bytes); |
27 | + "subformat=twoGbMaxExtentSparse" | 24 | - } |
28 | 25 | ||
29 | TEST_IMG_REL=$(basename "$TEST_IMG") | 26 | - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); |
27 | - ret = bdrv_co_preadv(s->data_file, | ||
28 | - cluster_offset + offset_in_cluster, | ||
29 | - cur_bytes, &hd_qiov, 0); | ||
30 | - if (ret < 0) { | ||
31 | - goto fail; | ||
32 | - } | ||
33 | - if (bs->encrypted) { | ||
34 | - assert(s->crypto); | ||
35 | + BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); | ||
36 | + ret = bdrv_co_pread(s->data_file, | ||
37 | + cluster_offset + offset_in_cluster, | ||
38 | + cur_bytes, cluster_data, 0); | ||
39 | + if (ret < 0) { | ||
40 | + goto fail; | ||
41 | + } | ||
42 | + | ||
43 | assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); | ||
44 | assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) == 0); | ||
45 | if (qcow2_co_decrypt(bs, cluster_offset, offset, | ||
46 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, | ||
47 | goto fail; | ||
48 | } | ||
49 | qemu_iovec_from_buf(qiov, bytes_done, cluster_data, cur_bytes); | ||
50 | + } else { | ||
51 | + BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); | ||
52 | + ret = bdrv_co_preadv(s->data_file, | ||
53 | + cluster_offset + offset_in_cluster, | ||
54 | + cur_bytes, &hd_qiov, 0); | ||
55 | + if (ret < 0) { | ||
56 | + goto fail; | ||
57 | + } | ||
58 | } | ||
59 | break; | ||
30 | 60 | ||
31 | -- | 61 | -- |
32 | 2.21.0 | 62 | 2.21.0 |
33 | 63 | ||
34 | 64 | diff view generated by jsdifflib |
1 | From: Nir Soffer <nirsof@gmail.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | When creating an image with preallocation "off" or "falloc", the first | 3 | Implement and use new interface to get rid of hd_qiov. |
4 | block of the image is typically not allocated. When using Gluster | ||
5 | storage backed by XFS filesystem, reading this block using direct I/O | ||
6 | succeeds regardless of request length, fooling alignment detection. | ||
7 | 4 | ||
8 | In this case we fallback to a safe value (4096) instead of the optimal | 5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
9 | value (512), which may lead to unneeded data copying when aligning | 6 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
10 | requests. Allocating the first block avoids the fallback. | 7 | Message-id: 20190604161514.262241-12-vsementsov@virtuozzo.com |
8 | Message-Id: <20190604161514.262241-12-vsementsov@virtuozzo.com> | ||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | --- | ||
11 | block/qcow2-cluster.c | 5 +++-- | ||
12 | block/qcow2.c | 49 +++++++++++++++++++------------------------ | ||
13 | 2 files changed, 25 insertions(+), 29 deletions(-) | ||
11 | 14 | ||
12 | Since we allocate the first block even with preallocation=off, we no | 15 | diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c |
13 | longer create images with zero disk size: | ||
14 | |||
15 | $ ./qemu-img create -f raw test.raw 1g | ||
16 | Formatting 'test.raw', fmt=raw size=1073741824 | ||
17 | |||
18 | $ ls -lhs test.raw | ||
19 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw | ||
20 | |||
21 | And converting the image requires additional cluster: | ||
22 | |||
23 | $ ./qemu-img measure -f raw -O qcow2 test.raw | ||
24 | required size: 458752 | ||
25 | fully allocated size: 1074135040 | ||
26 | |||
27 | When using format like vmdk with multiple files per image, we allocate | ||
28 | one block per file: | ||
29 | |||
30 | $ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g | ||
31 | Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat | ||
32 | |||
33 | $ ls -lhs test*.vmdk | ||
34 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk | ||
35 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk | ||
36 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk | ||
37 | |||
38 | I did quick performance test for copying disks with qemu-img convert to | ||
39 | new raw target image to Gluster storage with sector size of 512 bytes: | ||
40 | |||
41 | for i in $(seq 10); do | ||
42 | rm -f dst.raw | ||
43 | sleep 10 | ||
44 | time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw | ||
45 | done | ||
46 | |||
47 | Here is a table comparing the total time spent: | ||
48 | |||
49 | Type Before(s) After(s) Diff(%) | ||
50 | --------------------------------------- | ||
51 | real 530.028 469.123 -11.4 | ||
52 | user 17.204 10.768 -37.4 | ||
53 | sys 17.881 7.011 -60.7 | ||
54 | |||
55 | We can see very clear improvement in CPU usage. | ||
56 | |||
57 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | ||
58 | Message-id: 20190827010528.8818-2-nsoffer@redhat.com | ||
59 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
60 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
61 | --- | ||
62 | block/file-posix.c | 51 +++++++++++++++++++ | ||
63 | tests/qemu-iotests/059.out | 2 +- | ||
64 | tests/qemu-iotests/{150.out => 150.out.qcow2} | 0 | ||
65 | tests/qemu-iotests/150.out.raw | 12 +++++ | ||
66 | tests/qemu-iotests/175 | 19 ++++--- | ||
67 | tests/qemu-iotests/175.out | 8 +-- | ||
68 | tests/qemu-iotests/178.out.qcow2 | 4 +- | ||
69 | tests/qemu-iotests/221.out | 12 +++-- | ||
70 | tests/qemu-iotests/253.out | 12 +++-- | ||
71 | 9 files changed, 99 insertions(+), 21 deletions(-) | ||
72 | rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%) | ||
73 | create mode 100644 tests/qemu-iotests/150.out.raw | ||
74 | |||
75 | diff --git a/block/file-posix.c b/block/file-posix.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
77 | --- a/block/file-posix.c | 17 | --- a/block/qcow2-cluster.c |
78 | +++ b/block/file-posix.c | 18 | +++ b/block/qcow2-cluster.c |
79 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque) | 19 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn do_perform_cow_read(BlockDriverState *bs, |
20 | * interface. This avoids double I/O throttling and request tracking, | ||
21 | * which can lead to deadlock when block layer copy-on-read is enabled. | ||
22 | */ | ||
23 | - ret = bs->drv->bdrv_co_preadv(bs, src_cluster_offset + offset_in_cluster, | ||
24 | - qiov->size, qiov, 0); | ||
25 | + ret = bs->drv->bdrv_co_preadv_part(bs, | ||
26 | + src_cluster_offset + offset_in_cluster, | ||
27 | + qiov->size, qiov, 0, 0); | ||
28 | if (ret < 0) { | ||
29 | return ret; | ||
30 | } | ||
31 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/block/qcow2.c | ||
34 | +++ b/block/qcow2.c | ||
35 | @@ -XXX,XX +XXX,XX @@ qcow2_co_preadv_compressed(BlockDriverState *bs, | ||
36 | uint64_t file_cluster_offset, | ||
37 | uint64_t offset, | ||
38 | uint64_t bytes, | ||
39 | - QEMUIOVector *qiov); | ||
40 | + QEMUIOVector *qiov, | ||
41 | + size_t qiov_offset); | ||
42 | |||
43 | static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename) | ||
44 | { | ||
45 | @@ -XXX,XX +XXX,XX @@ out: | ||
80 | return ret; | 46 | return ret; |
81 | } | 47 | } |
82 | 48 | ||
83 | +/* | 49 | -static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, |
84 | + * Help alignment probing by allocating the first block. | 50 | - uint64_t bytes, QEMUIOVector *qiov, |
85 | + * | 51 | - int flags) |
86 | + * When reading with direct I/O from unallocated area on Gluster backed by XFS, | 52 | +static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, |
87 | + * reading succeeds regardless of request length. In this case we fallback to | 53 | + uint64_t offset, uint64_t bytes, |
88 | + * safe alignment which is not optimal. Allocating the first block avoids this | 54 | + QEMUIOVector *qiov, |
89 | + * fallback. | 55 | + size_t qiov_offset, int flags) |
90 | + * | ||
91 | + * fd may be opened with O_DIRECT, but we don't know the buffer alignment or | ||
92 | + * request alignment, so we use safe values. | ||
93 | + * | ||
94 | + * Returns: 0 on success, -errno on failure. Since this is an optimization, | ||
95 | + * caller may ignore failures. | ||
96 | + */ | ||
97 | +static int allocate_first_block(int fd, size_t max_size) | ||
98 | +{ | ||
99 | + size_t write_size = (max_size < MAX_BLOCKSIZE) | ||
100 | + ? BDRV_SECTOR_SIZE | ||
101 | + : MAX_BLOCKSIZE; | ||
102 | + size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); | ||
103 | + void *buf; | ||
104 | + ssize_t n; | ||
105 | + int ret; | ||
106 | + | ||
107 | + buf = qemu_memalign(max_align, write_size); | ||
108 | + memset(buf, 0, write_size); | ||
109 | + | ||
110 | + do { | ||
111 | + n = pwrite(fd, buf, write_size, 0); | ||
112 | + } while (n == -1 && errno == EINTR); | ||
113 | + | ||
114 | + ret = (n == -1) ? -errno : 0; | ||
115 | + | ||
116 | + qemu_vfree(buf); | ||
117 | + return ret; | ||
118 | +} | ||
119 | + | ||
120 | static int handle_aiocb_truncate(void *opaque) | ||
121 | { | 56 | { |
122 | RawPosixAIOData *aiocb = opaque; | 57 | BDRVQcow2State *s = bs->opaque; |
123 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque) | 58 | int offset_in_cluster; |
124 | /* posix_fallocate() doesn't set errno. */ | 59 | int ret; |
125 | error_setg_errno(errp, -result, | 60 | unsigned int cur_bytes; /* number of bytes in current iteration */ |
126 | "Could not preallocate new data"); | 61 | uint64_t cluster_offset = 0; |
127 | + } else if (current_length == 0) { | 62 | - uint64_t bytes_done = 0; |
128 | + /* | 63 | - QEMUIOVector hd_qiov; |
129 | + * posix_fallocate() uses fallocate() if the filesystem | 64 | uint8_t *cluster_data = NULL; |
130 | + * supports it, or fallback to manually writing zeroes. If | 65 | |
131 | + * fallocate() was used, unaligned reads from the fallocated | 66 | - qemu_iovec_init(&hd_qiov, qiov->niov); |
132 | + * area in raw_probe_alignment() will succeed, hence we need to | 67 | - |
133 | + * allocate the first block. | 68 | while (bytes != 0) { |
134 | + * | 69 | |
135 | + * Optimize future alignment probing; ignore failures. | 70 | /* prepare next request */ |
136 | + */ | 71 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, |
137 | + allocate_first_block(fd, offset); | 72 | |
73 | offset_in_cluster = offset_into_cluster(s, offset); | ||
74 | |||
75 | - qemu_iovec_reset(&hd_qiov); | ||
76 | - qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_bytes); | ||
77 | - | ||
78 | switch (ret) { | ||
79 | case QCOW2_CLUSTER_UNALLOCATED: | ||
80 | |||
81 | if (bs->backing) { | ||
82 | BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); | ||
83 | - ret = bdrv_co_preadv(bs->backing, offset, cur_bytes, | ||
84 | - &hd_qiov, 0); | ||
85 | + ret = bdrv_co_preadv_part(bs->backing, offset, cur_bytes, | ||
86 | + qiov, qiov_offset, 0); | ||
87 | if (ret < 0) { | ||
88 | goto fail; | ||
89 | } | ||
90 | } else { | ||
91 | /* Note: in this case, no need to wait */ | ||
92 | - qemu_iovec_memset(&hd_qiov, 0, 0, cur_bytes); | ||
93 | + qemu_iovec_memset(qiov, qiov_offset, 0, cur_bytes); | ||
138 | } | 94 | } |
139 | } else { | 95 | break; |
140 | result = 0; | 96 | |
141 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque) | 97 | case QCOW2_CLUSTER_ZERO_PLAIN: |
142 | if (ftruncate(fd, offset) != 0) { | 98 | case QCOW2_CLUSTER_ZERO_ALLOC: |
143 | result = -errno; | 99 | - qemu_iovec_memset(&hd_qiov, 0, 0, cur_bytes); |
144 | error_setg_errno(errp, -result, "Could not resize file"); | 100 | + qemu_iovec_memset(qiov, qiov_offset, 0, cur_bytes); |
145 | + } else if (current_length == 0 && offset > current_length) { | 101 | break; |
146 | + /* Optimize future alignment probing; ignore failures. */ | 102 | |
147 | + allocate_first_block(fd, offset); | 103 | case QCOW2_CLUSTER_COMPRESSED: |
148 | } | 104 | ret = qcow2_co_preadv_compressed(bs, cluster_offset, |
149 | return result; | 105 | offset, cur_bytes, |
150 | default: | 106 | - &hd_qiov); |
151 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | 107 | + qiov, qiov_offset); |
152 | index XXXXXXX..XXXXXXX 100644 | 108 | if (ret < 0) { |
153 | --- a/tests/qemu-iotests/059.out | 109 | goto fail; |
154 | +++ b/tests/qemu-iotests/059.out | 110 | } |
155 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax | 111 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, |
156 | image: TEST_DIR/t.vmdk | 112 | ret = -EIO; |
157 | file format: vmdk | 113 | goto fail; |
158 | virtual size: 0.977 TiB (1073741824000 bytes) | 114 | } |
159 | -disk size: 16 KiB | 115 | - qemu_iovec_from_buf(qiov, bytes_done, cluster_data, cur_bytes); |
160 | +disk size: 1.97 MiB | 116 | + qemu_iovec_from_buf(qiov, qiov_offset, cluster_data, cur_bytes); |
161 | Format specific information: | 117 | } else { |
162 | cid: XXXXXXXX | 118 | BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); |
163 | parent cid: XXXXXXXX | 119 | - ret = bdrv_co_preadv(s->data_file, |
164 | diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2 | 120 | - cluster_offset + offset_in_cluster, |
165 | similarity index 100% | 121 | - cur_bytes, &hd_qiov, 0); |
166 | rename from tests/qemu-iotests/150.out | 122 | + ret = bdrv_co_preadv_part(s->data_file, |
167 | rename to tests/qemu-iotests/150.out.qcow2 | 123 | + cluster_offset + offset_in_cluster, |
168 | diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw | 124 | + cur_bytes, qiov, qiov_offset, 0); |
169 | new file mode 100644 | 125 | if (ret < 0) { |
170 | index XXXXXXX..XXXXXXX | 126 | goto fail; |
171 | --- /dev/null | 127 | } |
172 | +++ b/tests/qemu-iotests/150.out.raw | 128 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, |
173 | @@ -XXX,XX +XXX,XX @@ | 129 | |
174 | +QA output created by 150 | 130 | bytes -= cur_bytes; |
175 | + | 131 | offset += cur_bytes; |
176 | +=== Mapping sparse conversion === | 132 | - bytes_done += cur_bytes; |
177 | + | 133 | + qiov_offset += cur_bytes; |
178 | +Offset Length File | 134 | } |
179 | +0 0x1000 TEST_DIR/t.IMGFMT | 135 | ret = 0; |
180 | + | 136 | |
181 | +=== Mapping non-sparse conversion === | 137 | fail: |
182 | + | 138 | - qemu_iovec_destroy(&hd_qiov); |
183 | +Offset Length File | 139 | qemu_vfree(cluster_data); |
184 | +0 0x100000 TEST_DIR/t.IMGFMT | 140 | |
185 | +*** done | 141 | return ret; |
186 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 | 142 | @@ -XXX,XX +XXX,XX @@ qcow2_co_preadv_compressed(BlockDriverState *bs, |
187 | index XXXXXXX..XXXXXXX 100755 | 143 | uint64_t file_cluster_offset, |
188 | --- a/tests/qemu-iotests/175 | 144 | uint64_t offset, |
189 | +++ b/tests/qemu-iotests/175 | 145 | uint64_t bytes, |
190 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 146 | - QEMUIOVector *qiov) |
191 | # the file size. This function hides the resulting difference in the | 147 | + QEMUIOVector *qiov, |
192 | # stat -c '%b' output. | 148 | + size_t qiov_offset) |
193 | # Parameter 1: Number of blocks an empty file occupies | ||
194 | -# Parameter 2: Image size in bytes | ||
195 | +# Parameter 2: Minimal number of blocks in an image | ||
196 | +# Parameter 3: Image size in bytes | ||
197 | _filter_blocks() | ||
198 | { | 149 | { |
199 | extra_blocks=$1 | 150 | BDRVQcow2State *s = bs->opaque; |
200 | - img_size=$2 | 151 | int ret = 0, csize, nb_csectors; |
201 | + min_blocks=$2 | 152 | @@ -XXX,XX +XXX,XX @@ qcow2_co_preadv_compressed(BlockDriverState *bs, |
202 | + img_size=$3 | 153 | goto fail; |
203 | 154 | } | |
204 | - sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \ | 155 | |
205 | - -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/" | 156 | - qemu_iovec_from_buf(qiov, 0, out_buf + offset_in_cluster, bytes); |
206 | + sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \ | 157 | + qemu_iovec_from_buf(qiov, qiov_offset, out_buf + offset_in_cluster, bytes); |
207 | + -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/" | 158 | |
159 | fail: | ||
160 | qemu_vfree(out_buf); | ||
161 | @@ -XXX,XX +XXX,XX @@ static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, | ||
162 | BDRVQcow2State *s = bs->opaque; | ||
163 | |||
164 | BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); | ||
165 | - return bs->drv->bdrv_co_preadv(bs, qcow2_vm_state_offset(s) + pos, | ||
166 | - qiov->size, qiov, 0); | ||
167 | + return bs->drv->bdrv_co_preadv_part(bs, qcow2_vm_state_offset(s) + pos, | ||
168 | + qiov->size, qiov, 0, 0); | ||
208 | } | 169 | } |
209 | 170 | ||
210 | # get standard environment, filters and checks | 171 | /* |
211 | @@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024)) | 172 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_qcow2 = { |
212 | touch "$TEST_DIR/empty" | 173 | .bdrv_has_zero_init_truncate = bdrv_has_zero_init_1, |
213 | extra_blocks=$(stat -c '%b' "$TEST_DIR/empty") | 174 | .bdrv_co_block_status = qcow2_co_block_status, |
214 | 175 | ||
215 | +# We always write the first byte; check how many blocks this filesystem | 176 | - .bdrv_co_preadv = qcow2_co_preadv, |
216 | +# allocates to match empty image alloation. | 177 | + .bdrv_co_preadv_part = qcow2_co_preadv_part, |
217 | +printf "\0" > "$TEST_DIR/empty" | 178 | .bdrv_co_pwritev = qcow2_co_pwritev, |
218 | +min_blocks=$(stat -c '%b' "$TEST_DIR/empty") | 179 | .bdrv_co_flush_to_os = qcow2_co_flush_to_os, |
219 | + | 180 | |
220 | echo | ||
221 | echo "== creating image with default preallocation ==" | ||
222 | _make_test_img $size | _filter_imgfmt | ||
223 | -stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size | ||
224 | +stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | ||
225 | |||
226 | for mode in off full falloc; do | ||
227 | echo | ||
228 | echo "== creating image with preallocation $mode ==" | ||
229 | IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt | ||
230 | - stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size | ||
231 | + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | ||
232 | done | ||
233 | |||
234 | # success, all done | ||
235 | diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out | ||
236 | index XXXXXXX..XXXXXXX 100644 | ||
237 | --- a/tests/qemu-iotests/175.out | ||
238 | +++ b/tests/qemu-iotests/175.out | ||
239 | @@ -XXX,XX +XXX,XX @@ QA output created by 175 | ||
240 | |||
241 | == creating image with default preallocation == | ||
242 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | ||
243 | -size=1048576, nothing allocated | ||
244 | +size=1048576, min allocation | ||
245 | |||
246 | == creating image with preallocation off == | ||
247 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off | ||
248 | -size=1048576, nothing allocated | ||
249 | +size=1048576, min allocation | ||
250 | |||
251 | == creating image with preallocation full == | ||
252 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full | ||
253 | -size=1048576, everything allocated | ||
254 | +size=1048576, max allocation | ||
255 | |||
256 | == creating image with preallocation falloc == | ||
257 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc | ||
258 | -size=1048576, everything allocated | ||
259 | +size=1048576, max allocation | ||
260 | *** done | ||
261 | diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2 | ||
262 | index XXXXXXX..XXXXXXX 100644 | ||
263 | --- a/tests/qemu-iotests/178.out.qcow2 | ||
264 | +++ b/tests/qemu-iotests/178.out.qcow2 | ||
265 | @@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608 | ||
266 | == raw input image with data (human) == | ||
267 | |||
268 | Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824 | ||
269 | -required size: 393216 | ||
270 | +required size: 458752 | ||
271 | fully allocated size: 1074135040 | ||
272 | wrote 512/512 bytes at offset 512 | ||
273 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
274 | @@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608 | ||
275 | |||
276 | Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824 | ||
277 | { | ||
278 | - "required": 393216, | ||
279 | + "required": 458752, | ||
280 | "fully-allocated": 1074135040 | ||
281 | } | ||
282 | wrote 512/512 bytes at offset 512 | ||
283 | diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out | ||
284 | index XXXXXXX..XXXXXXX 100644 | ||
285 | --- a/tests/qemu-iotests/221.out | ||
286 | +++ b/tests/qemu-iotests/221.out | ||
287 | @@ -XXX,XX +XXX,XX @@ QA output created by 221 | ||
288 | === Check mapping of unaligned raw image === | ||
289 | |||
290 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537 | ||
291 | -[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
292 | -[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
293 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
294 | +{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
295 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
296 | +{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
297 | wrote 1/1 bytes at offset 65536 | ||
298 | 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
299 | -[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
300 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
301 | +{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
302 | { "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
303 | { "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
304 | -[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
305 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
306 | +{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
307 | { "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
308 | { "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
309 | *** done | ||
310 | diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out | ||
311 | index XXXXXXX..XXXXXXX 100644 | ||
312 | --- a/tests/qemu-iotests/253.out | ||
313 | +++ b/tests/qemu-iotests/253.out | ||
314 | @@ -XXX,XX +XXX,XX @@ QA output created by 253 | ||
315 | === Check mapping of unaligned raw image === | ||
316 | |||
317 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575 | ||
318 | -[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
319 | -[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
320 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
321 | +{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
322 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
323 | +{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] | ||
324 | wrote 65535/65535 bytes at offset 983040 | ||
325 | 63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
326 | -[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
327 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
328 | +{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
329 | { "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] | ||
330 | -[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
331 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, | ||
332 | +{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | ||
333 | { "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] | ||
334 | *** done | ||
335 | -- | 181 | -- |
336 | 2.21.0 | 182 | 2.21.0 |
337 | 183 | ||
338 | 184 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | fe646693acc changed qemu-img create's output so that it no longer prints | ||
2 | single quotes around parameter values. The subformat and adapter_type | ||
3 | filters in _filter_img_create() have never been adapted to that change. | ||
4 | 1 | ||
5 | Fixes: fe646693acc13ac48b98435d14149ab04dc597bc | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Message-id: 20190815153638.4600-2-mreitz@redhat.com | ||
9 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/059.out | 16 ++++++++-------- | ||
13 | tests/qemu-iotests/common.filter | 4 ++-- | ||
14 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qemu-iotests/059.out | ||
19 | +++ b/tests/qemu-iotests/059.out | ||
20 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
21 | qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big | ||
22 | |||
23 | === Testing monolithicFlat creation and opening === | ||
24 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat | ||
25 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 | ||
26 | image: TEST_DIR/t.IMGFMT | ||
27 | file format: IMGFMT | ||
28 | virtual size: 2 GiB (2147483648 bytes) | ||
29 | |||
30 | === Testing monolithicFlat with zeroed_grain === | ||
31 | qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain | ||
32 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat | ||
33 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 | ||
34 | |||
35 | === Testing big twoGbMaxExtentFlat === | ||
36 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat | ||
37 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 | ||
38 | image: TEST_DIR/t.vmdk | ||
39 | file format: vmdk | ||
40 | virtual size: 0.977 TiB (1073741824000 bytes) | ||
41 | @@ -XXX,XX +XXX,XX @@ Format specific information: | ||
42 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1 | ||
43 | |||
44 | === Testing truncated sparse === | ||
45 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse | ||
46 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 | ||
47 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes | ||
48 | |||
49 | === Converting to streamOptimized from image with small cluster size=== | ||
50 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | ||
51 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
52 | |||
53 | === Testing monolithicFlat with internally generated JSON file name === | ||
54 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat | ||
55 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
56 | qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' | ||
57 | |||
58 | === Testing version 3 === | ||
59 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328 | ||
60 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
61 | |||
62 | === Testing 4TB monolithicFlat creation and IO === | ||
63 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat | ||
64 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 | ||
65 | image: TEST_DIR/t.IMGFMT | ||
66 | file format: IMGFMT | ||
67 | virtual size: 4 TiB (4398046511104 bytes) | ||
68 | @@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600 | ||
69 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
70 | |||
71 | === Testing qemu-img map on extents === | ||
72 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse | ||
73 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 | ||
74 | wrote 1024/1024 bytes at offset 65024 | ||
75 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
76 | wrote 1024/1024 bytes at offset 2147483136 | ||
77 | @@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File | ||
78 | 0 0x20000 0x3f0000 TEST_DIR/t.vmdk | ||
79 | 0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk | ||
80 | 0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk | ||
81 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse | ||
82 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 | ||
83 | wrote 1024/1024 bytes at offset 65024 | ||
84 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
85 | wrote 1024/1024 bytes at offset 2147483136 | ||
86 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/tests/qemu-iotests/common.filter | ||
89 | +++ b/tests/qemu-iotests/common.filter | ||
90 | @@ -XXX,XX +XXX,XX @@ _filter_img_create() | ||
91 | -e "s# compat6=\\(on\\|off\\)##g" \ | ||
92 | -e "s# static=\\(on\\|off\\)##g" \ | ||
93 | -e "s# zeroed_grain=\\(on\\|off\\)##g" \ | ||
94 | - -e "s# subformat='[^']*'##g" \ | ||
95 | - -e "s# adapter_type='[^']*'##g" \ | ||
96 | + -e "s# subformat=[^ ]*##g" \ | ||
97 | + -e "s# adapter_type=[^ ]*##g" \ | ||
98 | -e "s# hwversion=[^ ]*##g" \ | ||
99 | -e "s# lazy_refcounts=\\(on\\|off\\)##g" \ | ||
100 | -e "s# block_size=[0-9]\\+##g" \ | ||
101 | -- | ||
102 | 2.21.0 | ||
103 | |||
104 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We had a test for a case where relative extent paths did not work, but | ||
2 | unfortunately we just fixed the underlying problem, so it works now. | ||
3 | This patch adds a new test case that still fails. | ||
4 | 1 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
7 | Message-id: 20190815153638.4600-4-mreitz@redhat.com | ||
8 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++ | ||
12 | tests/qemu-iotests/059.out | 4 ++++ | ||
13 | 2 files changed, 31 insertions(+) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/059 | ||
18 | +++ b/tests/qemu-iotests/059 | ||
19 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 | ||
20 | |||
21 | echo | ||
22 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" | ||
23 | + | ||
24 | +echo '--- blkdebug ---' | ||
25 | # Should work, because bdrv_dirname() works fine with blkdebug | ||
26 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
27 | $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | ||
28 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE | ||
29 | | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
30 | _cleanup_test_img | ||
31 | |||
32 | +echo '--- quorum ---' | ||
33 | +# Should not work, because bdrv_dirname() does not work with quorum | ||
34 | +IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
35 | +cp "$TEST_IMG" "$TEST_IMG.orig" | ||
36 | + | ||
37 | +filename="json:{ | ||
38 | + \"driver\": \"$IMGFMT\", | ||
39 | + \"file\": { | ||
40 | + \"driver\": \"quorum\", | ||
41 | + \"children\": [ { | ||
42 | + \"driver\": \"file\", | ||
43 | + \"filename\": \"$TEST_IMG\" | ||
44 | + }, { | ||
45 | + \"driver\": \"file\", | ||
46 | + \"filename\": \"$TEST_IMG.orig\" | ||
47 | + } ], | ||
48 | + \"vote-threshold\": 1 | ||
49 | + } }" | ||
50 | + | ||
51 | +filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g') | ||
52 | +$QEMU_IMG info "$filename" 2>&1 \ | ||
53 | + | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \ | ||
54 | + | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
55 | + | ||
56 | + | ||
57 | echo | ||
58 | echo "=== Testing version 3 ===" | ||
59 | _use_sample_img iotest-version3.vmdk.bz2 | ||
60 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/tests/qemu-iotests/059.out | ||
63 | +++ b/tests/qemu-iotests/059.out | ||
64 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | ||
65 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
66 | |||
67 | === Testing monolithicFlat with internally generated JSON file name === | ||
68 | +--- blkdebug --- | ||
69 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
70 | format name: IMGFMT | ||
71 | cluster size: 0 bytes | ||
72 | vm state offset: 0 bytes | ||
73 | +--- quorum --- | ||
74 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
75 | +qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes | ||
76 | |||
77 | === Testing version 3 === | ||
78 | image: TEST_DIR/iotest-version3.IMGFMT | ||
79 | -- | ||
80 | 2.21.0 | ||
81 | |||
82 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | streamOptimized does not support writes that do not span exactly one | ||
2 | cluster. Furthermore, it cannot rewrite already allocated clusters. | ||
3 | As such, many iotests do not work with it. Disable them. | ||
4 | 1 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Message-id: 20190815153638.4600-6-mreitz@redhat.com | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/002 | 1 + | ||
11 | tests/qemu-iotests/003 | 1 + | ||
12 | tests/qemu-iotests/005 | 3 ++- | ||
13 | tests/qemu-iotests/009 | 1 + | ||
14 | tests/qemu-iotests/010 | 1 + | ||
15 | tests/qemu-iotests/011 | 1 + | ||
16 | tests/qemu-iotests/017 | 3 ++- | ||
17 | tests/qemu-iotests/018 | 3 ++- | ||
18 | tests/qemu-iotests/019 | 3 ++- | ||
19 | tests/qemu-iotests/020 | 3 ++- | ||
20 | tests/qemu-iotests/027 | 1 + | ||
21 | tests/qemu-iotests/032 | 1 + | ||
22 | tests/qemu-iotests/033 | 1 + | ||
23 | tests/qemu-iotests/034 | 3 ++- | ||
24 | tests/qemu-iotests/037 | 3 ++- | ||
25 | tests/qemu-iotests/063 | 3 ++- | ||
26 | tests/qemu-iotests/072 | 1 + | ||
27 | tests/qemu-iotests/105 | 3 ++- | ||
28 | tests/qemu-iotests/197 | 1 + | ||
29 | tests/qemu-iotests/215 | 1 + | ||
30 | tests/qemu-iotests/251 | 1 + | ||
31 | 21 files changed, 30 insertions(+), 9 deletions(-) | ||
32 | |||
33 | diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002 | ||
34 | index XXXXXXX..XXXXXXX 100755 | ||
35 | --- a/tests/qemu-iotests/002 | ||
36 | +++ b/tests/qemu-iotests/002 | ||
37 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
38 | |||
39 | _supported_fmt generic | ||
40 | _supported_proto generic | ||
41 | +_unsupported_imgopts "subformat=streamOptimized" | ||
42 | |||
43 | |||
44 | size=128M | ||
45 | diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003 | ||
46 | index XXXXXXX..XXXXXXX 100755 | ||
47 | --- a/tests/qemu-iotests/003 | ||
48 | +++ b/tests/qemu-iotests/003 | ||
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
50 | |||
51 | _supported_fmt generic | ||
52 | _supported_proto generic | ||
53 | +_unsupported_imgopts "subformat=streamOptimized" | ||
54 | |||
55 | size=128M | ||
56 | offset=67M | ||
57 | diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 | ||
58 | index XXXXXXX..XXXXXXX 100755 | ||
59 | --- a/tests/qemu-iotests/005 | ||
60 | +++ b/tests/qemu-iotests/005 | ||
61 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
62 | _supported_proto generic | ||
63 | _supported_os Linux | ||
64 | _unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ | ||
65 | - "subformat=twoGbMaxExtentSparse" | ||
66 | + "subformat=twoGbMaxExtentSparse" \ | ||
67 | + "subformat=streamOptimized" | ||
68 | |||
69 | # vpc is limited to 127GB, so we can't test it here | ||
70 | if [ "$IMGFMT" = "vpc" ]; then | ||
71 | diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009 | ||
72 | index XXXXXXX..XXXXXXX 100755 | ||
73 | --- a/tests/qemu-iotests/009 | ||
74 | +++ b/tests/qemu-iotests/009 | ||
75 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
76 | |||
77 | _supported_fmt generic | ||
78 | _supported_proto generic | ||
79 | +_unsupported_imgopts "subformat=streamOptimized" | ||
80 | |||
81 | |||
82 | size=6G | ||
83 | diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010 | ||
84 | index XXXXXXX..XXXXXXX 100755 | ||
85 | --- a/tests/qemu-iotests/010 | ||
86 | +++ b/tests/qemu-iotests/010 | ||
87 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
88 | |||
89 | _supported_fmt generic | ||
90 | _supported_proto generic | ||
91 | +_unsupported_imgopts "subformat=streamOptimized" | ||
92 | |||
93 | |||
94 | size=6G | ||
95 | diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011 | ||
96 | index XXXXXXX..XXXXXXX 100755 | ||
97 | --- a/tests/qemu-iotests/011 | ||
98 | +++ b/tests/qemu-iotests/011 | ||
99 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
100 | |||
101 | _supported_fmt generic | ||
102 | _supported_proto generic | ||
103 | +_unsupported_imgopts "subformat=streamOptimized" | ||
104 | |||
105 | |||
106 | size=6G | ||
107 | diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017 | ||
108 | index XXXXXXX..XXXXXXX 100755 | ||
109 | --- a/tests/qemu-iotests/017 | ||
110 | +++ b/tests/qemu-iotests/017 | ||
111 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
112 | _supported_fmt qcow qcow2 vmdk qed | ||
113 | _supported_proto generic | ||
114 | _unsupported_proto vxhs | ||
115 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
116 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
117 | + "subformat=streamOptimized" | ||
118 | |||
119 | TEST_OFFSETS="0 4294967296" | ||
120 | |||
121 | diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 | ||
122 | index XXXXXXX..XXXXXXX 100755 | ||
123 | --- a/tests/qemu-iotests/018 | ||
124 | +++ b/tests/qemu-iotests/018 | ||
125 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
126 | _supported_fmt qcow qcow2 vmdk qed | ||
127 | _supported_proto file | ||
128 | _supported_os Linux | ||
129 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
130 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
131 | + "streamOptimized" | ||
132 | |||
133 | TEST_OFFSETS="0 4294967296" | ||
134 | |||
135 | diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 | ||
136 | index XXXXXXX..XXXXXXX 100755 | ||
137 | --- a/tests/qemu-iotests/019 | ||
138 | +++ b/tests/qemu-iotests/019 | ||
139 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
140 | _supported_os Linux | ||
141 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
142 | "subformat=twoGbMaxExtentFlat" \ | ||
143 | - "subformat=twoGbMaxExtentSparse" | ||
144 | + "subformat=twoGbMaxExtentSparse" \ | ||
145 | + "subformat=streamOptimized" | ||
146 | |||
147 | TEST_OFFSETS="0 4294967296" | ||
148 | CLUSTER_SIZE=65536 | ||
149 | diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 | ||
150 | index XXXXXXX..XXXXXXX 100755 | ||
151 | --- a/tests/qemu-iotests/020 | ||
152 | +++ b/tests/qemu-iotests/020 | ||
153 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed | ||
154 | _supported_proto file | ||
155 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
156 | "subformat=twoGbMaxExtentFlat" \ | ||
157 | - "subformat=twoGbMaxExtentSparse" | ||
158 | + "subformat=twoGbMaxExtentSparse" \ | ||
159 | + "subformat=streamOptimized" | ||
160 | |||
161 | TEST_OFFSETS="0 4294967296" | ||
162 | |||
163 | diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027 | ||
164 | index XXXXXXX..XXXXXXX 100755 | ||
165 | --- a/tests/qemu-iotests/027 | ||
166 | +++ b/tests/qemu-iotests/027 | ||
167 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
168 | |||
169 | _supported_fmt vmdk qcow qcow2 qed | ||
170 | _supported_proto generic | ||
171 | +_unsupported_imgopts "subformat=streamOptimized" | ||
172 | |||
173 | |||
174 | size=128M | ||
175 | diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032 | ||
176 | index XXXXXXX..XXXXXXX 100755 | ||
177 | --- a/tests/qemu-iotests/032 | ||
178 | +++ b/tests/qemu-iotests/032 | ||
179 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
180 | # This works for any image format (though unlikely to segfault for raw) | ||
181 | _supported_fmt generic | ||
182 | _supported_proto generic | ||
183 | +_unsupported_imgopts "subformat=streamOptimized" | ||
184 | |||
185 | echo | ||
186 | echo === Prepare image === | ||
187 | diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033 | ||
188 | index XXXXXXX..XXXXXXX 100755 | ||
189 | --- a/tests/qemu-iotests/033 | ||
190 | +++ b/tests/qemu-iotests/033 | ||
191 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
192 | |||
193 | _supported_fmt generic | ||
194 | _supported_proto generic | ||
195 | +_unsupported_imgopts "subformat=streamOptimized" | ||
196 | |||
197 | |||
198 | size=128M | ||
199 | diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034 | ||
200 | index XXXXXXX..XXXXXXX 100755 | ||
201 | --- a/tests/qemu-iotests/034 | ||
202 | +++ b/tests/qemu-iotests/034 | ||
203 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
204 | _supported_os Linux | ||
205 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
206 | "subformat=twoGbMaxExtentFlat" \ | ||
207 | - "subformat=twoGbMaxExtentSparse" | ||
208 | + "subformat=twoGbMaxExtentSparse" \ | ||
209 | + "subformat=streamOptimized" | ||
210 | |||
211 | CLUSTER_SIZE=4k | ||
212 | size=128M | ||
213 | diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037 | ||
214 | index XXXXXXX..XXXXXXX 100755 | ||
215 | --- a/tests/qemu-iotests/037 | ||
216 | +++ b/tests/qemu-iotests/037 | ||
217 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed | ||
218 | _supported_proto file | ||
219 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
220 | "subformat=twoGbMaxExtentFlat" \ | ||
221 | - "subformat=twoGbMaxExtentSparse" | ||
222 | + "subformat=twoGbMaxExtentSparse" \ | ||
223 | + "subformat=streamOptimized" | ||
224 | |||
225 | CLUSTER_SIZE=4k | ||
226 | size=128M | ||
227 | diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063 | ||
228 | index XXXXXXX..XXXXXXX 100755 | ||
229 | --- a/tests/qemu-iotests/063 | ||
230 | +++ b/tests/qemu-iotests/063 | ||
231 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw | ||
232 | _supported_proto file | ||
233 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
234 | "subformat=twoGbMaxExtentFlat" \ | ||
235 | - "subformat=twoGbMaxExtentSparse" | ||
236 | + "subformat=twoGbMaxExtentSparse" \ | ||
237 | + "subformat=streamOptimized" | ||
238 | |||
239 | _make_test_img 4M | ||
240 | |||
241 | diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072 | ||
242 | index XXXXXXX..XXXXXXX 100755 | ||
243 | --- a/tests/qemu-iotests/072 | ||
244 | +++ b/tests/qemu-iotests/072 | ||
245 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
246 | |||
247 | _supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow | ||
248 | _supported_proto file | ||
249 | +_unsupported_imgopts "subformat=streamOptimized" | ||
250 | |||
251 | IMG_SIZE=64M | ||
252 | |||
253 | diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105 | ||
254 | index XXXXXXX..XXXXXXX 100755 | ||
255 | --- a/tests/qemu-iotests/105 | ||
256 | +++ b/tests/qemu-iotests/105 | ||
257 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
258 | _supported_fmt qcow2 vmdk vhdx qed | ||
259 | _supported_proto generic | ||
260 | _unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ | ||
261 | - "subformat=twoGbMaxExtentSparse" | ||
262 | + "subformat=twoGbMaxExtentSparse" \ | ||
263 | + "subformat=streamOptimized" | ||
264 | |||
265 | echo | ||
266 | echo "creating large image" | ||
267 | diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 | ||
268 | index XXXXXXX..XXXXXXX 100755 | ||
269 | --- a/tests/qemu-iotests/197 | ||
270 | +++ b/tests/qemu-iotests/197 | ||
271 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
272 | _supported_proto generic | ||
273 | # LUKS support may be possible, but it complicates things. | ||
274 | _unsupported_fmt luks | ||
275 | +_unsupported_imgopts "subformat=streamOptimized" | ||
276 | |||
277 | echo | ||
278 | echo '=== Copy-on-read ===' | ||
279 | diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 | ||
280 | index XXXXXXX..XXXXXXX 100755 | ||
281 | --- a/tests/qemu-iotests/215 | ||
282 | +++ b/tests/qemu-iotests/215 | ||
283 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
284 | _supported_proto generic | ||
285 | # LUKS support may be possible, but it complicates things. | ||
286 | _unsupported_fmt luks | ||
287 | +_unsupported_imgopts "subformat=streamOptimized" | ||
288 | |||
289 | echo | ||
290 | echo '=== Copy-on-read ===' | ||
291 | diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251 | ||
292 | index XXXXXXX..XXXXXXX 100755 | ||
293 | --- a/tests/qemu-iotests/251 | ||
294 | +++ b/tests/qemu-iotests/251 | ||
295 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
296 | _supported_fmt generic | ||
297 | _supported_proto file | ||
298 | _supported_os Linux | ||
299 | +_unsupported_imgopts "subformat=streamOptimized" | ||
300 | |||
301 | if [ "$IMGOPTSSYNTAX" = "true" ]; then | ||
302 | # We use json:{} filenames here, so we cannot work with additional options. | ||
303 | -- | ||
304 | 2.21.0 | ||
305 | |||
306 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | It is possible to enable only a subset of the block drivers with the | 3 | Implement and use new interface to get rid of hd_qiov. |
4 | "--block-drv-rw-whitelist" option of the "configure" script. All other | 4 | |
5 | drivers are marked as unusable (or only included as read-only with the | 5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
6 | "--block-drv-ro-whitelist" option). If an iotest is now using such a | 6 | Acked-by: Stefan Hajnoczi <stefanha@redhat.com> |
7 | disabled block driver, it is failing - which is bad, since at least the | 7 | Message-id: 20190604161514.262241-13-vsementsov@virtuozzo.com |
8 | tests in the "auto" group should be able to deal with this situation. | 8 | Message-Id: <20190604161514.262241-13-vsementsov@virtuozzo.com> |
9 | Thus let's introduce a "_require_drivers" function that can be used by | 9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
10 | the shell tests to check for the availability of certain drivers first, | ||
11 | and marks the test as "not run" if one of the drivers is missing. | ||
12 | |||
13 | This patch mainly targets the test in the "auto" group which should | ||
14 | never fail in such a case, but also improves some of the other tests | ||
15 | along the way. Note that we also assume that the "qcow2" and "file" | ||
16 | drivers are always available - otherwise it does not make sense to | ||
17 | run "make check-block" at all (which only tests with qcow2 by default). | ||
18 | |||
19 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
20 | Message-id: 20190823133552.11680-1-thuth@redhat.com | ||
21 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
22 | --- | 10 | --- |
23 | tests/qemu-iotests/071 | 1 + | 11 | block/qcow2.h | 1 + |
24 | tests/qemu-iotests/081 | 4 +--- | 12 | include/qemu/iov.h | 1 + |
25 | tests/qemu-iotests/099 | 1 + | 13 | block/qcow2-cluster.c | 9 ++++--- |
26 | tests/qemu-iotests/120 | 1 + | 14 | block/qcow2.c | 60 +++++++++++++++++++++---------------------- |
27 | tests/qemu-iotests/162 | 4 +--- | 15 | util/iov.c | 10 ++++++++ |
28 | tests/qemu-iotests/184 | 1 + | 16 | 5 files changed, 48 insertions(+), 33 deletions(-) |
29 | tests/qemu-iotests/186 | 1 + | 17 | |
30 | tests/qemu-iotests/common.rc | 14 ++++++++++++++ | 18 | diff --git a/block/qcow2.h b/block/qcow2.h |
31 | 8 files changed, 21 insertions(+), 6 deletions(-) | 19 | index XXXXXXX..XXXXXXX 100644 |
32 | 20 | --- a/block/qcow2.h | |
33 | diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 | 21 | +++ b/block/qcow2.h |
34 | index XXXXXXX..XXXXXXX 100755 | 22 | @@ -XXX,XX +XXX,XX @@ typedef struct QCowL2Meta |
35 | --- a/tests/qemu-iotests/071 | 23 | * from @cow_start and @cow_end into one single write operation. |
36 | +++ b/tests/qemu-iotests/071 | 24 | */ |
37 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 25 | QEMUIOVector *data_qiov; |
38 | 26 | + size_t data_qiov_offset; | |
39 | _supported_fmt qcow2 | 27 | |
40 | _supported_proto file | 28 | /** Pointer to next L2Meta of the same write request */ |
41 | +_require_drivers blkdebug blkverify | 29 | struct QCowL2Meta *next; |
42 | 30 | diff --git a/include/qemu/iov.h b/include/qemu/iov.h | |
43 | do_run_qemu() | 31 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/qemu/iov.h | ||
33 | +++ b/include/qemu/iov.h | ||
34 | @@ -XXX,XX +XXX,XX @@ void qemu_iovec_init_extended( | ||
35 | void *tail_buf, size_t tail_len); | ||
36 | void qemu_iovec_init_slice(QEMUIOVector *qiov, QEMUIOVector *source, | ||
37 | size_t offset, size_t len); | ||
38 | +int qemu_iovec_subvec_niov(QEMUIOVector *qiov, size_t offset, size_t len); | ||
39 | void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); | ||
40 | void qemu_iovec_concat(QEMUIOVector *dst, | ||
41 | QEMUIOVector *src, size_t soffset, size_t sbytes); | ||
42 | diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/block/qcow2-cluster.c | ||
45 | +++ b/block/qcow2-cluster.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m) | ||
47 | assert(start->nb_bytes <= UINT_MAX - end->nb_bytes); | ||
48 | assert(start->nb_bytes + end->nb_bytes <= UINT_MAX - data_bytes); | ||
49 | assert(start->offset + start->nb_bytes <= end->offset); | ||
50 | - assert(!m->data_qiov || m->data_qiov->size == data_bytes); | ||
51 | |||
52 | if ((start->nb_bytes == 0 && end->nb_bytes == 0) || m->skip_cow) { | ||
53 | return 0; | ||
54 | @@ -XXX,XX +XXX,XX @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m) | ||
55 | /* The part of the buffer where the end region is located */ | ||
56 | end_buffer = start_buffer + buffer_size - end->nb_bytes; | ||
57 | |||
58 | - qemu_iovec_init(&qiov, 2 + (m->data_qiov ? m->data_qiov->niov : 0)); | ||
59 | + qemu_iovec_init(&qiov, 2 + (m->data_qiov ? | ||
60 | + qemu_iovec_subvec_niov(m->data_qiov, | ||
61 | + m->data_qiov_offset, | ||
62 | + data_bytes) | ||
63 | + : 0)); | ||
64 | |||
65 | qemu_co_mutex_unlock(&s->lock); | ||
66 | /* First we read the existing data from both COW regions. We | ||
67 | @@ -XXX,XX +XXX,XX @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m) | ||
68 | if (start->nb_bytes) { | ||
69 | qemu_iovec_add(&qiov, start_buffer, start->nb_bytes); | ||
70 | } | ||
71 | - qemu_iovec_concat(&qiov, m->data_qiov, 0, data_bytes); | ||
72 | + qemu_iovec_concat(&qiov, m->data_qiov, m->data_qiov_offset, data_bytes); | ||
73 | if (end->nb_bytes) { | ||
74 | qemu_iovec_add(&qiov, end_buffer, end->nb_bytes); | ||
75 | } | ||
76 | diff --git a/block/qcow2.c b/block/qcow2.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/block/qcow2.c | ||
79 | +++ b/block/qcow2.c | ||
80 | @@ -XXX,XX +XXX,XX @@ fail: | ||
81 | /* Check if it's possible to merge a write request with the writing of | ||
82 | * the data from the COW regions */ | ||
83 | static bool merge_cow(uint64_t offset, unsigned bytes, | ||
84 | - QEMUIOVector *hd_qiov, QCowL2Meta *l2meta) | ||
85 | + QEMUIOVector *qiov, size_t qiov_offset, | ||
86 | + QCowL2Meta *l2meta) | ||
44 | { | 87 | { |
45 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | 88 | QCowL2Meta *m; |
46 | index XXXXXXX..XXXXXXX 100755 | 89 | |
47 | --- a/tests/qemu-iotests/081 | 90 | @@ -XXX,XX +XXX,XX @@ static bool merge_cow(uint64_t offset, unsigned bytes, |
48 | +++ b/tests/qemu-iotests/081 | 91 | |
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 92 | /* Make sure that adding both COW regions to the QEMUIOVector |
50 | _supported_fmt raw | 93 | * does not exceed IOV_MAX */ |
51 | _supported_proto file | 94 | - if (hd_qiov->niov > IOV_MAX - 2) { |
52 | _supported_os Linux | 95 | + if (qemu_iovec_subvec_niov(qiov, qiov_offset, bytes) > IOV_MAX - 2) { |
53 | +_require_drivers quorum | 96 | continue; |
54 | 97 | } | |
55 | do_run_qemu() | 98 | |
99 | - m->data_qiov = hd_qiov; | ||
100 | + m->data_qiov = qiov; | ||
101 | + m->data_qiov_offset = qiov_offset; | ||
102 | return true; | ||
103 | } | ||
104 | |||
105 | @@ -XXX,XX +XXX,XX @@ static int handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta) | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | -static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, | ||
110 | - uint64_t bytes, QEMUIOVector *qiov, | ||
111 | - int flags) | ||
112 | +static coroutine_fn int qcow2_co_pwritev_part( | ||
113 | + BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
114 | + QEMUIOVector *qiov, size_t qiov_offset, int flags) | ||
56 | { | 115 | { |
57 | @@ -XXX,XX +XXX,XX @@ run_qemu() | 116 | BDRVQcow2State *s = bs->opaque; |
58 | | _filter_qemu_io | _filter_generated_node_ids | 117 | int offset_in_cluster; |
118 | int ret; | ||
119 | unsigned int cur_bytes; /* number of sectors in current iteration */ | ||
120 | uint64_t cluster_offset; | ||
121 | - QEMUIOVector hd_qiov; | ||
122 | + QEMUIOVector encrypted_qiov; | ||
123 | uint64_t bytes_done = 0; | ||
124 | uint8_t *cluster_data = NULL; | ||
125 | QCowL2Meta *l2meta = NULL; | ||
126 | |||
127 | trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes); | ||
128 | |||
129 | - qemu_iovec_init(&hd_qiov, qiov->niov); | ||
130 | - | ||
131 | qemu_co_mutex_lock(&s->lock); | ||
132 | |||
133 | while (bytes != 0) { | ||
134 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, | ||
135 | |||
136 | qemu_co_mutex_unlock(&s->lock); | ||
137 | |||
138 | - qemu_iovec_reset(&hd_qiov); | ||
139 | - qemu_iovec_concat(&hd_qiov, qiov, bytes_done, cur_bytes); | ||
140 | - | ||
141 | if (bs->encrypted) { | ||
142 | assert(s->crypto); | ||
143 | if (!cluster_data) { | ||
144 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, | ||
145 | } | ||
146 | } | ||
147 | |||
148 | - assert(hd_qiov.size <= | ||
149 | - QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); | ||
150 | - qemu_iovec_to_buf(&hd_qiov, 0, cluster_data, hd_qiov.size); | ||
151 | + assert(cur_bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); | ||
152 | + qemu_iovec_to_buf(qiov, qiov_offset + bytes_done, | ||
153 | + cluster_data, cur_bytes); | ||
154 | |||
155 | if (qcow2_co_encrypt(bs, cluster_offset, offset, | ||
156 | cluster_data, cur_bytes) < 0) { | ||
157 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, | ||
158 | goto out_unlocked; | ||
159 | } | ||
160 | |||
161 | - qemu_iovec_reset(&hd_qiov); | ||
162 | - qemu_iovec_add(&hd_qiov, cluster_data, cur_bytes); | ||
163 | + qemu_iovec_init_buf(&encrypted_qiov, cluster_data, cur_bytes); | ||
164 | } | ||
165 | |||
166 | /* Try to efficiently initialize the physical space with zeroes */ | ||
167 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int qcow2_co_pwritev(BlockDriverState *bs, uint64_t offset, | ||
168 | * writing of the guest data together with that of the COW regions. | ||
169 | * If it's not possible (or not necessary) then write the | ||
170 | * guest data now. */ | ||
171 | - if (!merge_cow(offset, cur_bytes, &hd_qiov, l2meta)) { | ||
172 | + if (!merge_cow(offset, cur_bytes, | ||
173 | + bs->encrypted ? &encrypted_qiov : qiov, | ||
174 | + bs->encrypted ? 0 : qiov_offset + bytes_done, l2meta)) | ||
175 | + { | ||
176 | BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); | ||
177 | trace_qcow2_writev_data(qemu_coroutine_self(), | ||
178 | cluster_offset + offset_in_cluster); | ||
179 | - ret = bdrv_co_pwritev(s->data_file, | ||
180 | - cluster_offset + offset_in_cluster, | ||
181 | - cur_bytes, &hd_qiov, 0); | ||
182 | + ret = bdrv_co_pwritev_part( | ||
183 | + s->data_file, cluster_offset + offset_in_cluster, cur_bytes, | ||
184 | + bs->encrypted ? &encrypted_qiov : qiov, | ||
185 | + bs->encrypted ? 0 : qiov_offset + bytes_done, 0); | ||
186 | if (ret < 0) { | ||
187 | goto out_unlocked; | ||
188 | } | ||
189 | @@ -XXX,XX +XXX,XX @@ out_locked: | ||
190 | |||
191 | qemu_co_mutex_unlock(&s->lock); | ||
192 | |||
193 | - qemu_iovec_destroy(&hd_qiov); | ||
194 | qemu_vfree(cluster_data); | ||
195 | trace_qcow2_writev_done_req(qemu_coroutine_self(), ret); | ||
196 | |||
197 | @@ -XXX,XX +XXX,XX @@ fail: | ||
198 | /* XXX: put compressed sectors first, then all the cluster aligned | ||
199 | tables to avoid losing bytes in alignment */ | ||
200 | static coroutine_fn int | ||
201 | -qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, | ||
202 | - uint64_t bytes, QEMUIOVector *qiov) | ||
203 | +qcow2_co_pwritev_compressed_part(BlockDriverState *bs, | ||
204 | + uint64_t offset, uint64_t bytes, | ||
205 | + QEMUIOVector *qiov, size_t qiov_offset) | ||
206 | { | ||
207 | BDRVQcow2State *s = bs->opaque; | ||
208 | int ret; | ||
209 | @@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, | ||
210 | /* Zero-pad last write if image size is not cluster aligned */ | ||
211 | memset(buf + bytes, 0, s->cluster_size - bytes); | ||
212 | } | ||
213 | - qemu_iovec_to_buf(qiov, 0, buf, bytes); | ||
214 | + qemu_iovec_to_buf(qiov, qiov_offset, buf, bytes); | ||
215 | |||
216 | out_buf = g_malloc(s->cluster_size); | ||
217 | |||
218 | @@ -XXX,XX +XXX,XX @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, | ||
219 | buf, s->cluster_size); | ||
220 | if (out_len == -ENOMEM) { | ||
221 | /* could not compress: write normal cluster */ | ||
222 | - ret = qcow2_co_pwritev(bs, offset, bytes, qiov, 0); | ||
223 | + ret = qcow2_co_pwritev_part(bs, offset, bytes, qiov, qiov_offset, 0); | ||
224 | if (ret < 0) { | ||
225 | goto fail; | ||
226 | } | ||
227 | @@ -XXX,XX +XXX,XX @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, | ||
228 | BDRVQcow2State *s = bs->opaque; | ||
229 | |||
230 | BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); | ||
231 | - return bs->drv->bdrv_co_pwritev(bs, qcow2_vm_state_offset(s) + pos, | ||
232 | - qiov->size, qiov, 0); | ||
233 | + return bs->drv->bdrv_co_pwritev_part(bs, qcow2_vm_state_offset(s) + pos, | ||
234 | + qiov->size, qiov, 0, 0); | ||
59 | } | 235 | } |
60 | 236 | ||
61 | -test_quorum=$($QEMU_IMG --help|grep quorum) | 237 | static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, |
62 | -[ "$test_quorum" = "" ] && _supported_fmt quorum | 238 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_qcow2 = { |
63 | - | 239 | .bdrv_co_block_status = qcow2_co_block_status, |
64 | quorum="driver=raw,file.driver=quorum,file.vote-threshold=2" | 240 | |
65 | quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" | 241 | .bdrv_co_preadv_part = qcow2_co_preadv_part, |
66 | quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" | 242 | - .bdrv_co_pwritev = qcow2_co_pwritev, |
67 | diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099 | 243 | + .bdrv_co_pwritev_part = qcow2_co_pwritev_part, |
68 | index XXXXXXX..XXXXXXX 100755 | 244 | .bdrv_co_flush_to_os = qcow2_co_flush_to_os, |
69 | --- a/tests/qemu-iotests/099 | 245 | |
70 | +++ b/tests/qemu-iotests/099 | 246 | .bdrv_co_pwrite_zeroes = qcow2_co_pwrite_zeroes, |
71 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 247 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_qcow2 = { |
72 | _supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc | 248 | .bdrv_co_copy_range_from = qcow2_co_copy_range_from, |
73 | _supported_proto file | 249 | .bdrv_co_copy_range_to = qcow2_co_copy_range_to, |
74 | _supported_os Linux | 250 | .bdrv_co_truncate = qcow2_co_truncate, |
75 | +_require_drivers blkdebug blkverify | 251 | - .bdrv_co_pwritev_compressed = qcow2_co_pwritev_compressed, |
76 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | 252 | + .bdrv_co_pwritev_compressed_part = qcow2_co_pwritev_compressed_part, |
77 | "subformat=twoGbMaxExtentSparse" | 253 | .bdrv_make_empty = qcow2_make_empty, |
78 | 254 | ||
79 | diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120 | 255 | .bdrv_snapshot_create = qcow2_snapshot_create, |
80 | index XXXXXXX..XXXXXXX 100755 | 256 | diff --git a/util/iov.c b/util/iov.c |
81 | --- a/tests/qemu-iotests/120 | 257 | index XXXXXXX..XXXXXXX 100644 |
82 | +++ b/tests/qemu-iotests/120 | 258 | --- a/util/iov.c |
83 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | 259 | +++ b/util/iov.c |
84 | _supported_fmt generic | 260 | @@ -XXX,XX +XXX,XX @@ static struct iovec *qiov_slice(QEMUIOVector *qiov, |
85 | _supported_proto file | 261 | return iov; |
86 | _unsupported_fmt luks | ||
87 | +_require_drivers raw | ||
88 | |||
89 | _make_test_img 64M | ||
90 | |||
91 | diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162 | ||
92 | index XXXXXXX..XXXXXXX 100755 | ||
93 | --- a/tests/qemu-iotests/162 | ||
94 | +++ b/tests/qemu-iotests/162 | ||
95 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
96 | . ./common.filter | ||
97 | |||
98 | _supported_fmt generic | ||
99 | - | ||
100 | -test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)') | ||
101 | -[ "$test_ssh" = "" ] && _notrun "ssh support required" | ||
102 | +_require_drivers ssh | ||
103 | |||
104 | echo | ||
105 | echo '=== NBD ===' | ||
106 | diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184 | ||
107 | index XXXXXXX..XXXXXXX 100755 | ||
108 | --- a/tests/qemu-iotests/184 | ||
109 | +++ b/tests/qemu-iotests/184 | ||
110 | @@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15 | ||
111 | . ./common.filter | ||
112 | |||
113 | _supported_os Linux | ||
114 | +_require_drivers throttle | ||
115 | |||
116 | do_run_qemu() | ||
117 | { | ||
118 | diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186 | ||
119 | index XXXXXXX..XXXXXXX 100755 | ||
120 | --- a/tests/qemu-iotests/186 | ||
121 | +++ b/tests/qemu-iotests/186 | ||
122 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
123 | |||
124 | _supported_fmt qcow2 | ||
125 | _supported_proto file | ||
126 | +_require_drivers null-co | ||
127 | |||
128 | if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then | ||
129 | _notrun "Requires a PC machine" | ||
130 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
131 | index XXXXXXX..XXXXXXX 100644 | ||
132 | --- a/tests/qemu-iotests/common.rc | ||
133 | +++ b/tests/qemu-iotests/common.rc | ||
134 | @@ -XXX,XX +XXX,XX @@ _require_command() | ||
135 | [ -x "$c" ] || _notrun "$1 utility required, skipped this test" | ||
136 | } | 262 | } |
137 | 263 | ||
138 | +# Check that a set of drivers has been whitelisted in the QEMU binary | 264 | +int qemu_iovec_subvec_niov(QEMUIOVector *qiov, size_t offset, size_t len) |
139 | +# | ||
140 | +_require_drivers() | ||
141 | +{ | 265 | +{ |
142 | + available=$($QEMU -drive format=help | \ | 266 | + size_t head, tail; |
143 | + sed -e '/Supported formats:/!d' -e 's/Supported formats://') | 267 | + int niov; |
144 | + for driver | 268 | + |
145 | + do | 269 | + qiov_slice(qiov, offset, len, &head, &tail, &niov); |
146 | + if ! echo "$available" | grep -q " $driver\( \|$\)"; then | 270 | + |
147 | + _notrun "$driver not available" | 271 | + return niov; |
148 | + fi | ||
149 | + done | ||
150 | +} | 272 | +} |
151 | + | 273 | + |
152 | # make sure this script returns success | 274 | /* |
153 | true | 275 | * Compile new iovec, combining @head_buf buffer, sub-qiov of @mid_qiov, |
276 | * and @tail_buf buffer into new qiov. | ||
154 | -- | 277 | -- |
155 | 2.21.0 | 278 | 2.21.0 |
156 | 279 | ||
157 | 280 | diff view generated by jsdifflib |