1
The following changes since commit 508ba0f7e2092d3ca56e3f75e894d52d8b94818e:
1
The following changes since commit 711c0418c8c1ce3a24346f058b001c4c5a2f0f81:
2
2
3
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20171109' into staging (2017-11-13 11:41:47 +0000)
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 0761562687e0d8135310a94b1d3e08376387c027:
9
for you to fetch changes up to 9f460c64e13897117f35ffb61f6f5e0102cabc70:
10
10
11
qemu-iotests: Test I/O limits with removable media (2017-11-13 15:46:26 +0000)
11
block/io: Merge discard request alignments (2021-07-06 14:28:55 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Pull request
15
15
16
The following disk I/O throttling fixes solve recent bugs.
17
18
----------------------------------------------------------------
16
----------------------------------------------------------------
19
17
20
Alberto Garcia (3):
18
Akihiko Odaki (3):
21
block: Check for inserted BlockDriverState in blk_io_limits_disable()
19
block/file-posix: Optimize for macOS
22
block: Leave valid throttle timers when removing a BDS from a backend
20
block: Add backend_defaults property
23
qemu-iotests: Test I/O limits with removable media
21
block/io: Merge discard request alignments
24
22
25
Stefan Hajnoczi (1):
23
Stefan Hajnoczi (2):
26
throttle-groups: drain before detaching ThrottleState
24
util/async: add a human-readable name to BHs for debugging
25
util/async: print leaked BH name when AioContext finalizes
27
26
28
Zhengui (1):
27
include/block/aio.h | 31 ++++++++++++++++++++++---
29
block: all I/O should be completed before removing throttle timers.
28
include/hw/block/block.h | 3 +++
30
29
include/qemu/main-loop.h | 4 +++-
31
block/block-backend.c | 36 ++++++++++++++++++---------
30
block/file-posix.c | 27 ++++++++++++++++++++--
32
block/throttle-groups.c | 6 +++++
31
block/io.c | 2 ++
33
tests/qemu-iotests/093 | 62 ++++++++++++++++++++++++++++++++++++++++++++++
32
hw/block/block.c | 42 ++++++++++++++++++++++++++++++----
34
tests/qemu-iotests/093.out | 4 +--
33
tests/unit/ptimer-test-stubs.c | 2 +-
35
4 files changed, 94 insertions(+), 14 deletions(-)
34
util/async.c | 25 ++++++++++++++++----
35
util/main-loop.c | 4 ++--
36
tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++
37
10 files changed, 161 insertions(+), 17 deletions(-)
36
38
37
--
39
--
38
2.13.6
40
2.31.1
39
41
40
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.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
This test hotplugs a CD drive to a VM and checks that I/O limits can
7
This patch adds a name to each BH. The name is not unique per instance
4
be set only when the drive has media inserted and that they are kept
8
but differentiates between cb() functions, which is usually enough. It's
5
when the media is replaced.
9
done by changing aio_bh_new() and friends to macros that stringify cb.
6
10
7
This also tests the removal of a device with valid I/O limits set but
11
The next patch will use the name field when reporting leaked BHs.
8
no media inserted. This involves deleting and disabling the limits
9
of a BlockBackend without BlockDriverState, a scenario that has been
10
crashing until the fixes from the last couple of patches.
11
12
12
[Python PEP8 fixup: "Don't use spaces are the = sign when used to
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
indicate a keyword argument or a default parameter value"
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
--Stefan]
15
Message-Id: <20210414200247.917496-2-stefanha@redhat.com>
16
---
17
include/block/aio.h | 31 ++++++++++++++++++++++++++++---
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(-)
15
23
16
Signed-off-by: Alberto Garcia <berto@igalia.com>
24
diff --git a/include/block/aio.h b/include/block/aio.h
17
Reviewed-by: Max Reitz <mreitz@redhat.com>
25
index XXXXXXX..XXXXXXX 100644
18
Message-id: 071eb397118ed207c5a7f01d58766e415ee18d6a.1510339534.git.berto@igalia.com
26
--- a/include/block/aio.h
19
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
27
+++ b/include/block/aio.h
20
---
28
@@ -XXX,XX +XXX,XX @@ void aio_context_acquire(AioContext *ctx);
21
tests/qemu-iotests/093 | 62 ++++++++++++++++++++++++++++++++++++++++++++++
29
/* Relinquish ownership of the AioContext. */
22
tests/qemu-iotests/093.out | 4 +--
30
void aio_context_release(AioContext *ctx);
23
2 files changed, 64 insertions(+), 2 deletions(-)
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.
47
*/
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)
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
/*
166
--
167
2.31.1
24
168
25
diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
26
index XXXXXXX..XXXXXXX 100755
27
--- a/tests/qemu-iotests/093
28
+++ b/tests/qemu-iotests/093
29
@@ -XXX,XX +XXX,XX @@ class ThrottleTestGroupNames(iotests.QMPTestCase):
30
groupname = "group%d" % i
31
self.verify_name(devname, groupname)
32
33
+class ThrottleTestRemovableMedia(iotests.QMPTestCase):
34
+ def setUp(self):
35
+ self.vm = iotests.VM()
36
+ if iotests.qemu_default_machine == 's390-ccw-virtio':
37
+ self.vm.add_device("virtio-scsi-ccw,id=virtio-scsi")
38
+ else:
39
+ self.vm.add_device("virtio-scsi-pci,id=virtio-scsi")
40
+ self.vm.launch()
41
+
42
+ def tearDown(self):
43
+ self.vm.shutdown()
44
+
45
+ def test_removable_media(self):
46
+ # Add a couple of dummy nodes named cd0 and cd1
47
+ result = self.vm.qmp("blockdev-add", driver="null-aio",
48
+ node_name="cd0")
49
+ self.assert_qmp(result, 'return', {})
50
+ result = self.vm.qmp("blockdev-add", driver="null-aio",
51
+ node_name="cd1")
52
+ self.assert_qmp(result, 'return', {})
53
+
54
+ # Attach a CD drive with cd0 inserted
55
+ result = self.vm.qmp("device_add", driver="scsi-cd",
56
+ id="dev0", drive="cd0")
57
+ self.assert_qmp(result, 'return', {})
58
+
59
+ # Set I/O limits
60
+ args = { "id": "dev0", "iops": 100, "iops_rd": 0, "iops_wr": 0,
61
+ "bps": 50, "bps_rd": 0, "bps_wr": 0 }
62
+ result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args)
63
+ self.assert_qmp(result, 'return', {})
64
+
65
+ # Check that the I/O limits have been set
66
+ result = self.vm.qmp("query-block")
67
+ self.assert_qmp(result, 'return[0]/inserted/iops', 100)
68
+ self.assert_qmp(result, 'return[0]/inserted/bps', 50)
69
+
70
+ # Now eject cd0 and insert cd1
71
+ result = self.vm.qmp("blockdev-open-tray", id='dev0')
72
+ self.assert_qmp(result, 'return', {})
73
+ result = self.vm.qmp("x-blockdev-remove-medium", id='dev0')
74
+ self.assert_qmp(result, 'return', {})
75
+ result = self.vm.qmp("x-blockdev-insert-medium", id='dev0', node_name='cd1')
76
+ self.assert_qmp(result, 'return', {})
77
+
78
+ # Check that the I/O limits are still the same
79
+ result = self.vm.qmp("query-block")
80
+ self.assert_qmp(result, 'return[0]/inserted/iops', 100)
81
+ self.assert_qmp(result, 'return[0]/inserted/bps', 50)
82
+
83
+ # Eject cd1
84
+ result = self.vm.qmp("x-blockdev-remove-medium", id='dev0')
85
+ self.assert_qmp(result, 'return', {})
86
+
87
+ # Check that we can't set limits if the device has no medium
88
+ result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **args)
89
+ self.assert_qmp(result, 'error/class', 'GenericError')
90
+
91
+ # Remove the CD drive
92
+ result = self.vm.qmp("device_del", id='dev0')
93
+ self.assert_qmp(result, 'return', {})
94
+
95
96
if __name__ == '__main__':
97
iotests.main(supported_fmts=["raw"])
98
diff --git a/tests/qemu-iotests/093.out b/tests/qemu-iotests/093.out
99
index XXXXXXX..XXXXXXX 100644
100
--- a/tests/qemu-iotests/093.out
101
+++ b/tests/qemu-iotests/093.out
102
@@ -XXX,XX +XXX,XX @@
103
-.......
104
+........
105
----------------------------------------------------------------------
106
-Ran 7 tests
107
+Ran 8 tests
108
109
OK
110
--
111
2.13.6
112
113
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
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.
2
5
3
When you set I/O limits using block_set_io_throttle or the command
6
Unfortunately the assert(flags & BH_DELETED) call in aio_ctx_finalize()
4
line throttling.* options they are kept in the BlockBackend regardless
7
is difficult to debug because the assertion failure contains no
5
of whether a BlockDriverState is attached to the backend or not.
8
information about the BH!
6
9
7
Therefore when removing the limits using blk_io_limits_disable() we
10
Use the QEMUBH name field added in the previous patch to show a useful
8
need to check if there's a BDS before attempting to drain it, else it
11
error when a leaked BH is detected.
9
will crash QEMU. This can be reproduced very easily using HMP:
10
12
11
(qemu) drive_add 0 if=none,throttling.iops-total=5000
13
Suggested-by: Eric Ernst <eric.g.ernst@gmail.com>
12
(qemu) drive_del none0
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(-)
13
19
14
Reported-by: sochin jiang <sochin.jiang@huawei.com>
20
diff --git a/util/async.c b/util/async.c
15
Signed-off-by: Alberto Garcia <berto@igalia.com>
21
index XXXXXXX..XXXXXXX 100644
16
Reviewed-by: Max Reitz <mreitz@redhat.com>
22
--- a/util/async.c
17
Message-id: 0d3a67ce8d948bb33e08672564714dcfb76a3d8c.1510339534.git.berto@igalia.com
23
+++ b/util/async.c
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
@@ -XXX,XX +XXX,XX @@ aio_ctx_finalize(GSource *source)
19
---
25
assert(QSIMPLEQ_EMPTY(&ctx->bh_slice_list));
20
block/block-backend.c | 14 ++++++++++----
26
21
1 file changed, 10 insertions(+), 4 deletions(-)
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
22
49
23
diff --git a/block/block-backend.c b/block/block-backend.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/block/block-backend.c
26
+++ b/block/block-backend.c
27
@@ -XXX,XX +XXX,XX @@ void blk_set_io_limits(BlockBackend *blk, ThrottleConfig *cfg)
28
29
void blk_io_limits_disable(BlockBackend *blk)
30
{
31
- assert(blk->public.throttle_group_member.throttle_state);
32
- bdrv_drained_begin(blk_bs(blk));
33
- throttle_group_unregister_tgm(&blk->public.throttle_group_member);
34
- bdrv_drained_end(blk_bs(blk));
35
+ BlockDriverState *bs = blk_bs(blk);
36
+ ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
37
+ assert(tgm->throttle_state);
38
+ if (bs) {
39
+ bdrv_drained_begin(bs);
40
+ }
41
+ throttle_group_unregister_tgm(tgm);
42
+ if (bs) {
43
+ bdrv_drained_end(bs);
44
+ }
45
}
46
47
/* should be called before blk_set_io_limits if a limit is set */
48
--
49
2.13.6
50
51
diff view generated by jsdifflib
1
From: Alberto Garcia <berto@igalia.com>
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
2
3
If a BlockBackend has I/O limits set then its ThrottleGroupMember
3
This commit introduces "punch hole" operation and optimizes transfer
4
structure uses the AioContext from its attached BlockDriverState.
4
block size for macOS.
5
Those two contexts must be kept in sync manually. This is not
6
ideal and will be fixed in the future by removing the throttling
7
configuration from the BlockBackend and storing it in an implicit
8
filter node instead, but for now we have to live with this.
9
5
10
When you remove the BlockDriverState from the backend then the
6
Thanks to Konstantin Nazarov for detailed analysis of a flaw in an
11
throttle timers are destroyed. If a new BlockDriverState is later
7
old version of this change:
12
inserted then they are created again using the new AioContext.
8
https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3654667
13
9
14
There are a couple of problems with this:
10
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
15
11
Message-id: 20210705130458.97642-1-akihiko.odaki@gmail.com
16
a) The code manipulates the timers directly, leaving the
17
ThrottleGroupMember.aio_context field in an inconsisent state.
18
19
b) If you remove the I/O limits (e.g by destroying the backend)
20
when the timers are gone then throttle_group_unregister_tgm()
21
will attempt to destroy them again, crashing QEMU.
22
23
While b) could be fixed easily by allowing the timers to be freed
24
twice, this would result in a situation in which we can no longer
25
guarantee that a valid ThrottleState has a valid AioContext and
26
timers.
27
28
This patch ensures that the timers and AioContext are always valid
29
when I/O limits are set, regardless of whether the BlockBackend has a
30
BlockDriverState inserted or not.
31
32
[Fixed "There'a" typo as suggested by Max Reitz <mreitz@redhat.com>
33
--Stefan]
34
35
Reported-by: sochin jiang <sochin.jiang@huawei.com>
36
Signed-off-by: Alberto Garcia <berto@igalia.com>
37
Reviewed-by: Max Reitz <mreitz@redhat.com>
38
Message-id: e089c66e7c20289b046d782cea4373b765c5bc1d.1510339534.git.berto@igalia.com
39
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
40
---
13
---
41
block/block-backend.c | 16 ++++++++--------
14
block/file-posix.c | 27 +++++++++++++++++++++++++--
42
1 file changed, 8 insertions(+), 8 deletions(-)
15
1 file changed, 25 insertions(+), 2 deletions(-)
43
16
44
diff --git a/block/block-backend.c b/block/block-backend.c
17
diff --git a/block/file-posix.c b/block/file-posix.c
45
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
46
--- a/block/block-backend.c
19
--- a/block/file-posix.c
47
+++ b/block/block-backend.c
20
+++ b/block/file-posix.c
48
@@ -XXX,XX +XXX,XX @@ BlockBackend *blk_by_public(BlockBackendPublic *public)
21
@@ -XXX,XX +XXX,XX @@
49
*/
22
#if defined(HAVE_HOST_BLOCK_DEVICE)
50
void blk_remove_bs(BlockBackend *blk)
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
{
51
{
52
+ ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
52
if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP ||
53
BlockDriverState *bs;
53
@@ -XXX,XX +XXX,XX @@ static int translate_err(int err)
54
- ThrottleTimers *tt;
55
56
notifier_list_notify(&blk->remove_bs_notifiers, blk);
57
- if (blk->public.throttle_group_member.throttle_state) {
58
- tt = &blk->public.throttle_group_member.throttle_timers;
59
+ if (tgm->throttle_state) {
60
bs = blk_bs(blk);
61
bdrv_drained_begin(bs);
62
- throttle_timers_detach_aio_context(tt);
63
+ throttle_group_detach_aio_context(tgm);
64
+ throttle_group_attach_aio_context(tgm, qemu_get_aio_context());
65
bdrv_drained_end(bs);
66
}
54
}
67
55
return err;
68
@@ -XXX,XX +XXX,XX @@ void blk_remove_bs(BlockBackend *blk)
56
}
69
*/
57
+#endif
70
int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
58
71
{
59
#ifdef CONFIG_FALLOCATE
72
+ ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
60
static int do_fallocate(int fd, int mode, off_t offset, off_t len)
73
blk->root = bdrv_root_attach_child(bs, "root", &child_root,
61
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
74
blk->perm, blk->shared_perm, blk, errp);
62
}
75
if (blk->root == NULL) {
63
} while (errno == EINTR);
76
@@ -XXX,XX +XXX,XX @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
64
77
bdrv_ref(bs);
65
- ret = -errno;
78
66
+ ret = translate_err(-errno);
79
notifier_list_notify(&blk->insert_bs_notifiers, blk);
67
#endif
80
- if (blk->public.throttle_group_member.throttle_state) {
68
} else {
81
- throttle_timers_attach_aio_context(
69
#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
82
- &blk->public.throttle_group_member.throttle_timers,
70
ret = do_fallocate(s->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
83
- bdrv_get_aio_context(bs));
71
aiocb->aio_offset, aiocb->aio_nbytes);
84
+ if (tgm->throttle_state) {
72
+ ret = translate_err(-errno);
85
+ throttle_group_detach_aio_context(tgm);
73
+#elif defined(__APPLE__) && (__MACH__)
86
+ throttle_group_attach_aio_context(tgm, bdrv_get_aio_context(bs));
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
87
}
85
}
88
86
89
return 0;
87
- ret = translate_err(ret);
88
if (ret == -ENOTSUP) {
89
s->has_discard = false;
90
}
90
--
91
--
91
2.13.6
92
2.31.1
92
93
93
diff view generated by jsdifflib
1
I/O requests hang after stop/cont commands at least since QEMU 2.10.0
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
with -drive iops=100:
2
3
3
backend_defaults property allow users to control if default block
4
(guest)$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000
4
properties should be decided with backend information.
5
(qemu) stop
5
6
(qemu) cont
6
If it is off, any backend information will be discarded, which is
7
...I/O is stuck...
7
suitable if you plan to perform live migration to a different disk backend.
8
8
9
This happens because blk_set_aio_context() detaches the ThrottleState
9
If it is on, a block device may utilize backend information more
10
while requests may still be in flight:
10
aggressively.
11
11
12
if (tgm->throttle_state) {
12
By default, it is auto, which uses backend information for block
13
throttle_group_detach_aio_context(tgm);
13
sizes and ignores the others, which is consistent with the older
14
throttle_group_attach_aio_context(tgm, new_context);
14
versions.
15
}
15
16
16
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
17
This patch encloses the detach/attach calls in a drained region so no
17
Message-id: 20210705130458.97642-2-akihiko.odaki@gmail.com
18
I/O request is left hanging. Also add assertions so we don't make the
19
same mistake again in the future.
20
21
Reported-by: Yongxue Hong <yhong@redhat.com>
22
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
23
Reviewed-by: Alberto Garcia <berto@igalia.com>
24
Message-id: 20171110151934.16883-1-stefanha@redhat.com
25
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
26
---
19
---
27
block/block-backend.c | 2 ++
20
include/hw/block/block.h | 3 +++
28
block/throttle-groups.c | 6 ++++++
21
hw/block/block.c | 42 ++++++++++++++++++++++++++++++++++----
29
2 files changed, 8 insertions(+)
22
tests/qemu-iotests/172.out | 38 ++++++++++++++++++++++++++++++++++
30
23
3 files changed, 79 insertions(+), 4 deletions(-)
31
diff --git a/block/block-backend.c b/block/block-backend.c
24
25
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
32
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
33
--- a/block/block-backend.c
27
--- a/include/hw/block/block.h
34
+++ b/block/block-backend.c
28
+++ b/include/hw/block/block.h
35
@@ -XXX,XX +XXX,XX @@ void blk_set_aio_context(BlockBackend *blk, AioContext *new_context)
29
@@ -XXX,XX +XXX,XX @@
36
30
37
if (bs) {
31
typedef struct BlockConf {
38
if (tgm->throttle_state) {
32
BlockBackend *blk;
39
+ bdrv_drained_begin(bs);
33
+ OnOffAuto backend_defaults;
40
throttle_group_detach_aio_context(tgm);
34
uint32_t physical_block_size;
41
throttle_group_attach_aio_context(tgm, new_context);
35
uint32_t logical_block_size;
42
+ bdrv_drained_end(bs);
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;
43
}
88
}
44
bdrv_set_aio_context(bs, new_context);
45
}
89
}
46
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
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
47
index XXXXXXX..XXXXXXX 100644
114
index XXXXXXX..XXXXXXX 100644
48
--- a/block/throttle-groups.c
115
--- a/tests/qemu-iotests/172.out
49
+++ b/block/throttle-groups.c
116
+++ b/tests/qemu-iotests/172.out
50
@@ -XXX,XX +XXX,XX @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm,
117
@@ -XXX,XX +XXX,XX @@ Testing:
51
void throttle_group_detach_aio_context(ThrottleGroupMember *tgm)
118
dev: floppy, id ""
52
{
119
unit = 0 (0x0)
53
ThrottleTimers *tt = &tgm->throttle_timers;
120
drive = "floppy0"
54
+
121
+ backend_defaults = "auto"
55
+ /* Requests must have been drained */
122
logical_block_size = 512 (512 B)
56
+ assert(tgm->pending_reqs[0] == 0 && tgm->pending_reqs[1] == 0);
123
physical_block_size = 512 (512 B)
57
+ assert(qemu_co_queue_empty(&tgm->throttled_reqs[0]));
124
min_io_size = 0 (0 B)
58
+ assert(qemu_co_queue_empty(&tgm->throttled_reqs[1]));
125
@@ -XXX,XX +XXX,XX @@ Testing: -fda TEST_DIR/t.qcow2
59
+
126
dev: floppy, id ""
60
throttle_timers_detach_aio_context(tt);
127
unit = 0 (0x0)
61
tgm->aio_context = NULL;
128
drive = "floppy0"
62
}
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)
63
--
421
--
64
2.13.6
422
2.31.1
65
423
66
diff view generated by jsdifflib
1
From: Zhengui <lizhengui@huawei.com>
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
2
3
In blk_remove_bs, all I/O should be completed before removing throttle
3
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
4
timers. If there has inflight I/O, removing throttle timers here will
4
Message-id: 20210705130458.97642-3-akihiko.odaki@gmail.com
5
cause the inflight I/O never return.
6
This patch add bdrv_drained_begin before throttle_timers_detach_aio_context
7
to let all I/O completed before removing throttle timers.
8
9
[Moved declaration of bs as suggested by Alberto Garcia
10
<berto@igalia.com>.
11
--Stefan]
12
13
Signed-off-by: Zhengui <lizhengui@huawei.com>
14
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Reviewed-by: Alberto Garcia <berto@igalia.com>
16
Message-id: 1508564040-120700-1-git-send-email-lizhengui@huawei.com
17
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
---
6
---
19
block/block-backend.c | 4 ++++
7
block/io.c | 2 ++
20
1 file changed, 4 insertions(+)
8
1 file changed, 2 insertions(+)
21
9
22
diff --git a/block/block-backend.c b/block/block-backend.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/block-backend.c
12
--- a/block/io.c
25
+++ b/block/block-backend.c
13
+++ b/block/io.c
26
@@ -XXX,XX +XXX,XX @@ BlockBackend *blk_by_public(BlockBackendPublic *public)
14
@@ -XXX,XX +XXX,XX @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
27
*/
15
28
void blk_remove_bs(BlockBackend *blk)
16
static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src)
29
{
17
{
30
+ BlockDriverState *bs;
18
+ dst->pdiscard_alignment = MAX(dst->pdiscard_alignment,
31
ThrottleTimers *tt;
19
+ src->pdiscard_alignment);
32
20
dst->opt_transfer = MAX(dst->opt_transfer, src->opt_transfer);
33
notifier_list_notify(&blk->remove_bs_notifiers, blk);
21
dst->max_transfer = MIN_NON_ZERO(dst->max_transfer, src->max_transfer);
34
if (blk->public.throttle_group_member.throttle_state) {
22
dst->max_hw_transfer = MIN_NON_ZERO(dst->max_hw_transfer,
35
tt = &blk->public.throttle_group_member.throttle_timers;
36
+ bs = blk_bs(blk);
37
+ bdrv_drained_begin(bs);
38
throttle_timers_detach_aio_context(tt);
39
+ bdrv_drained_end(bs);
40
}
41
42
blk_update_root_state(blk);
43
--
23
--
44
2.13.6
24
2.31.1
45
25
46
diff view generated by jsdifflib