1 | The following changes since commit ecc1f5adeec4e3324d1b695a7c54e3967c526949: | 1 | The following changes since commit 711c0418c8c1ce3a24346f058b001c4c5a2f0f81: |
---|---|---|---|
2 | 2 | ||
3 | maintainers: Add myself as linux-user reviewer (2017-05-11 13:31:11 -0400) | 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/stefanha/qemu.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 321d1dba8bef9676a77e9399484e3cd8bf2cf16a: | 9 | for you to fetch changes up to 9f460c64e13897117f35ffb61f6f5e0102cabc70: |
10 | 10 | ||
11 | aio: add missing aio_notify() to aio_enable_external() (2017-05-12 10:36:46 -0400) | 11 | block/io: Merge discard request alignments (2021-07-06 14:28:55 +0100) |
12 | |||
13 | ---------------------------------------------------------------- | ||
14 | Pull request | ||
12 | 15 | ||
13 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
14 | 17 | ||
15 | ---------------------------------------------------------------- | 18 | Akihiko Odaki (3): |
19 | block/file-posix: Optimize for macOS | ||
20 | block: Add backend_defaults property | ||
21 | block/io: Merge discard request alignments | ||
16 | 22 | ||
17 | Daniel P. Berrange (1): | 23 | Stefan Hajnoczi (2): |
18 | coroutine: remove GThread implementation | 24 | util/async: add a human-readable name to BHs for debugging |
25 | util/async: print leaked BH name when AioContext finalizes | ||
19 | 26 | ||
20 | Eric Blake (1): | 27 | include/block/aio.h | 31 ++++++++++++++++++++++--- |
21 | block: Simplify BDRV_BLOCK_RAW recursion | 28 | include/hw/block/block.h | 3 +++ |
22 | 29 | include/qemu/main-loop.h | 4 +++- | |
23 | Stefan Hajnoczi (1): | 30 | block/file-posix.c | 27 ++++++++++++++++++++-- |
24 | aio: add missing aio_notify() to aio_enable_external() | 31 | block/io.c | 2 ++ |
25 | 32 | hw/block/block.c | 42 ++++++++++++++++++++++++++++++---- | |
26 | configure | 19 ++--- | 33 | tests/unit/ptimer-test-stubs.c | 2 +- |
27 | include/block/aio.h | 10 ++- | 34 | util/async.c | 25 ++++++++++++++++---- |
28 | block/io.c | 4 +- | 35 | util/main-loop.c | 4 ++-- |
29 | util/coroutine-gthread.c | 198 ----------------------------------------------- | 36 | tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++ |
30 | .travis.yml | 5 +- | 37 | 10 files changed, 161 insertions(+), 17 deletions(-) |
31 | 5 files changed, 16 insertions(+), 220 deletions(-) | ||
32 | delete mode 100644 util/coroutine-gthread.c | ||
33 | 38 | ||
34 | -- | 39 | -- |
35 | 2.9.3 | 40 | 2.31.1 |
36 | 41 | ||
37 | diff view generated by jsdifflib |
1 | The main loop uses aio_disable_external()/aio_enable_external() to | 1 | It can be difficult to debug issues with BHs in production environments. |
---|---|---|---|
2 | temporarily disable processing of external AioContext clients like | 2 | Although BHs can usually be identified by looking up their ->cb() |
3 | device emulation. | 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. | ||
4 | 6 | ||
5 | This allows monitor commands to quiesce I/O and prevent the guest from | 7 | This patch adds a name to each BH. The name is not unique per instance |
6 | submitting new requests while a monitor command is in progress. | 8 | but differentiates between cb() functions, which is usually enough. It's |
9 | done by changing aio_bh_new() and friends to macros that stringify cb. | ||
7 | 10 | ||
8 | The aio_enable_external() API is currently broken when an IOThread is in | 11 | The next patch will use the name field when reporting leaked BHs. |
9 | aio_poll() waiting for fd activity when the main loop re-enables | ||
10 | external clients. Incrementing ctx->external_disable_cnt does not wake | ||
11 | the IOThread from ppoll(2) so fd processing remains suspended and leads | ||
12 | to unresponsive emulated devices. | ||
13 | 12 | ||
14 | This patch adds an aio_notify() call to aio_enable_external() so the | ||
15 | IOThread is kicked out of ppoll(2) and will re-arm the file descriptors. | ||
16 | |||
17 | The bug can be reproduced as follows: | ||
18 | |||
19 | $ qemu -M accel=kvm -m 1024 \ | ||
20 | -object iothread,id=iothread0 \ | ||
21 | -device virtio-scsi-pci,iothread=iothread0,id=virtio-scsi-pci0 \ | ||
22 | -drive if=none,id=drive0,aio=native,cache=none,format=raw,file=test.img \ | ||
23 | -device scsi-hd,id=scsi-hd0,drive=drive0 \ | ||
24 | -qmp tcp::5555,server,nowait | ||
25 | |||
26 | $ scripts/qmp/qmp-shell localhost:5555 | ||
27 | (qemu) blockdev-snapshot-sync device=drive0 snapshot-file=sn1.qcow2 | ||
28 | mode=absolute-paths format=qcow2 | ||
29 | |||
30 | After blockdev-snapshot-sync completes the SCSI disk will be | ||
31 | unresponsive. This leads to request timeouts inside the guest. | ||
32 | |||
33 | Reported-by: Qianqian Zhu <qizhu@redhat.com> | ||
34 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
35 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
36 | Message-id: 20170508180705.20609-1-stefanha@redhat.com | 14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
37 | Suggested-by: Fam Zheng <famz@redhat.com> | 15 | Message-Id: <20210414200247.917496-2-stefanha@redhat.com> |
38 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
39 | --- | 16 | --- |
40 | include/block/aio.h | 10 ++++++++-- | 17 | include/block/aio.h | 31 ++++++++++++++++++++++++++++--- |
41 | 1 file changed, 8 insertions(+), 2 deletions(-) | 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(-) | ||
42 | 23 | ||
43 | diff --git a/include/block/aio.h b/include/block/aio.h | 24 | diff --git a/include/block/aio.h b/include/block/aio.h |
44 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/include/block/aio.h | 26 | --- a/include/block/aio.h |
46 | +++ b/include/block/aio.h | 27 | +++ b/include/block/aio.h |
47 | @@ -XXX,XX +XXX,XX @@ static inline void aio_disable_external(AioContext *ctx) | 28 | @@ -XXX,XX +XXX,XX @@ void aio_context_acquire(AioContext *ctx); |
29 | /* Relinquish ownership of the AioContext. */ | ||
30 | void aio_context_release(AioContext *ctx); | ||
31 | |||
32 | +/** | ||
33 | + * aio_bh_schedule_oneshot_full: Allocate a new bottom half structure that will | ||
34 | + * run only once and as soon as possible. | ||
35 | + * | ||
36 | + * @name: A human-readable identifier for debugging purposes. | ||
37 | + */ | ||
38 | +void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, | ||
39 | + const char *name); | ||
40 | + | ||
41 | /** | ||
42 | * aio_bh_schedule_oneshot: Allocate a new bottom half structure that will run | ||
43 | * only once and as soon as possible. | ||
44 | + * | ||
45 | + * A convenience wrapper for aio_bh_schedule_oneshot_full() that uses cb as the | ||
46 | + * name string. | ||
48 | */ | 47 | */ |
49 | static inline void aio_enable_external(AioContext *ctx) | 48 | -void aio_bh_schedule_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque); |
49 | +#define aio_bh_schedule_oneshot(ctx, cb, opaque) \ | ||
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; | ||
98 | } | ||
99 | |||
100 | -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) | ||
101 | +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name) | ||
50 | { | 102 | { |
51 | - assert(ctx->external_disable_cnt > 0); | 103 | QEMUBH *bh = g_new(QEMUBH, 1); |
52 | - atomic_dec(&ctx->external_disable_cnt); | 104 | |
53 | + int old; | 105 | diff --git a/util/async.c b/util/async.c |
54 | + | 106 | index XXXXXXX..XXXXXXX 100644 |
55 | + old = atomic_fetch_dec(&ctx->external_disable_cnt); | 107 | --- a/util/async.c |
56 | + assert(old > 0); | 108 | +++ b/util/async.c |
57 | + if (old == 1) { | 109 | @@ -XXX,XX +XXX,XX @@ enum { |
58 | + /* Kick event loop so it re-arms file descriptors */ | 110 | |
59 | + aio_notify(ctx); | 111 | struct QEMUBH { |
60 | + } | 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; | ||
61 | } | 119 | } |
62 | 120 | ||
63 | /** | 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 | /* | ||
64 | -- | 166 | -- |
65 | 2.9.3 | 167 | 2.31.1 |
66 | 168 | ||
67 | 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 |
New patch | |||
---|---|---|---|
1 | From: Akihiko Odaki <akihiko.odaki@gmail.com> | ||
1 | 2 | ||
3 | This commit introduces "punch hole" operation and optimizes transfer | ||
4 | block size for macOS. | ||
5 | |||
6 | Thanks to Konstantin Nazarov for detailed analysis of a flaw in an | ||
7 | old version of this change: | ||
8 | https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3654667 | ||
9 | |||
10 | Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> | ||
11 | Message-id: 20210705130458.97642-1-akihiko.odaki@gmail.com | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | --- | ||
14 | block/file-posix.c | 27 +++++++++++++++++++++++++-- | ||
15 | 1 file changed, 25 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/block/file-posix.c b/block/file-posix.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/block/file-posix.c | ||
20 | +++ b/block/file-posix.c | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #if defined(HAVE_HOST_BLOCK_DEVICE) | ||
23 | #include <paths.h> | ||
24 | #include <sys/param.h> | ||
25 | +#include <sys/mount.h> | ||
26 | #include <IOKit/IOKitLib.h> | ||
27 | #include <IOKit/IOBSD.h> | ||
28 | #include <IOKit/storage/IOMediaBSDClient.h> | ||
29 | @@ -XXX,XX +XXX,XX @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) | ||
30 | return; | ||
31 | } | ||
32 | |||
33 | +#if defined(__APPLE__) && (__MACH__) | ||
34 | + struct statfs buf; | ||
35 | + | ||
36 | + if (!fstatfs(s->fd, &buf)) { | ||
37 | + bs->bl.opt_transfer = buf.f_iosize; | ||
38 | + bs->bl.pdiscard_alignment = buf.f_bsize; | ||
39 | + } | ||
40 | +#endif | ||
41 | + | ||
42 | if (bs->sg || S_ISBLK(st.st_mode)) { | ||
43 | int ret = hdev_get_max_hw_transfer(s->fd, &st); | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ out: | ||
46 | } | ||
47 | } | ||
48 | |||
49 | +#if defined(CONFIG_FALLOCATE) || defined(BLKZEROOUT) || defined(BLKDISCARD) | ||
50 | static int translate_err(int err) | ||
51 | { | ||
52 | if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP || | ||
53 | @@ -XXX,XX +XXX,XX @@ static int translate_err(int err) | ||
54 | } | ||
55 | return err; | ||
56 | } | ||
57 | +#endif | ||
58 | |||
59 | #ifdef CONFIG_FALLOCATE | ||
60 | static int do_fallocate(int fd, int mode, off_t offset, off_t len) | ||
61 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque) | ||
62 | } | ||
63 | } while (errno == EINTR); | ||
64 | |||
65 | - ret = -errno; | ||
66 | + ret = translate_err(-errno); | ||
67 | #endif | ||
68 | } else { | ||
69 | #ifdef CONFIG_FALLOCATE_PUNCH_HOLE | ||
70 | ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, | ||
71 | aiocb->aio_offset, aiocb->aio_nbytes); | ||
72 | + ret = translate_err(-errno); | ||
73 | +#elif defined(__APPLE__) && (__MACH__) | ||
74 | + fpunchhole_t fpunchhole; | ||
75 | + fpunchhole.fp_flags = 0; | ||
76 | + fpunchhole.reserved = 0; | ||
77 | + fpunchhole.fp_offset = aiocb->aio_offset; | ||
78 | + fpunchhole.fp_length = aiocb->aio_nbytes; | ||
79 | + if (fcntl(s->fd, F_PUNCHHOLE, &fpunchhole) == -1) { | ||
80 | + ret = errno == ENODEV ? -ENOTSUP : -errno; | ||
81 | + } else { | ||
82 | + ret = 0; | ||
83 | + } | ||
84 | #endif | ||
85 | } | ||
86 | |||
87 | - ret = translate_err(ret); | ||
88 | if (ret == -ENOTSUP) { | ||
89 | s->has_discard = false; | ||
90 | } | ||
91 | -- | ||
92 | 2.31.1 | ||
93 | diff view generated by jsdifflib |
1 | From: "Daniel P. Berrange" <berrange@redhat.com> | 1 | From: Akihiko Odaki <akihiko.odaki@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | The GThread implementation is not functional enough to actually | 3 | backend_defaults property allow users to control if default block |
4 | run QEMU reliably. While it was potentially useful for debugging, | 4 | properties should be decided with backend information. |
5 | we have a scripts/qemugdb/coroutine.py to enable tracing of | 5 | |
6 | ucontext coroutines in GDB, so that removes the only reason for | 6 | If it is off, any backend information will be discarded, which is |
7 | GThread to exist. | 7 | suitable if you plan to perform live migration to a different disk backend. |
8 | 8 | ||
9 | Signed-off-by: Daniel P. Berrange <berrange@redhat.com> | 9 | If it is on, a block device may utilize backend information more |
10 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | 10 | aggressively. |
11 | |||
12 | By default, it is auto, which uses backend information for block | ||
13 | sizes and ignores the others, which is consistent with the older | ||
14 | versions. | ||
15 | |||
16 | Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> | ||
17 | Message-id: 20210705130458.97642-2-akihiko.odaki@gmail.com | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
12 | --- | 19 | --- |
13 | configure | 19 ++--- | 20 | include/hw/block/block.h | 3 +++ |
14 | util/coroutine-gthread.c | 198 ----------------------------------------------- | 21 | hw/block/block.c | 42 ++++++++++++++++++++++++++++++++++---- |
15 | .travis.yml | 5 +- | 22 | tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++++++ |
16 | 3 files changed, 6 insertions(+), 216 deletions(-) | 23 | 3 files changed, 79 insertions(+), 4 deletions(-) |
17 | delete mode 100644 util/coroutine-gthread.c | 24 | |
18 | 25 | diff --git a/include/hw/block/block.h b/include/hw/block/block.h | |
19 | diff --git a/configure b/configure | 26 | index XXXXXXX..XXXXXXX 100644 |
20 | index XXXXXXX..XXXXXXX 100755 | 27 | --- a/include/hw/block/block.h |
21 | --- a/configure | 28 | +++ b/include/hw/block/block.h |
22 | +++ b/configure | ||
23 | @@ -XXX,XX +XXX,XX @@ Advanced options (experts only): | ||
24 | --oss-lib path to OSS library | ||
25 | --cpu=CPU Build for host CPU [$cpu] | ||
26 | --with-coroutine=BACKEND coroutine backend. Supported options: | ||
27 | - gthread, ucontext, sigaltstack, windows | ||
28 | + ucontext, sigaltstack, windows | ||
29 | --enable-gcov enable test coverage analysis with gcov | ||
30 | --gcov=GCOV use specified gcov [$gcov_tool] | ||
31 | --disable-blobs disable installing provided firmware blobs | ||
32 | @@ -XXX,XX +XXX,XX @@ fi | ||
33 | # check and set a backend for coroutine | ||
34 | |||
35 | # We prefer ucontext, but it's not always possible. The fallback | ||
36 | -# is sigcontext. gthread is not selectable except explicitly, because | ||
37 | -# it is not functional enough to run QEMU proper. (It is occasionally | ||
38 | -# useful for debugging purposes.) On Windows the only valid backend | ||
39 | -# is the Windows-specific one. | ||
40 | +# is sigcontext. On Windows the only valid backend is the Windows | ||
41 | +# specific one. | ||
42 | |||
43 | ucontext_works=no | ||
44 | if test "$darwin" != "yes"; then | ||
45 | @@ -XXX,XX +XXX,XX @@ else | ||
46 | feature_not_found "ucontext" | ||
47 | fi | ||
48 | ;; | ||
49 | - gthread|sigaltstack) | ||
50 | + sigaltstack) | ||
51 | if test "$mingw32" = "yes"; then | ||
52 | error_exit "only the 'windows' coroutine backend is valid for Windows" | ||
53 | fi | ||
54 | @@ -XXX,XX +XXX,XX @@ else | ||
55 | fi | ||
56 | |||
57 | if test "$coroutine_pool" = ""; then | ||
58 | - if test "$coroutine" = "gthread"; then | ||
59 | - coroutine_pool=no | ||
60 | - else | ||
61 | - coroutine_pool=yes | ||
62 | - fi | ||
63 | -fi | ||
64 | -if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then | ||
65 | - error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)" | ||
66 | + coroutine_pool=yes | ||
67 | fi | ||
68 | |||
69 | if test "$debug_stack_usage" = "yes"; then | ||
70 | diff --git a/util/coroutine-gthread.c b/util/coroutine-gthread.c | ||
71 | deleted file mode 100644 | ||
72 | index XXXXXXX..XXXXXXX | ||
73 | --- a/util/coroutine-gthread.c | ||
74 | +++ /dev/null | ||
75 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ |
76 | -/* | 30 | |
77 | - * GThread coroutine initialization code | 31 | typedef struct BlockConf { |
78 | - * | 32 | BlockBackend *blk; |
79 | - * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> | 33 | + OnOffAuto backend_defaults; |
80 | - * Copyright (C) 2011 Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 34 | uint32_t physical_block_size; |
81 | - * | 35 | uint32_t logical_block_size; |
82 | - * This library is free software; you can redistribute it and/or | 36 | uint32_t min_io_size; |
83 | - * modify it under the terms of the GNU Lesser General Public | 37 | @@ -XXX,XX +XXX,XX @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) |
84 | - * License as published by the Free Software Foundation; either | 38 | } |
85 | - * version 2.0 of the License, or (at your option) any later version. | 39 | |
86 | - * | 40 | #define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) \ |
87 | - * This library is distributed in the hope that it will be useful, | 41 | + DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state, \ |
88 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | 42 | + _conf.backend_defaults, ON_OFF_AUTO_AUTO), \ |
89 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 43 | DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \ |
90 | - * Lesser General Public License for more details. | 44 | _conf.logical_block_size), \ |
91 | - * | 45 | DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \ |
92 | - * You should have received a copy of the GNU Lesser General Public | 46 | diff --git a/hw/block/block.c b/hw/block/block.c |
93 | - * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
94 | - */ | ||
95 | - | ||
96 | -#include "qemu/osdep.h" | ||
97 | -#include "qemu-common.h" | ||
98 | -#include "qemu/coroutine_int.h" | ||
99 | - | ||
100 | -typedef struct { | ||
101 | - Coroutine base; | ||
102 | - GThread *thread; | ||
103 | - bool runnable; | ||
104 | - bool free_on_thread_exit; | ||
105 | - CoroutineAction action; | ||
106 | -} CoroutineGThread; | ||
107 | - | ||
108 | -static CompatGMutex coroutine_lock; | ||
109 | -static CompatGCond coroutine_cond; | ||
110 | - | ||
111 | -/* GLib 2.31 and beyond deprecated various parts of the thread API, | ||
112 | - * but the new interfaces are not available in older GLib versions | ||
113 | - * so we have to cope with both. | ||
114 | - */ | ||
115 | -#if GLIB_CHECK_VERSION(2, 31, 0) | ||
116 | -/* Awkwardly, the GPrivate API doesn't provide a way to update the | ||
117 | - * GDestroyNotify handler for the coroutine key dynamically. So instead | ||
118 | - * we track whether or not the CoroutineGThread should be freed on | ||
119 | - * thread exit / coroutine key update using the free_on_thread_exit | ||
120 | - * field. | ||
121 | - */ | ||
122 | -static void coroutine_destroy_notify(gpointer data) | ||
123 | -{ | ||
124 | - CoroutineGThread *co = data; | ||
125 | - if (co && co->free_on_thread_exit) { | ||
126 | - g_free(co); | ||
127 | - } | ||
128 | -} | ||
129 | - | ||
130 | -static GPrivate coroutine_key = G_PRIVATE_INIT(coroutine_destroy_notify); | ||
131 | - | ||
132 | -static inline CoroutineGThread *get_coroutine_key(void) | ||
133 | -{ | ||
134 | - return g_private_get(&coroutine_key); | ||
135 | -} | ||
136 | - | ||
137 | -static inline void set_coroutine_key(CoroutineGThread *co, | ||
138 | - bool free_on_thread_exit) | ||
139 | -{ | ||
140 | - /* Unlike g_static_private_set() this does not call the GDestroyNotify | ||
141 | - * if the previous value of the key was NULL. Fortunately we only need | ||
142 | - * the GDestroyNotify in the non-NULL key case. | ||
143 | - */ | ||
144 | - co->free_on_thread_exit = free_on_thread_exit; | ||
145 | - g_private_replace(&coroutine_key, co); | ||
146 | -} | ||
147 | - | ||
148 | -static inline GThread *create_thread(GThreadFunc func, gpointer data) | ||
149 | -{ | ||
150 | - return g_thread_new("coroutine", func, data); | ||
151 | -} | ||
152 | - | ||
153 | -#else | ||
154 | - | ||
155 | -/* Handle older GLib versions */ | ||
156 | - | ||
157 | -static GStaticPrivate coroutine_key = G_STATIC_PRIVATE_INIT; | ||
158 | - | ||
159 | -static inline CoroutineGThread *get_coroutine_key(void) | ||
160 | -{ | ||
161 | - return g_static_private_get(&coroutine_key); | ||
162 | -} | ||
163 | - | ||
164 | -static inline void set_coroutine_key(CoroutineGThread *co, | ||
165 | - bool free_on_thread_exit) | ||
166 | -{ | ||
167 | - g_static_private_set(&coroutine_key, co, | ||
168 | - free_on_thread_exit ? (GDestroyNotify)g_free : NULL); | ||
169 | -} | ||
170 | - | ||
171 | -static inline GThread *create_thread(GThreadFunc func, gpointer data) | ||
172 | -{ | ||
173 | - return g_thread_create_full(func, data, 0, TRUE, TRUE, | ||
174 | - G_THREAD_PRIORITY_NORMAL, NULL); | ||
175 | -} | ||
176 | - | ||
177 | -#endif | ||
178 | - | ||
179 | - | ||
180 | -static void __attribute__((constructor)) coroutine_init(void) | ||
181 | -{ | ||
182 | -#if !GLIB_CHECK_VERSION(2, 31, 0) | ||
183 | - if (!g_thread_supported()) { | ||
184 | - g_thread_init(NULL); | ||
185 | - } | ||
186 | -#endif | ||
187 | -} | ||
188 | - | ||
189 | -static void coroutine_wait_runnable_locked(CoroutineGThread *co) | ||
190 | -{ | ||
191 | - while (!co->runnable) { | ||
192 | - g_cond_wait(&coroutine_cond, &coroutine_lock); | ||
193 | - } | ||
194 | -} | ||
195 | - | ||
196 | -static void coroutine_wait_runnable(CoroutineGThread *co) | ||
197 | -{ | ||
198 | - g_mutex_lock(&coroutine_lock); | ||
199 | - coroutine_wait_runnable_locked(co); | ||
200 | - g_mutex_unlock(&coroutine_lock); | ||
201 | -} | ||
202 | - | ||
203 | -static gpointer coroutine_thread(gpointer opaque) | ||
204 | -{ | ||
205 | - CoroutineGThread *co = opaque; | ||
206 | - | ||
207 | - set_coroutine_key(co, false); | ||
208 | - coroutine_wait_runnable(co); | ||
209 | - co->base.entry(co->base.entry_arg); | ||
210 | - qemu_coroutine_switch(&co->base, co->base.caller, COROUTINE_TERMINATE); | ||
211 | - return NULL; | ||
212 | -} | ||
213 | - | ||
214 | -Coroutine *qemu_coroutine_new(void) | ||
215 | -{ | ||
216 | - CoroutineGThread *co; | ||
217 | - | ||
218 | - co = g_malloc0(sizeof(*co)); | ||
219 | - co->thread = create_thread(coroutine_thread, co); | ||
220 | - if (!co->thread) { | ||
221 | - g_free(co); | ||
222 | - return NULL; | ||
223 | - } | ||
224 | - return &co->base; | ||
225 | -} | ||
226 | - | ||
227 | -void qemu_coroutine_delete(Coroutine *co_) | ||
228 | -{ | ||
229 | - CoroutineGThread *co = DO_UPCAST(CoroutineGThread, base, co_); | ||
230 | - | ||
231 | - g_thread_join(co->thread); | ||
232 | - g_free(co); | ||
233 | -} | ||
234 | - | ||
235 | -CoroutineAction qemu_coroutine_switch(Coroutine *from_, | ||
236 | - Coroutine *to_, | ||
237 | - CoroutineAction action) | ||
238 | -{ | ||
239 | - CoroutineGThread *from = DO_UPCAST(CoroutineGThread, base, from_); | ||
240 | - CoroutineGThread *to = DO_UPCAST(CoroutineGThread, base, to_); | ||
241 | - | ||
242 | - g_mutex_lock(&coroutine_lock); | ||
243 | - from->runnable = false; | ||
244 | - from->action = action; | ||
245 | - to->runnable = true; | ||
246 | - to->action = action; | ||
247 | - g_cond_broadcast(&coroutine_cond); | ||
248 | - | ||
249 | - if (action != COROUTINE_TERMINATE) { | ||
250 | - coroutine_wait_runnable_locked(from); | ||
251 | - } | ||
252 | - g_mutex_unlock(&coroutine_lock); | ||
253 | - return from->action; | ||
254 | -} | ||
255 | - | ||
256 | -Coroutine *qemu_coroutine_self(void) | ||
257 | -{ | ||
258 | - CoroutineGThread *co = get_coroutine_key(); | ||
259 | - if (!co) { | ||
260 | - co = g_malloc0(sizeof(*co)); | ||
261 | - co->runnable = true; | ||
262 | - set_coroutine_key(co, true); | ||
263 | - } | ||
264 | - | ||
265 | - return &co->base; | ||
266 | -} | ||
267 | - | ||
268 | -bool qemu_in_coroutine(void) | ||
269 | -{ | ||
270 | - CoroutineGThread *co = get_coroutine_key(); | ||
271 | - | ||
272 | - return co && co->base.caller; | ||
273 | -} | ||
274 | diff --git a/.travis.yml b/.travis.yml | ||
275 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
276 | --- a/.travis.yml | 48 | --- a/hw/block/block.c |
277 | +++ b/.travis.yml | 49 | +++ b/hw/block/block.c |
278 | @@ -XXX,XX +XXX,XX @@ matrix: | 50 | @@ -XXX,XX +XXX,XX @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp) |
279 | - env: CONFIG="--enable-trace-backends=ust" | 51 | { |
280 | TEST_CMD="" | 52 | BlockBackend *blk = conf->blk; |
281 | compiler: gcc | 53 | BlockSizes blocksizes; |
282 | - - env: CONFIG="--with-coroutine=gthread" | 54 | - int backend_ret; |
283 | - TEST_CMD="" | 55 | + BlockDriverState *bs; |
284 | - compiler: gcc | 56 | + bool use_blocksizes; |
285 | - env: CONFIG="" | 57 | + bool use_bs; |
286 | os: osx | 58 | + |
287 | compiler: clang | 59 | + switch (conf->backend_defaults) { |
288 | @@ -XXX,XX +XXX,XX @@ matrix: | 60 | + case ON_OFF_AUTO_AUTO: |
289 | compiler: none | 61 | + use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes); |
290 | env: | 62 | + use_bs = false; |
291 | - COMPILER_NAME=gcc CXX=g++-5 CC=gcc-5 | 63 | + break; |
292 | - - CONFIG="--cc=gcc-5 --cxx=g++-5 --disable-pie --disable-linux-user --with-coroutine=gthread" | 64 | + |
293 | + - CONFIG="--cc=gcc-5 --cxx=g++-5 --disable-pie --disable-linux-user" | 65 | + case ON_OFF_AUTO_ON: |
294 | - TEST_CMD="" | 66 | + use_blocksizes = !blk_probe_blocksizes(blk, &blocksizes); |
295 | before_script: | 67 | + bs = blk_bs(blk); |
296 | - ./configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread -fuse-ld=gold" || cat config.log | 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; | ||
88 | } | ||
89 | } | ||
90 | if (!conf->logical_block_size) { | ||
91 | - if (!backend_ret) { | ||
92 | + if (use_blocksizes) { | ||
93 | conf->logical_block_size = blocksizes.log; | ||
94 | } else { | ||
95 | conf->logical_block_size = BDRV_SECTOR_SIZE; | ||
96 | } | ||
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) | ||
297 | -- | 421 | -- |
298 | 2.9.3 | 422 | 2.31.1 |
299 | 423 | ||
300 | diff view generated by jsdifflib |
1 | From: Eric Blake <eblake@redhat.com> | 1 | From: Akihiko Odaki <akihiko.odaki@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Since we are already in coroutine context during the body of | 3 | Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> |
4 | bdrv_co_get_block_status(), we can shave off a few layers of | 4 | Message-id: 20210705130458.97642-3-akihiko.odaki@gmail.com |
5 | wrappers when recursing to query the protocol when a format driver | ||
6 | returned BDRV_BLOCK_RAW. | ||
7 | |||
8 | Note that we are already using the correct recursion later on in | ||
9 | the same function, when probing whether the protocol layer is sparse | ||
10 | in order to find out if we can add BDRV_BLOCK_ZERO to an existing | ||
11 | BDRV_BLOCK_DATA|BDRV_BLOCK_OFFSET_VALID. | ||
12 | |||
13 | Signed-off-by: Eric Blake <eblake@redhat.com> | ||
14 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
15 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
16 | Message-id: 20170504173745.27414-1-eblake@redhat.com | ||
17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
18 | --- | 6 | --- |
19 | block/io.c | 4 ++-- | 7 | block/io.c | 2 ++ |
20 | 1 file changed, 2 insertions(+), 2 deletions(-) | 8 | 1 file changed, 2 insertions(+) |
21 | 9 | ||
22 | diff --git a/block/io.c b/block/io.c | 10 | diff --git a/block/io.c b/block/io.c |
23 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/block/io.c | 12 | --- a/block/io.c |
25 | +++ b/block/io.c | 13 | +++ b/block/io.c |
26 | @@ -XXX,XX +XXX,XX @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, | 14 | @@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) |
27 | 15 | ||
28 | if (ret & BDRV_BLOCK_RAW) { | 16 | static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) |
29 | assert(ret & BDRV_BLOCK_OFFSET_VALID); | 17 | { |
30 | - ret = bdrv_get_block_status(*file, ret >> BDRV_SECTOR_BITS, | 18 | + dst->pdiscard_alignment = MAX(dst->pdiscard_alignment, |
31 | - *pnum, pnum, file); | 19 | + src->pdiscard_alignment); |
32 | + ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, | 20 | dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer); |
33 | + *pnum, pnum, file); | 21 | dst->max_transfer = MIN_NON_ZERO(dst->max_transfer, src->max_transfer); |
34 | goto out; | 22 | dst->max_hw_transfer = MIN_NON_ZERO(dst->max_hw_transfer, |
35 | } | ||
36 | |||
37 | -- | 23 | -- |
38 | 2.9.3 | 24 | 2.31.1 |
39 | 25 | ||
40 | diff view generated by jsdifflib |