1 | The following changes since commit d01beac177d44491d7db8747b79d94e1b53d173b: | 1 | The following changes since commit 711c0418c8c1ce3a24346f058b001c4c5a2f0f81: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20180507-pull-request' into staging (2018-05-08 14:23:02 +0100) | 3 | Merge remote-tracking branch 'remotes/philmd/tags/mips-20210702' into staging (2021-07-04 14:04:12 +0100) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request | 7 | https://gitlab.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to a2cb9239b7610ffb00f9ced5cd7640d40b0e1ccf: | 9 | for you to fetch changes up to 9f460c64e13897117f35ffb61f6f5e0102cabc70: |
10 | 10 | ||
11 | sheepdog: Fix sd_co_create_opts() memory leaks (2018-05-08 10:47:27 -0400) | 11 | block/io: Merge discard request alignments (2021-07-06 14:28:55 +0100) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches | 14 | Pull request |
15 | |||
15 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
16 | 17 | ||
17 | Kevin Wolf (1): | 18 | Akihiko Odaki (3): |
18 | sheepdog: Fix sd_co_create_opts() memory leaks | 19 | block/file-posix: Optimize for macOS |
20 | block: Add backend_defaults property | ||
21 | block/io: Merge discard request alignments | ||
19 | 22 | ||
20 | Max Reitz (2): | 23 | Stefan Hajnoczi (2): |
21 | block/mirror: Make cancel always cancel pre-READY | 24 | util/async: add a human-readable name to BHs for debugging |
22 | iotests: Add test for cancelling a mirror job | 25 | util/async: print leaked BH name when AioContext finalizes |
23 | 26 | ||
24 | Stefan Hajnoczi (1): | 27 | include/block/aio.h | 31 ++++++++++++++++++++++--- |
25 | block/mirror: honor ratelimit again | 28 | include/hw/block/block.h | 3 +++ |
26 | 29 | include/qemu/main-loop.h | 4 +++- | |
27 | block/mirror.c | 14 +++-- | 30 | block/file-posix.c | 27 ++++++++++++++++++++-- |
28 | block/sheepdog.c | 4 +- | 31 | block/io.c | 2 ++ |
29 | tests/qemu-iotests/185.out | 4 +- | 32 | hw/block/block.c | 42 ++++++++++++++++++++++++++++++---- |
30 | tests/qemu-iotests/218 | 138 +++++++++++++++++++++++++++++++++++++++++++++ | 33 | tests/unit/ptimer-test-stubs.c | 2 +- |
31 | tests/qemu-iotests/218.out | 30 ++++++++++ | 34 | util/async.c | 25 ++++++++++++++++---- |
32 | tests/qemu-iotests/group | 1 + | 35 | util/main-loop.c | 4 ++-- |
33 | 6 files changed, 183 insertions(+), 8 deletions(-) | 36 | tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++ |
34 | create mode 100644 tests/qemu-iotests/218 | 37 | 10 files changed, 161 insertions(+), 17 deletions(-) |
35 | create mode 100644 tests/qemu-iotests/218.out | ||
36 | 38 | ||
37 | -- | 39 | -- |
38 | 2.13.6 | 40 | 2.31.1 |
39 | 41 | ||
40 | diff view generated by jsdifflib |
1 | From: Kevin Wolf <kwolf@redhat.com> | 1 | It can be difficult to debug issues with BHs in production environments. |
---|---|---|---|
2 | Although BHs can usually be identified by looking up their ->cb() | ||
3 | function pointer, this requires debug information for the program. It is | ||
4 | also not possible to print human-readable diagnostics about BHs because | ||
5 | they have no identifier. | ||
2 | 6 | ||
3 | Both the option string for the 'redundancy' option and the | 7 | This patch adds a name to each BH. The name is not unique per instance |
4 | SheepdogRedundancy object that is created accordingly could be leaked in | 8 | but differentiates between cb() functions, which is usually enough. It's |
5 | error paths. This fixes the memory leaks. | 9 | done by changing aio_bh_new() and friends to macros that stringify cb. |
6 | 10 | ||
7 | Reported by Coverity (CID 1390614 and 1390641). | 11 | The next patch will use the name field when reporting leaked BHs. |
8 | 12 | ||
9 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
10 | Message-id: 20180503153509.22223-1-kwolf@redhat.com | 14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
11 | Reviewed-by: Jeff Cody <jcody@redhat.com> | 15 | Message-Id: <20210414200247.917496-2-stefanha@redhat.com> |
12 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
13 | --- | 16 | --- |
14 | block/sheepdog.c | 4 +++- | 17 | include/block/aio.h | 31 ++++++++++++++++++++++++++++--- |
15 | 1 file changed, 3 insertions(+), 1 deletion(-) | 18 | include/qemu/main-loop.h | 4 +++- |
19 | tests/unit/ptimer-test-stubs.c | 2 +- | ||
20 | util/async.c | 9 +++++++-- | ||
21 | util/main-loop.c | 4 ++-- | ||
22 | 5 files changed, 41 insertions(+), 9 deletions(-) | ||
16 | 23 | ||
17 | diff --git a/block/sheepdog.c b/block/sheepdog.c | 24 | diff --git a/include/block/aio.h b/include/block/aio.h |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/block/sheepdog.c | 26 | --- a/include/block/aio.h |
20 | +++ b/block/sheepdog.c | 27 | +++ b/include/block/aio.h |
21 | @@ -XXX,XX +XXX,XX @@ static SheepdogRedundancy *parse_redundancy_str(const char *opt) | 28 | @@ -XXX,XX +XXX,XX @@ void aio_context_acquire(AioContext *ctx); |
22 | } else { | 29 | /* Relinquish ownership of the AioContext. */ |
23 | ret = qemu_strtol(n2, NULL, 10, &parity); | 30 | void aio_context_release(AioContext *ctx); |
24 | if (ret < 0) { | 31 | |
25 | + g_free(redundancy); | 32 | +/** |
26 | return NULL; | 33 | + * aio_bh_schedule_oneshot_full: Allocate a new bottom half structure that will |
27 | } | 34 | + * run only once and as soon as possible. |
28 | 35 | + * | |
29 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts, | 36 | + * @name: A human-readable identifier for debugging purposes. |
30 | QDict *qdict, *location_qdict; | 37 | + */ |
31 | QObject *crumpled; | 38 | +void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, |
32 | Visitor *v; | 39 | + const char *name); |
33 | - const char *redundancy; | 40 | + |
34 | + char *redundancy; | 41 | /** |
35 | Error *local_err = NULL; | 42 | * aio_bh_schedule_oneshot: Allocate a new bottom half structure that will run |
36 | int ret; | 43 | * only once and as soon as possible. |
37 | 44 | + * | |
38 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts, | 45 | + * A convenience wrapper for aio_bh_schedule_oneshot_full() that uses cb as the |
39 | fail: | 46 | + * name string. |
40 | qapi_free_BlockdevCreateOptions(create_options); | 47 | */ |
41 | qobject_unref(qdict); | 48 | -void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque); |
42 | + g_free(redundancy); | 49 | +#define aio_bh_schedule_oneshot(ctx, cb, opaque) \ |
43 | return ret; | 50 | + aio_bh_schedule_oneshot_full((ctx), (cb), (opaque), (stringify(cb))) |
51 | |||
52 | /** | ||
53 | - * aio_bh_new: Allocate a new bottom half structure. | ||
54 | + * aio_bh_new_full: Allocate a new bottom half structure. | ||
55 | * | ||
56 | * Bottom halves are lightweight callbacks whose invocation is guaranteed | ||
57 | * to be wait-free, thread-safe and signal-safe. The #QEMUBH structure | ||
58 | * is opaque and must be allocated prior to its use. | ||
59 | + * | ||
60 | + * @name: A human-readable identifier for debugging purposes. | ||
61 | */ | ||
62 | -QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque); | ||
63 | +QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, | ||
64 | + const char *name); | ||
65 | + | ||
66 | +/** | ||
67 | + * aio_bh_new: Allocate a new bottom half structure | ||
68 | + * | ||
69 | + * A convenience wrapper for aio_bh_new_full() that uses the cb as the name | ||
70 | + * string. | ||
71 | + */ | ||
72 | +#define aio_bh_new(ctx, cb, opaque) \ | ||
73 | + aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb))) | ||
74 | |||
75 | /** | ||
76 | * aio_notify: Force processing of pending events. | ||
77 | diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/include/qemu/main-loop.h | ||
80 | +++ b/include/qemu/main-loop.h | ||
81 | @@ -XXX,XX +XXX,XX @@ void qemu_cond_timedwait_iothread(QemuCond *cond, int ms); | ||
82 | |||
83 | void qemu_fd_register(int fd); | ||
84 | |||
85 | -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); | ||
86 | +#define qemu_bh_new(cb, opaque) \ | ||
87 | + qemu_bh_new_full((cb), (opaque), (stringify(cb))) | ||
88 | +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name); | ||
89 | void qemu_bh_schedule_idle(QEMUBH *bh); | ||
90 | |||
91 | enum { | ||
92 | diff --git a/tests/unit/ptimer-test-stubs.c b/tests/unit/ptimer-test-stubs.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/tests/unit/ptimer-test-stubs.c | ||
95 | +++ b/tests/unit/ptimer-test-stubs.c | ||
96 | @@ -XXX,XX +XXX,XX @@ int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask) | ||
97 | return deadline; | ||
44 | } | 98 | } |
45 | 99 | ||
100 | -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) | ||
101 | +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name) | ||
102 | { | ||
103 | QEMUBH *bh = g_new(QEMUBH, 1); | ||
104 | |||
105 | diff --git a/util/async.c b/util/async.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/util/async.c | ||
108 | +++ b/util/async.c | ||
109 | @@ -XXX,XX +XXX,XX @@ enum { | ||
110 | |||
111 | struct QEMUBH { | ||
112 | AioContext *ctx; | ||
113 | + const char *name; | ||
114 | QEMUBHFunc *cb; | ||
115 | void *opaque; | ||
116 | QSLIST_ENTRY(QEMUBH) next; | ||
117 | @@ -XXX,XX +XXX,XX @@ static QEMUBH *aio_bh_dequeue(BHList *head, unsigned *flags) | ||
118 | return bh; | ||
119 | } | ||
120 | |||
121 | -void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque) | ||
122 | +void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, | ||
123 | + void *opaque, const char *name) | ||
124 | { | ||
125 | QEMUBH *bh; | ||
126 | bh = g_new(QEMUBH, 1); | ||
127 | @@ -XXX,XX +XXX,XX @@ void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque) | ||
128 | .ctx = ctx, | ||
129 | .cb = cb, | ||
130 | .opaque = opaque, | ||
131 | + .name = name, | ||
132 | }; | ||
133 | aio_bh_enqueue(bh, BH_SCHEDULED | BH_ONESHOT); | ||
134 | } | ||
135 | |||
136 | -QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) | ||
137 | +QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, | ||
138 | + const char *name) | ||
139 | { | ||
140 | QEMUBH *bh; | ||
141 | bh = g_new(QEMUBH, 1); | ||
142 | @@ -XXX,XX +XXX,XX @@ QEMUBH *aio_bh_new(AioContext *ctx, QEMUBHFunc *cb, void *opaque) | ||
143 | .ctx = ctx, | ||
144 | .cb = cb, | ||
145 | .opaque = opaque, | ||
146 | + .name = name, | ||
147 | }; | ||
148 | return bh; | ||
149 | } | ||
150 | diff --git a/util/main-loop.c b/util/main-loop.c | ||
151 | index XXXXXXX..XXXXXXX 100644 | ||
152 | --- a/util/main-loop.c | ||
153 | +++ b/util/main-loop.c | ||
154 | @@ -XXX,XX +XXX,XX @@ void main_loop_wait(int nonblocking) | ||
155 | |||
156 | /* Functions to operate on the main QEMU AioContext. */ | ||
157 | |||
158 | -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) | ||
159 | +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name) | ||
160 | { | ||
161 | - return aio_bh_new(qemu_aio_context, cb, opaque); | ||
162 | + return aio_bh_new_full(qemu_aio_context, cb, opaque, name); | ||
163 | } | ||
164 | |||
165 | /* | ||
46 | -- | 166 | -- |
47 | 2.13.6 | 167 | 2.31.1 |
48 | 168 | ||
49 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | BHs must be deleted before the AioContext is finalized. If not, it's a | ||
2 | bug and probably indicates that some part of the program still expects | ||
3 | the BH to run in the future. That can lead to memory leaks, inconsistent | ||
4 | state, or just hangs. | ||
1 | 5 | ||
6 | Unfortunately the assert(flags & BH_DELETED) call in aio_ctx_finalize() | ||
7 | is difficult to debug because the assertion failure contains no | ||
8 | information about the BH! | ||
9 | |||
10 | Use the QEMUBH name field added in the previous patch to show a useful | ||
11 | error when a leaked BH is detected. | ||
12 | |||
13 | Suggested-by: Eric Ernst <eric.g.ernst@gmail.com> | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | Message-Id: <20210414200247.917496-3-stefanha@redhat.com> | ||
16 | --- | ||
17 | util/async.c | 16 ++++++++++++++-- | ||
18 | 1 file changed, 14 insertions(+), 2 deletions(-) | ||
19 | |||
20 | diff --git a/util/async.c b/util/async.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/util/async.c | ||
23 | +++ b/util/async.c | ||
24 | @@ -XXX,XX +XXX,XX @@ aio_ctx_finalize(GSource *source) | ||
25 | assert(QSIMPLEQ_EMPTY(&ctx->bh_slice_list)); | ||
26 | |||
27 | while ((bh = aio_bh_dequeue(&ctx->bh_list, &flags))) { | ||
28 | - /* qemu_bh_delete() must have been called on BHs in this AioContext */ | ||
29 | - assert(flags & BH_DELETED); | ||
30 | + /* | ||
31 | + * qemu_bh_delete() must have been called on BHs in this AioContext. In | ||
32 | + * many cases memory leaks, hangs, or inconsistent state occur when a | ||
33 | + * BH is leaked because something still expects it to run. | ||
34 | + * | ||
35 | + * If you hit this, fix the lifecycle of the BH so that | ||
36 | + * qemu_bh_delete() and any associated cleanup is called before the | ||
37 | + * AioContext is finalized. | ||
38 | + */ | ||
39 | + if (unlikely(!(flags & BH_DELETED))) { | ||
40 | + fprintf(stderr, "%s: BH '%s' leaked, aborting...\n", | ||
41 | + __func__, bh->name); | ||
42 | + abort(); | ||
43 | + } | ||
44 | |||
45 | g_free(bh); | ||
46 | } | ||
47 | -- | ||
48 | 2.31.1 | ||
49 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Akihiko Odaki <akihiko.odaki@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | We already have an extensive mirror test (041) which does cover | 3 | This commit introduces "punch hole" operation and optimizes transfer |
4 | cancelling a mirror job, especially after it has emitted the READY | 4 | block size for macOS. |
5 | event. However, it does not check what exact events are emitted after | ||
6 | block-job-cancel is executed. More importantly, it does not use | ||
7 | throttling to ensure that it covers the case of block-job-cancel before | ||
8 | READY. | ||
9 | 5 | ||
10 | It would be possible to add this case to 041, but considering it is | 6 | Thanks to Konstantin Nazarov for detailed analysis of a flaw in an |
11 | already our largest test file, it makes sense to create a new file for | 7 | old version of this change: |
12 | these cases. | 8 | https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3654667 |
13 | 9 | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> |
15 | Message-id: 20180501220509.14152-3-mreitz@redhat.com | 11 | Message-id: 20210705130458.97642-1-akihiko.odaki@gmail.com |
16 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
17 | --- | 13 | --- |
18 | tests/qemu-iotests/218 | 138 +++++++++++++++++++++++++++++++++++++++++++++ | 14 | block/file-posix.c | 27 +++++++++++++++++++++++++-- |
19 | tests/qemu-iotests/218.out | 30 ++++++++++ | 15 | 1 file changed, 25 insertions(+), 2 deletions(-) |
20 | tests/qemu-iotests/group | 1 + | ||
21 | 3 files changed, 169 insertions(+) | ||
22 | create mode 100644 tests/qemu-iotests/218 | ||
23 | create mode 100644 tests/qemu-iotests/218.out | ||
24 | 16 | ||
25 | diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 | 17 | diff --git a/block/file-posix.c b/block/file-posix.c |
26 | new file mode 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
27 | index XXXXXXX..XXXXXXX | 19 | --- a/block/file-posix.c |
28 | --- /dev/null | 20 | +++ b/block/file-posix.c |
29 | +++ b/tests/qemu-iotests/218 | ||
30 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
31 | +#!/usr/bin/env python | 22 | #if defined(HAVE_HOST_BLOCK_DEVICE) |
32 | +# | 23 | #include <paths.h> |
33 | +# This test covers what happens when a mirror block job is cancelled | 24 | #include <sys/param.h> |
34 | +# in various phases of its existence. | 25 | +#include <sys/mount.h> |
35 | +# | 26 | #include <IOKit/IOKitLib.h> |
36 | +# Note that this test only checks the emitted events (i.e. | 27 | #include <IOKit/IOBSD.h> |
37 | +# BLOCK_JOB_COMPLETED vs. BLOCK_JOB_CANCELLED), it does not compare | 28 | #include <IOKit/storage/IOMediaBSDClient.h> |
38 | +# whether the target is in sync with the source when the | 29 | @@ -XXX,XX +XXX,XX @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) |
39 | +# BLOCK_JOB_COMPLETED event occurs. This is covered by other tests | 30 | return; |
40 | +# (such as 041). | 31 | } |
41 | +# | 32 | |
42 | +# Copyright (C) 2018 Red Hat, Inc. | 33 | +#if defined(__APPLE__) && (__MACH__) |
43 | +# | 34 | + struct statfs buf; |
44 | +# This program is free software; you can redistribute it and/or modify | ||
45 | +# it under the terms of the GNU General Public License as published by | ||
46 | +# the Free Software Foundation; either version 2 of the License, or | ||
47 | +# (at your option) any later version. | ||
48 | +# | ||
49 | +# This program is distributed in the hope that it will be useful, | ||
50 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
51 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
52 | +# GNU General Public License for more details. | ||
53 | +# | ||
54 | +# You should have received a copy of the GNU General Public License | ||
55 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
56 | +# | ||
57 | +# Creator/Owner: Max Reitz <mreitz@redhat.com> | ||
58 | + | 35 | + |
59 | +import iotests | 36 | + if (!fstatfs(s->fd, &buf)) { |
60 | +from iotests import log | 37 | + bs->bl.opt_transfer = buf.f_iosize; |
38 | + bs->bl.pdiscard_alignment = buf.f_bsize; | ||
39 | + } | ||
40 | +#endif | ||
61 | + | 41 | + |
62 | +iotests.verify_platform(['linux']) | 42 | if (bs->sg || S_ISBLK(st.st_mode)) { |
63 | + | 43 | int ret = hdev_get_max_hw_transfer(s->fd, &st); |
64 | + | 44 | |
65 | +# Launches the VM, adds two null-co nodes (source and target), and | 45 | @@ -XXX,XX +XXX,XX @@ out: |
66 | +# starts a blockdev-mirror job on them. | 46 | } |
67 | +# | 47 | } |
68 | +# Either both or none of speed and buf_size must be given. | 48 | |
69 | + | 49 | +#if defined(CONFIG_FALLOCATE) || defined(BLKZEROOUT) || defined(BLKDISCARD) |
70 | +def start_mirror(vm, speed=None, buf_size=None): | 50 | static int translate_err(int err) |
71 | + vm.launch() | 51 | { |
72 | + | 52 | if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP || |
73 | + ret = vm.qmp('blockdev-add', | 53 | @@ -XXX,XX +XXX,XX @@ static int translate_err(int err) |
74 | + node_name='source', | 54 | } |
75 | + driver='null-co', | 55 | return err; |
76 | + size=1048576) | 56 | } |
77 | + assert ret['return'] == {} | 57 | +#endif |
78 | + | 58 | |
79 | + ret = vm.qmp('blockdev-add', | 59 | #ifdef CONFIG_FALLOCATE |
80 | + node_name='target', | 60 | static int do_fallocate(int fd, int mode, off_t offset, off_t len) |
81 | + driver='null-co', | 61 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque) |
82 | + size=1048576) | 62 | } |
83 | + assert ret['return'] == {} | 63 | } while (errno == EINTR); |
84 | + | 64 | |
85 | + if speed is not None: | 65 | - ret = -errno; |
86 | + ret = vm.qmp('blockdev-mirror', | 66 | + ret = translate_err(-errno); |
87 | + job_id='mirror', | 67 | #endif |
88 | + device='source', | 68 | } else { |
89 | + target='target', | 69 | #ifdef CONFIG_FALLOCATE_PUNCH_HOLE |
90 | + sync='full', | 70 | ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, |
91 | + speed=speed, | 71 | aiocb->aio_offset, aiocb->aio_nbytes); |
92 | + buf_size=buf_size) | 72 | + ret = translate_err(-errno); |
93 | + else: | 73 | +#elif defined(__APPLE__) && (__MACH__) |
94 | + ret = vm.qmp('blockdev-mirror', | 74 | + fpunchhole_t fpunchhole; |
95 | + job_id='mirror', | 75 | + fpunchhole.fp_flags = 0; |
96 | + device='source', | 76 | + fpunchhole.reserved = 0; |
97 | + target='target', | 77 | + fpunchhole.fp_offset = aiocb->aio_offset; |
98 | + sync='full') | 78 | + fpunchhole.fp_length = aiocb->aio_nbytes; |
99 | + | 79 | + if (fcntl(s->fd, F_PUNCHHOLE, &fpunchhole) == -1) { |
100 | + assert ret['return'] == {} | 80 | + ret = errno == ENODEV ? -ENOTSUP : -errno; |
101 | + | 81 | + } else { |
102 | + | 82 | + ret = 0; |
103 | +log('') | 83 | + } |
104 | +log('=== Cancel mirror job before convergence ===') | 84 | #endif |
105 | +log('') | 85 | } |
106 | + | 86 | |
107 | +log('--- force=false ---') | 87 | - ret = translate_err(ret); |
108 | +log('') | 88 | if (ret == -ENOTSUP) { |
109 | + | 89 | s->has_discard = false; |
110 | +with iotests.VM() as vm: | 90 | } |
111 | + # Low speed so it does not converge | ||
112 | + start_mirror(vm, 65536, 65536) | ||
113 | + | ||
114 | + log('Cancelling job') | ||
115 | + log(vm.qmp('block-job-cancel', device='mirror', force=False)) | ||
116 | + | ||
117 | + log(vm.event_wait('BLOCK_JOB_CANCELLED'), | ||
118 | + filters=[iotests.filter_qmp_event]) | ||
119 | + | ||
120 | +log('') | ||
121 | +log('--- force=true ---') | ||
122 | +log('') | ||
123 | + | ||
124 | +with iotests.VM() as vm: | ||
125 | + # Low speed so it does not converge | ||
126 | + start_mirror(vm, 65536, 65536) | ||
127 | + | ||
128 | + log('Cancelling job') | ||
129 | + log(vm.qmp('block-job-cancel', device='mirror', force=True)) | ||
130 | + | ||
131 | + log(vm.event_wait('BLOCK_JOB_CANCELLED'), | ||
132 | + filters=[iotests.filter_qmp_event]) | ||
133 | + | ||
134 | + | ||
135 | +log('') | ||
136 | +log('=== Cancel mirror job after convergence ===') | ||
137 | +log('') | ||
138 | + | ||
139 | +log('--- force=false ---') | ||
140 | +log('') | ||
141 | + | ||
142 | +with iotests.VM() as vm: | ||
143 | + start_mirror(vm) | ||
144 | + | ||
145 | + log(vm.event_wait('BLOCK_JOB_READY'), | ||
146 | + filters=[iotests.filter_qmp_event]) | ||
147 | + | ||
148 | + log('Cancelling job') | ||
149 | + log(vm.qmp('block-job-cancel', device='mirror', force=False)) | ||
150 | + | ||
151 | + log(vm.event_wait('BLOCK_JOB_COMPLETED'), | ||
152 | + filters=[iotests.filter_qmp_event]) | ||
153 | + | ||
154 | +log('') | ||
155 | +log('--- force=true ---') | ||
156 | +log('') | ||
157 | + | ||
158 | +with iotests.VM() as vm: | ||
159 | + start_mirror(vm) | ||
160 | + | ||
161 | + log(vm.event_wait('BLOCK_JOB_READY'), | ||
162 | + filters=[iotests.filter_qmp_event]) | ||
163 | + | ||
164 | + log('Cancelling job') | ||
165 | + log(vm.qmp('block-job-cancel', device='mirror', force=True)) | ||
166 | + | ||
167 | + log(vm.event_wait('BLOCK_JOB_CANCELLED'), | ||
168 | + filters=[iotests.filter_qmp_event]) | ||
169 | diff --git a/tests/qemu-iotests/218.out b/tests/qemu-iotests/218.out | ||
170 | new file mode 100644 | ||
171 | index XXXXXXX..XXXXXXX | ||
172 | --- /dev/null | ||
173 | +++ b/tests/qemu-iotests/218.out | ||
174 | @@ -XXX,XX +XXX,XX @@ | ||
175 | + | ||
176 | +=== Cancel mirror job before convergence === | ||
177 | + | ||
178 | +--- force=false --- | ||
179 | + | ||
180 | +Cancelling job | ||
181 | +{u'return': {}} | ||
182 | +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 65536, u'len': 1048576, u'offset': 65536}, u'event': u'BLOCK_JOB_CANCELLED'} | ||
183 | + | ||
184 | +--- force=true --- | ||
185 | + | ||
186 | +Cancelling job | ||
187 | +{u'return': {}} | ||
188 | +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 65536, u'len': 1048576, u'offset': 65536}, u'event': u'BLOCK_JOB_CANCELLED'} | ||
189 | + | ||
190 | +=== Cancel mirror job after convergence === | ||
191 | + | ||
192 | +--- force=false --- | ||
193 | + | ||
194 | +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_READY'} | ||
195 | +Cancelling job | ||
196 | +{u'return': {}} | ||
197 | +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_COMPLETED'} | ||
198 | + | ||
199 | +--- force=true --- | ||
200 | + | ||
201 | +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_READY'} | ||
202 | +Cancelling job | ||
203 | +{u'return': {}} | ||
204 | +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_CANCELLED'} | ||
205 | diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group | ||
206 | index XXXXXXX..XXXXXXX 100644 | ||
207 | --- a/tests/qemu-iotests/group | ||
208 | +++ b/tests/qemu-iotests/group | ||
209 | @@ -XXX,XX +XXX,XX @@ | ||
210 | 211 rw auto quick | ||
211 | 212 rw auto quick | ||
212 | 213 rw auto quick | ||
213 | +218 rw auto quick | ||
214 | -- | 91 | -- |
215 | 2.13.6 | 92 | 2.31.1 |
216 | 93 | ||
217 | diff view generated by jsdifflib |
1 | From: Max Reitz <mreitz@redhat.com> | 1 | From: Akihiko Odaki <akihiko.odaki@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748 made the mirror block | 3 | backend_defaults property allow users to control if default block |
4 | job respect block-job-cancel's @force flag: With that flag set, it would | 4 | properties should be decided with backend information. |
5 | now always really cancel, even post-READY. | 5 | |
6 | 6 | If it is off, any backend information will be discarded, which is | |
7 | Unfortunately, it had a side effect: Without that flag set, it would now | 7 | suitable if you plan to perform live migration to a different disk backend. |
8 | never cancel, not even before READY. Considering that is an | 8 | |
9 | incompatible change and not noted anywhere in the commit or the | 9 | If it is on, a block device may utilize backend information more |
10 | description of block-job-cancel's @force parameter, this seems | 10 | aggressively. |
11 | unintentional and we should revert to the previous behavior, which is to | 11 | |
12 | immediately cancel the job when block-job-cancel is called before source | 12 | By default, it is auto, which uses backend information for block |
13 | and target are in sync (i.e. before the READY event). | 13 | sizes and ignores the others, which is consistent with the older |
14 | 14 | versions. | |
15 | Cc: qemu-stable@nongnu.org | 15 | |
16 | Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1572856 | 16 | Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> |
17 | Reported-by: Yanan Fu <yfu@redhat.com> | 17 | Message-id: 20210705130458.97642-2-akihiko.odaki@gmail.com |
18 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
19 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
20 | Message-id: 20180501220509.14152-2-mreitz@redhat.com | ||
21 | Reviewed-by: Jeff Cody <jcody@redhat.com> | ||
22 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
23 | --- | 19 | --- |
24 | block/mirror.c | 4 +++- | 20 | include/hw/block/block.h | 3 +++ |
25 | 1 file changed, 3 insertions(+), 1 deletion(-) | 21 | hw/block/block.c | 42 ++++++++++++++++++++++++++++++++++---- |
26 | 22 | tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++++++ | |
27 | diff --git a/block/mirror.c b/block/mirror.c | 23 | 3 files changed, 79 insertions(+), 4 deletions(-) |
24 | |||
25 | diff --git a/include/hw/block/block.h b/include/hw/block/block.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/block/mirror.c | 27 | --- a/include/hw/block/block.h |
30 | +++ b/block/mirror.c | 28 | +++ b/include/hw/block/block.h |
31 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn mirror_run(void *opaque) | 29 | @@ -XXX,XX +XXX,XX @@ |
30 | |||
31 | typedef struct BlockConf { | ||
32 | BlockBackend *blk; | ||
33 | + OnOffAuto backend_defaults; | ||
34 | uint32_t physical_block_size; | ||
35 | uint32_t logical_block_size; | ||
36 | uint32_t min_io_size; | ||
37 | @@ -XXX,XX +XXX,XX @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) | ||
38 | } | ||
39 | |||
40 | #define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) \ | ||
41 | + DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state, \ | ||
42 | + _conf.backend_defaults, ON_OFF_AUTO_AUTO), \ | ||
43 | DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \ | ||
44 | _conf.logical_block_size), \ | ||
45 | DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \ | ||
46 | diff --git a/hw/block/block.c b/hw/block/block.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/block/block.c | ||
49 | +++ b/hw/block/block.c | ||
50 | @@ -XXX,XX +XXX,XX @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp) | ||
51 | { | ||
52 | BlockBackend *blk = conf->blk; | ||
53 | BlockSizes blocksizes; | ||
54 | - int backend_ret; | ||
55 | + BlockDriverState *bs; | ||
56 | + bool use_blocksizes; | ||
57 | + bool use_bs; | ||
58 | + | ||
59 | + switch (conf->backend_defaults) { | ||
60 | + case ON_OFF_AUTO_AUTO: | ||
61 | + use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes); | ||
62 | + use_bs = false; | ||
63 | + break; | ||
64 | + | ||
65 | + case ON_OFF_AUTO_ON: | ||
66 | + use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes); | ||
67 | + bs = blk_bs(blk); | ||
68 | + use_bs = bs; | ||
69 | + break; | ||
70 | + | ||
71 | + case ON_OFF_AUTO_OFF: | ||
72 | + use_blocksizes = false; | ||
73 | + use_bs = false; | ||
74 | + break; | ||
75 | + | ||
76 | + default: | ||
77 | + abort(); | ||
78 | + } | ||
79 | |||
80 | - backend_ret = blk_probe_blocksizes(blk, &blocksizes); | ||
81 | /* fill in detected values if they are not defined via qemu command line */ | ||
82 | if (!conf->physical_block_size) { | ||
83 | - if (!backend_ret) { | ||
84 | + if (use_blocksizes) { | ||
85 | conf->physical_block_size = blocksizes.phys; | ||
86 | } else { | ||
87 | conf->physical_block_size = BDRV_SECTOR_SIZE; | ||
32 | } | 88 | } |
33 | trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); | 89 | } |
34 | block_job_sleep_ns(&s->common, delay_ns); | 90 | if (!conf->logical_block_size) { |
35 | - if (block_job_is_cancelled(&s->common) && s->common.force) { | 91 | - if (!backend_ret) { |
36 | + if (block_job_is_cancelled(&s->common) && | 92 | + if (use_blocksizes) { |
37 | + (!s->synced || s->common.force)) | 93 | conf->logical_block_size = blocksizes.log; |
38 | + { | 94 | } else { |
39 | break; | 95 | conf->logical_block_size = BDRV_SECTOR_SIZE; |
40 | } | 96 | } |
41 | s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); | 97 | } |
98 | + if (use_bs) { | ||
99 | + if (!conf->opt_io_size) { | ||
100 | + conf->opt_io_size = bs->bl.opt_transfer; | ||
101 | + } | ||
102 | + if (conf->discard_granularity == -1) { | ||
103 | + if (bs->bl.pdiscard_alignment) { | ||
104 | + conf->discard_granularity = bs->bl.pdiscard_alignment; | ||
105 | + } else if (bs->bl.request_alignment != 1) { | ||
106 | + conf->discard_granularity = bs->bl.request_alignment; | ||
107 | + } | ||
108 | + } | ||
109 | + } | ||
110 | |||
111 | if (conf->logical_block_size > conf->physical_block_size) { | ||
112 | error_setg(errp, | ||
113 | diff --git a/tests/qemu-iotests/172.out b/tests/qemu-iotests/172.out | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/tests/qemu-iotests/172.out | ||
116 | +++ b/tests/qemu-iotests/172.out | ||
117 | @@ -XXX,XX +XXX,XX @@ Testing: | ||
118 | dev: floppy, id "" | ||
119 | unit = 0 (0x0) | ||
120 | drive = "floppy0" | ||
121 | + backend_defaults = "auto" | ||
122 | logical_block_size = 512 (512 B) | ||
123 | physical_block_size = 512 (512 B) | ||
124 | min_io_size = 0 (0 B) | ||
125 | @@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 | ||
126 | dev: floppy, id "" | ||
127 | unit = 0 (0x0) | ||
128 | drive = "floppy0" | ||
129 | + backend_defaults = "auto" | ||
130 | logical_block_size = 512 (512 B) | ||
131 | physical_block_size = 512 (512 B) | ||
132 | min_io_size = 0 (0 B) | ||
133 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 | ||
134 | dev: floppy, id "" | ||
135 | unit = 1 (0x1) | ||
136 | drive = "floppy1" | ||
137 | + backend_defaults = "auto" | ||
138 | logical_block_size = 512 (512 B) | ||
139 | physical_block_size = 512 (512 B) | ||
140 | min_io_size = 0 (0 B) | ||
141 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 | ||
142 | dev: floppy, id "" | ||
143 | unit = 0 (0x0) | ||
144 | drive = "floppy0" | ||
145 | + backend_defaults = "auto" | ||
146 | logical_block_size = 512 (512 B) | ||
147 | physical_block_size = 512 (512 B) | ||
148 | min_io_size = 0 (0 B) | ||
149 | @@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2 | ||
150 | dev: floppy, id "" | ||
151 | unit = 1 (0x1) | ||
152 | drive = "floppy1" | ||
153 | + backend_defaults = "auto" | ||
154 | logical_block_size = 512 (512 B) | ||
155 | physical_block_size = 512 (512 B) | ||
156 | min_io_size = 0 (0 B) | ||
157 | @@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2 | ||
158 | dev: floppy, id "" | ||
159 | unit = 0 (0x0) | ||
160 | drive = "floppy0" | ||
161 | + backend_defaults = "auto" | ||
162 | logical_block_size = 512 (512 B) | ||
163 | physical_block_size = 512 (512 B) | ||
164 | min_io_size = 0 (0 B) | ||
165 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb | ||
166 | dev: floppy, id "" | ||
167 | unit = 1 (0x1) | ||
168 | drive = "floppy1" | ||
169 | + backend_defaults = "auto" | ||
170 | logical_block_size = 512 (512 B) | ||
171 | physical_block_size = 512 (512 B) | ||
172 | min_io_size = 0 (0 B) | ||
173 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb | ||
174 | dev: floppy, id "" | ||
175 | unit = 0 (0x0) | ||
176 | drive = "floppy0" | ||
177 | + backend_defaults = "auto" | ||
178 | logical_block_size = 512 (512 B) | ||
179 | physical_block_size = 512 (512 B) | ||
180 | min_io_size = 0 (0 B) | ||
181 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 | ||
182 | dev: floppy, id "" | ||
183 | unit = 0 (0x0) | ||
184 | drive = "floppy0" | ||
185 | + backend_defaults = "auto" | ||
186 | logical_block_size = 512 (512 B) | ||
187 | physical_block_size = 512 (512 B) | ||
188 | min_io_size = 0 (0 B) | ||
189 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2,index=1 | ||
190 | dev: floppy, id "" | ||
191 | unit = 1 (0x1) | ||
192 | drive = "floppy1" | ||
193 | + backend_defaults = "auto" | ||
194 | logical_block_size = 512 (512 B) | ||
195 | physical_block_size = 512 (512 B) | ||
196 | min_io_size = 0 (0 B) | ||
197 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2,index=1 | ||
198 | dev: floppy, id "" | ||
199 | unit = 0 (0x0) | ||
200 | drive = "floppy0" | ||
201 | + backend_defaults = "auto" | ||
202 | logical_block_size = 512 (512 B) | ||
203 | physical_block_size = 512 (512 B) | ||
204 | min_io_size = 0 (0 B) | ||
205 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=floppy,file=TEST_DIR/t | ||
206 | dev: floppy, id "" | ||
207 | unit = 1 (0x1) | ||
208 | drive = "floppy1" | ||
209 | + backend_defaults = "auto" | ||
210 | logical_block_size = 512 (512 B) | ||
211 | physical_block_size = 512 (512 B) | ||
212 | min_io_size = 0 (0 B) | ||
213 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=floppy,file=TEST_DIR/t | ||
214 | dev: floppy, id "" | ||
215 | unit = 0 (0x0) | ||
216 | drive = "floppy0" | ||
217 | + backend_defaults = "auto" | ||
218 | logical_block_size = 512 (512 B) | ||
219 | physical_block_size = 512 (512 B) | ||
220 | min_io_size = 0 (0 B) | ||
221 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0 | ||
222 | dev: floppy, id "" | ||
223 | unit = 0 (0x0) | ||
224 | drive = "none0" | ||
225 | + backend_defaults = "auto" | ||
226 | logical_block_size = 512 (512 B) | ||
227 | physical_block_size = 512 (512 B) | ||
228 | min_io_size = 0 (0 B) | ||
229 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,unit=1 | ||
230 | dev: floppy, id "" | ||
231 | unit = 1 (0x1) | ||
232 | drive = "none0" | ||
233 | + backend_defaults = "auto" | ||
234 | logical_block_size = 512 (512 B) | ||
235 | physical_block_size = 512 (512 B) | ||
236 | min_io_size = 0 (0 B) | ||
237 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco | ||
238 | dev: floppy, id "" | ||
239 | unit = 1 (0x1) | ||
240 | drive = "none1" | ||
241 | + backend_defaults = "auto" | ||
242 | logical_block_size = 512 (512 B) | ||
243 | physical_block_size = 512 (512 B) | ||
244 | min_io_size = 0 (0 B) | ||
245 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco | ||
246 | dev: floppy, id "" | ||
247 | unit = 0 (0x0) | ||
248 | drive = "none0" | ||
249 | + backend_defaults = "auto" | ||
250 | logical_block_size = 512 (512 B) | ||
251 | physical_block_size = 512 (512 B) | ||
252 | min_io_size = 0 (0 B) | ||
253 | @@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
254 | dev: floppy, id "" | ||
255 | unit = 1 (0x1) | ||
256 | drive = "none0" | ||
257 | + backend_defaults = "auto" | ||
258 | logical_block_size = 512 (512 B) | ||
259 | physical_block_size = 512 (512 B) | ||
260 | min_io_size = 0 (0 B) | ||
261 | @@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
262 | dev: floppy, id "" | ||
263 | unit = 0 (0x0) | ||
264 | drive = "floppy0" | ||
265 | + backend_defaults = "auto" | ||
266 | logical_block_size = 512 (512 B) | ||
267 | physical_block_size = 512 (512 B) | ||
268 | min_io_size = 0 (0 B) | ||
269 | @@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
270 | dev: floppy, id "" | ||
271 | unit = 1 (0x1) | ||
272 | drive = "none0" | ||
273 | + backend_defaults = "auto" | ||
274 | logical_block_size = 512 (512 B) | ||
275 | physical_block_size = 512 (512 B) | ||
276 | min_io_size = 0 (0 B) | ||
277 | @@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
278 | dev: floppy, id "" | ||
279 | unit = 0 (0x0) | ||
280 | drive = "floppy0" | ||
281 | + backend_defaults = "auto" | ||
282 | logical_block_size = 512 (512 B) | ||
283 | physical_block_size = 512 (512 B) | ||
284 | min_io_size = 0 (0 B) | ||
285 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
286 | dev: floppy, id "" | ||
287 | unit = 0 (0x0) | ||
288 | drive = "none0" | ||
289 | + backend_defaults = "auto" | ||
290 | logical_block_size = 512 (512 B) | ||
291 | physical_block_size = 512 (512 B) | ||
292 | min_io_size = 0 (0 B) | ||
293 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
294 | dev: floppy, id "" | ||
295 | unit = 1 (0x1) | ||
296 | drive = "floppy1" | ||
297 | + backend_defaults = "auto" | ||
298 | logical_block_size = 512 (512 B) | ||
299 | physical_block_size = 512 (512 B) | ||
300 | min_io_size = 0 (0 B) | ||
301 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
302 | dev: floppy, id "" | ||
303 | unit = 0 (0x0) | ||
304 | drive = "none0" | ||
305 | + backend_defaults = "auto" | ||
306 | logical_block_size = 512 (512 B) | ||
307 | physical_block_size = 512 (512 B) | ||
308 | min_io_size = 0 (0 B) | ||
309 | @@ -XXX,XX +XXX,XX @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl | ||
310 | dev: floppy, id "" | ||
311 | unit = 1 (0x1) | ||
312 | drive = "floppy1" | ||
313 | + backend_defaults = "auto" | ||
314 | logical_block_size = 512 (512 B) | ||
315 | physical_block_size = 512 (512 B) | ||
316 | min_io_size = 0 (0 B) | ||
317 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q | ||
318 | dev: floppy, id "" | ||
319 | unit = 1 (0x1) | ||
320 | drive = "none0" | ||
321 | + backend_defaults = "auto" | ||
322 | logical_block_size = 512 (512 B) | ||
323 | physical_block_size = 512 (512 B) | ||
324 | min_io_size = 0 (0 B) | ||
325 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q | ||
326 | dev: floppy, id "" | ||
327 | unit = 0 (0x0) | ||
328 | drive = "floppy0" | ||
329 | + backend_defaults = "auto" | ||
330 | logical_block_size = 512 (512 B) | ||
331 | physical_block_size = 512 (512 B) | ||
332 | min_io_size = 0 (0 B) | ||
333 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q | ||
334 | dev: floppy, id "" | ||
335 | unit = 1 (0x1) | ||
336 | drive = "none0" | ||
337 | + backend_defaults = "auto" | ||
338 | logical_block_size = 512 (512 B) | ||
339 | physical_block_size = 512 (512 B) | ||
340 | min_io_size = 0 (0 B) | ||
341 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q | ||
342 | dev: floppy, id "" | ||
343 | unit = 0 (0x0) | ||
344 | drive = "floppy0" | ||
345 | + backend_defaults = "auto" | ||
346 | logical_block_size = 512 (512 B) | ||
347 | physical_block_size = 512 (512 B) | ||
348 | min_io_size = 0 (0 B) | ||
349 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -global floppy.drive=none0 -device | ||
350 | dev: floppy, id "" | ||
351 | unit = 0 (0x0) | ||
352 | drive = "none0" | ||
353 | + backend_defaults = "auto" | ||
354 | logical_block_size = 512 (512 B) | ||
355 | physical_block_size = 512 (512 B) | ||
356 | min_io_size = 0 (0 B) | ||
357 | @@ -XXX,XX +XXX,XX @@ Testing: -device floppy | ||
358 | dev: floppy, id "" | ||
359 | unit = 0 (0x0) | ||
360 | drive = "" | ||
361 | + backend_defaults = "auto" | ||
362 | logical_block_size = 512 (512 B) | ||
363 | physical_block_size = 512 (512 B) | ||
364 | min_io_size = 0 (0 B) | ||
365 | @@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=120 | ||
366 | dev: floppy, id "" | ||
367 | unit = 0 (0x0) | ||
368 | drive = "" | ||
369 | + backend_defaults = "auto" | ||
370 | logical_block_size = 512 (512 B) | ||
371 | physical_block_size = 512 (512 B) | ||
372 | min_io_size = 0 (0 B) | ||
373 | @@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=144 | ||
374 | dev: floppy, id "" | ||
375 | unit = 0 (0x0) | ||
376 | drive = "" | ||
377 | + backend_defaults = "auto" | ||
378 | logical_block_size = 512 (512 B) | ||
379 | physical_block_size = 512 (512 B) | ||
380 | min_io_size = 0 (0 B) | ||
381 | @@ -XXX,XX +XXX,XX @@ Testing: -device floppy,drive-type=288 | ||
382 | dev: floppy, id "" | ||
383 | unit = 0 (0x0) | ||
384 | drive = "" | ||
385 | + backend_defaults = "auto" | ||
386 | logical_block_size = 512 (512 B) | ||
387 | physical_block_size = 512 (512 B) | ||
388 | min_io_size = 0 (0 B) | ||
389 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t | ||
390 | dev: floppy, id "" | ||
391 | unit = 0 (0x0) | ||
392 | drive = "none0" | ||
393 | + backend_defaults = "auto" | ||
394 | logical_block_size = 512 (512 B) | ||
395 | physical_block_size = 512 (512 B) | ||
396 | min_io_size = 0 (0 B) | ||
397 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t | ||
398 | dev: floppy, id "" | ||
399 | unit = 0 (0x0) | ||
400 | drive = "none0" | ||
401 | + backend_defaults = "auto" | ||
402 | logical_block_size = 512 (512 B) | ||
403 | physical_block_size = 512 (512 B) | ||
404 | min_io_size = 0 (0 B) | ||
405 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,logical | ||
406 | dev: floppy, id "" | ||
407 | unit = 0 (0x0) | ||
408 | drive = "none0" | ||
409 | + backend_defaults = "auto" | ||
410 | logical_block_size = 512 (512 B) | ||
411 | physical_block_size = 512 (512 B) | ||
412 | min_io_size = 0 (0 B) | ||
413 | @@ -XXX,XX +XXX,XX @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physica | ||
414 | dev: floppy, id "" | ||
415 | unit = 0 (0x0) | ||
416 | drive = "none0" | ||
417 | + backend_defaults = "auto" | ||
418 | logical_block_size = 512 (512 B) | ||
419 | physical_block_size = 512 (512 B) | ||
420 | min_io_size = 0 (0 B) | ||
42 | -- | 421 | -- |
43 | 2.13.6 | 422 | 2.31.1 |
44 | 423 | ||
45 | diff view generated by jsdifflib |
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | 1 | From: Akihiko Odaki <akihiko.odaki@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748 ("block/mirror: change | 3 | Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> |
4 | the semantic of 'force' of block-job-cancel") accidentally removed the | 4 | Message-id: 20210705130458.97642-3-akihiko.odaki@gmail.com |
5 | ratelimit in the mirror job. | 5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
6 | --- | ||
7 | block/io.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
6 | 9 | ||
7 | Reintroduce the ratelimit but keep the block-job-cancel force=true | 10 | diff --git a/block/io.c b/block/io.c |
8 | behavior that was added in commit | 11 | index XXXXXXX..XXXXXXX 100644 |
9 | b76e4458b1eb3c32e9824fe6aa51f67d2b251748. | 12 | --- a/block/io.c |
13 | +++ b/block/io.c | ||
14 | @@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) | ||
15 | |||
16 | static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) | ||
17 | { | ||
18 | + dst->pdiscard_alignment = MAX(dst->pdiscard_alignment, | ||
19 | + src->pdiscard_alignment); | ||
20 | dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer); | ||
21 | dst->max_transfer = MIN_NON_ZERO(dst->max_transfer, src->max_transfer); | ||
22 | dst->max_hw_transfer = MIN_NON_ZERO(dst->max_hw_transfer, | ||
23 | -- | ||
24 | 2.31.1 | ||
10 | 25 | ||
11 | Note that block_job_sleep_ns() returns immediately when the job is | ||
12 | cancelled. Therefore it's safe to unconditionally call | ||
13 | block_job_sleep_ns() - a cancelled job does not sleep. | ||
14 | |||
15 | This commit fixes the non-deterministic qemu-iotests 185 output. The | ||
16 | test relies on the ratelimit to make the job sleep until the 'quit' | ||
17 | command is processed. Previously the job could complete before the | ||
18 | 'quit' command was received since there was no ratelimit. | ||
19 | |||
20 | Cc: Liang Li <liliang.opensource@gmail.com> | ||
21 | Cc: Jeff Cody <jcody@redhat.com> | ||
22 | Cc: Kevin Wolf <kwolf@redhat.com> | ||
23 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
24 | Message-id: 20180424123527.19168-1-stefanha@redhat.com | ||
25 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
26 | --- | ||
27 | block/mirror.c | 8 +++++--- | ||
28 | tests/qemu-iotests/185.out | 4 ++-- | ||
29 | 2 files changed, 7 insertions(+), 5 deletions(-) | ||
30 | |||
31 | diff --git a/block/mirror.c b/block/mirror.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/block/mirror.c | ||
34 | +++ b/block/mirror.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn mirror_run(void *opaque) | ||
36 | } | ||
37 | |||
38 | ret = 0; | ||
39 | + | ||
40 | + if (s->synced && !should_complete) { | ||
41 | + delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); | ||
42 | + } | ||
43 | trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); | ||
44 | + block_job_sleep_ns(&s->common, delay_ns); | ||
45 | if (block_job_is_cancelled(&s->common) && s->common.force) { | ||
46 | break; | ||
47 | - } else if (!should_complete) { | ||
48 | - delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); | ||
49 | - block_job_sleep_ns(&s->common, delay_ns); | ||
50 | } | ||
51 | s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); | ||
52 | } | ||
53 | diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/tests/qemu-iotests/185.out | ||
56 | +++ b/tests/qemu-iotests/185.out | ||
57 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q | ||
58 | {"return": {}} | ||
59 | Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 | ||
60 | {"return": {}} | ||
61 | +{"return": {}} | ||
62 | +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
63 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} | ||
64 | -{"return": {}} | ||
65 | -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} | ||
66 | {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} | ||
67 | |||
68 | === Start backup job and exit qemu === | ||
69 | -- | ||
70 | 2.13.6 | ||
71 | |||
72 | diff view generated by jsdifflib |