1 | The following changes since commit 508ba0f7e2092d3ca56e3f75e894d52d8b94818e: | 1 | The following changes since commit ca61fa4b803e5d0abaf6f1ceb690f23bb78a4def: |
---|---|---|---|
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/quic/tags/pull-hex-20211006' into staging (2021-10-06 12:11:14 -0700) |
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 1cc7eada97914f090125e588497986f6f7900514: |
10 | 10 | ||
11 | qemu-iotests: Test I/O limits with removable media (2017-11-13 15:46:26 +0000) | 11 | iothread: use IOThreadParamInfo in iothread_[set|get]_param() (2021-10-07 15:29:50 +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 | Stefano Garzarella (2): |
21 | block: Check for inserted BlockDriverState in blk_io_limits_disable() | 19 | iothread: rename PollParamInfo to IOThreadParamInfo |
22 | block: Leave valid throttle timers when removing a BDS from a backend | 20 | iothread: use IOThreadParamInfo in iothread_[set|get]_param() |
23 | qemu-iotests: Test I/O limits with removable media | ||
24 | 21 | ||
25 | Stefan Hajnoczi (1): | 22 | iothread.c | 28 +++++++++++++++------------- |
26 | throttle-groups: drain before detaching ThrottleState | 23 | 1 file changed, 15 insertions(+), 13 deletions(-) |
27 | |||
28 | Zhengui (1): | ||
29 | block: all I/O should be completed before removing throttle timers. | ||
30 | |||
31 | block/block-backend.c | 36 ++++++++++++++++++--------- | ||
32 | block/throttle-groups.c | 6 +++++ | ||
33 | tests/qemu-iotests/093 | 62 ++++++++++++++++++++++++++++++++++++++++++++++ | ||
34 | tests/qemu-iotests/093.out | 4 +-- | ||
35 | 4 files changed, 94 insertions(+), 14 deletions(-) | ||
36 | 24 | ||
37 | -- | 25 | -- |
38 | 2.13.6 | 26 | 2.31.1 |
39 | 27 | ||
40 | 28 | ||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhengui <lizhengui@huawei.com> | ||
2 | 1 | ||
3 | In blk_remove_bs, all I/O should be completed before removing throttle | ||
4 | timers. If there has inflight I/O, removing throttle timers here will | ||
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> | ||
18 | --- | ||
19 | block/block-backend.c | 4 ++++ | ||
20 | 1 file changed, 4 insertions(+) | ||
21 | |||
22 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/block/block-backend.c | ||
25 | +++ b/block/block-backend.c | ||
26 | @@ -XXX,XX +XXX,XX @@ BlockBackend *blk_by_public(BlockBackendPublic *public) | ||
27 | */ | ||
28 | void blk_remove_bs(BlockBackend *blk) | ||
29 | { | ||
30 | + BlockDriverState *bs; | ||
31 | ThrottleTimers *tt; | ||
32 | |||
33 | notifier_list_notify(&blk->remove_bs_notifiers, blk); | ||
34 | if (blk->public.throttle_group_member.throttle_state) { | ||
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 | -- | ||
44 | 2.13.6 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | I/O requests hang after stop/cont commands at least since QEMU 2.10.0 | ||
2 | with -drive iops=100: | ||
3 | 1 | ||
4 | (guest)$ dd if=/dev/zero of=/dev/vdb oflag=direct count=1000 | ||
5 | (qemu) stop | ||
6 | (qemu) cont | ||
7 | ...I/O is stuck... | ||
8 | |||
9 | This happens because blk_set_aio_context() detaches the ThrottleState | ||
10 | while requests may still be in flight: | ||
11 | |||
12 | if (tgm->throttle_state) { | ||
13 | throttle_group_detach_aio_context(tgm); | ||
14 | throttle_group_attach_aio_context(tgm, new_context); | ||
15 | } | ||
16 | |||
17 | This patch encloses the detach/attach calls in a drained region so no | ||
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> | ||
26 | --- | ||
27 | block/block-backend.c | 2 ++ | ||
28 | block/throttle-groups.c | 6 ++++++ | ||
29 | 2 files changed, 8 insertions(+) | ||
30 | |||
31 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/block/block-backend.c | ||
34 | +++ b/block/block-backend.c | ||
35 | @@ -XXX,XX +XXX,XX @@ void blk_set_aio_context(BlockBackend *blk, AioContext *new_context) | ||
36 | |||
37 | if (bs) { | ||
38 | if (tgm->throttle_state) { | ||
39 | + bdrv_drained_begin(bs); | ||
40 | throttle_group_detach_aio_context(tgm); | ||
41 | throttle_group_attach_aio_context(tgm, new_context); | ||
42 | + bdrv_drained_end(bs); | ||
43 | } | ||
44 | bdrv_set_aio_context(bs, new_context); | ||
45 | } | ||
46 | diff --git a/block/throttle-groups.c b/block/throttle-groups.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/block/throttle-groups.c | ||
49 | +++ b/block/throttle-groups.c | ||
50 | @@ -XXX,XX +XXX,XX @@ void throttle_group_attach_aio_context(ThrottleGroupMember *tgm, | ||
51 | void throttle_group_detach_aio_context(ThrottleGroupMember *tgm) | ||
52 | { | ||
53 | ThrottleTimers *tt = &tgm->throttle_timers; | ||
54 | + | ||
55 | + /* Requests must have been drained */ | ||
56 | + assert(tgm->pending_reqs[0] == 0 && tgm->pending_reqs[1] == 0); | ||
57 | + assert(qemu_co_queue_empty(&tgm->throttled_reqs[0])); | ||
58 | + assert(qemu_co_queue_empty(&tgm->throttled_reqs[1])); | ||
59 | + | ||
60 | throttle_timers_detach_aio_context(tt); | ||
61 | tgm->aio_context = NULL; | ||
62 | } | ||
63 | -- | ||
64 | 2.13.6 | ||
65 | |||
66 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alberto Garcia <berto@igalia.com> | ||
2 | 1 | ||
3 | When you set I/O limits using block_set_io_throttle or the command | ||
4 | line throttling.* options they are kept in the BlockBackend regardless | ||
5 | of whether a BlockDriverState is attached to the backend or not. | ||
6 | |||
7 | Therefore when removing the limits using blk_io_limits_disable() we | ||
8 | need to check if there's a BDS before attempting to drain it, else it | ||
9 | will crash QEMU. This can be reproduced very easily using HMP: | ||
10 | |||
11 | (qemu) drive_add 0 if=none,throttling.iops-total=5000 | ||
12 | (qemu) drive_del none0 | ||
13 | |||
14 | Reported-by: sochin jiang <sochin.jiang@huawei.com> | ||
15 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
16 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
17 | Message-id: 0d3a67ce8d948bb33e08672564714dcfb76a3d8c.1510339534.git.berto@igalia.com | ||
18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
19 | --- | ||
20 | block/block-backend.c | 14 ++++++++++---- | ||
21 | 1 file changed, 10 insertions(+), 4 deletions(-) | ||
22 | |||
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: Stefano Garzarella <sgarzare@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | This test hotplugs a CD drive to a VM and checks that I/O limits can | 3 | Commit 1793ad0247 ("iothread: add aio-max-batch parameter") added |
4 | be set only when the drive has media inserted and that they are kept | 4 | a new parameter (aio-max-batch) to IOThread and used PollParamInfo |
5 | when the media is replaced. | 5 | structure to handle it. |
6 | 6 | ||
7 | This also tests the removal of a device with valid I/O limits set but | 7 | Since it is not a parameter of the polling mechanism, we rename the |
8 | no media inserted. This involves deleting and disabling the limits | 8 | structure to a more generic IOThreadParamInfo. |
9 | of a BlockBackend without BlockDriverState, a scenario that has been | ||
10 | crashing until the fixes from the last couple of patches. | ||
11 | 9 | ||
12 | [Python PEP8 fixup: "Don't use spaces are the = sign when used to | 10 | Suggested-by: Kevin Wolf <kwolf@redhat.com> |
13 | indicate a keyword argument or a default parameter value" | 11 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> |
14 | --Stefan] | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
15 | 13 | Message-id: 20210727145936.147032-2-sgarzare@redhat.com | |
16 | Signed-off-by: Alberto Garcia <berto@igalia.com> | ||
17 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
18 | Message-id: 071eb397118ed207c5a7f01d58766e415ee18d6a.1510339534.git.berto@igalia.com | ||
19 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
20 | --- | 15 | --- |
21 | tests/qemu-iotests/093 | 62 ++++++++++++++++++++++++++++++++++++++++++++++ | 16 | iothread.c | 14 +++++++------- |
22 | tests/qemu-iotests/093.out | 4 +-- | 17 | 1 file changed, 7 insertions(+), 7 deletions(-) |
23 | 2 files changed, 64 insertions(+), 2 deletions(-) | ||
24 | 18 | ||
25 | diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093 | 19 | diff --git a/iothread.c b/iothread.c |
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 | 20 | index XXXXXXX..XXXXXXX 100644 |
100 | --- a/tests/qemu-iotests/093.out | 21 | --- a/iothread.c |
101 | +++ b/tests/qemu-iotests/093.out | 22 | +++ b/iothread.c |
102 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp) |
103 | -....... | 24 | typedef struct { |
104 | +........ | 25 | const char *name; |
105 | ---------------------------------------------------------------------- | 26 | ptrdiff_t offset; /* field's byte offset in IOThread struct */ |
106 | -Ran 7 tests | 27 | -} PollParamInfo; |
107 | +Ran 8 tests | 28 | +} IOThreadParamInfo; |
108 | 29 | ||
109 | OK | 30 | -static PollParamInfo poll_max_ns_info = { |
31 | +static IOThreadParamInfo poll_max_ns_info = { | ||
32 | "poll-max-ns", offsetof(IOThread, poll_max_ns), | ||
33 | }; | ||
34 | -static PollParamInfo poll_grow_info = { | ||
35 | +static IOThreadParamInfo poll_grow_info = { | ||
36 | "poll-grow", offsetof(IOThread, poll_grow), | ||
37 | }; | ||
38 | -static PollParamInfo poll_shrink_info = { | ||
39 | +static IOThreadParamInfo poll_shrink_info = { | ||
40 | "poll-shrink", offsetof(IOThread, poll_shrink), | ||
41 | }; | ||
42 | -static PollParamInfo aio_max_batch_info = { | ||
43 | +static IOThreadParamInfo aio_max_batch_info = { | ||
44 | "aio-max-batch", offsetof(IOThread, aio_max_batch), | ||
45 | }; | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static void iothread_get_param(Object *obj, Visitor *v, | ||
48 | const char *name, void *opaque, Error **errp) | ||
49 | { | ||
50 | IOThread *iothread = IOTHREAD(obj); | ||
51 | - PollParamInfo *info = opaque; | ||
52 | + IOThreadParamInfo *info = opaque; | ||
53 | int64_t *field = (void *)iothread + info->offset; | ||
54 | |||
55 | visit_type_int64(v, name, field, errp); | ||
56 | @@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v, | ||
57 | const char *name, void *opaque, Error **errp) | ||
58 | { | ||
59 | IOThread *iothread = IOTHREAD(obj); | ||
60 | - PollParamInfo *info = opaque; | ||
61 | + IOThreadParamInfo *info = opaque; | ||
62 | int64_t *field = (void *)iothread + info->offset; | ||
63 | int64_t value; | ||
64 | |||
110 | -- | 65 | -- |
111 | 2.13.6 | 66 | 2.31.1 |
112 | 67 | ||
113 | 68 | diff view generated by jsdifflib |
1 | From: Alberto Garcia <berto@igalia.com> | 1 | From: Stefano Garzarella <sgarzare@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | If a BlockBackend has I/O limits set then its ThrottleGroupMember | 3 | Commit 0445409d74 ("iothread: generalize |
4 | structure uses the AioContext from its attached BlockDriverState. | 4 | iothread_set_param/iothread_get_param") moved common code to set and |
5 | Those two contexts must be kept in sync manually. This is not | 5 | get IOThread parameters in two new functions. |
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 | 6 | ||
10 | When you remove the BlockDriverState from the backend then the | 7 | These functions are called inside callbacks, so we don't need to use an |
11 | throttle timers are destroyed. If a new BlockDriverState is later | 8 | opaque pointer. Let's replace `void *opaque` parameter with |
12 | inserted then they are created again using the new AioContext. | 9 | `IOThreadParamInfo *info`. |
13 | 10 | ||
14 | There are a couple of problems with this: | 11 | Suggested-by: Kevin Wolf <kwolf@redhat.com> |
15 | 12 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> | |
16 | a) The code manipulates the timers directly, leaving the | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
17 | ThrottleGroupMember.aio_context field in an inconsisent state. | 14 | Message-id: 20210727145936.147032-3-sgarzare@redhat.com |
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> | 15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
40 | --- | 16 | --- |
41 | block/block-backend.c | 16 ++++++++-------- | 17 | iothread.c | 18 ++++++++++-------- |
42 | 1 file changed, 8 insertions(+), 8 deletions(-) | 18 | 1 file changed, 10 insertions(+), 8 deletions(-) |
43 | 19 | ||
44 | diff --git a/block/block-backend.c b/block/block-backend.c | 20 | diff --git a/iothread.c b/iothread.c |
45 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/block/block-backend.c | 22 | --- a/iothread.c |
47 | +++ b/block/block-backend.c | 23 | +++ b/iothread.c |
48 | @@ -XXX,XX +XXX,XX @@ BlockBackend *blk_by_public(BlockBackendPublic *public) | 24 | @@ -XXX,XX +XXX,XX @@ static IOThreadParamInfo aio_max_batch_info = { |
49 | */ | 25 | }; |
50 | void blk_remove_bs(BlockBackend *blk) | 26 | |
27 | static void iothread_get_param(Object *obj, Visitor *v, | ||
28 | - const char *name, void *opaque, Error **errp) | ||
29 | + const char *name, IOThreadParamInfo *info, Error **errp) | ||
51 | { | 30 | { |
52 | + ThrottleGroupMember *tgm = &blk->public.throttle_group_member; | 31 | IOThread *iothread = IOTHREAD(obj); |
53 | BlockDriverState *bs; | 32 | - IOThreadParamInfo *info = opaque; |
54 | - ThrottleTimers *tt; | 33 | int64_t *field = (void *)iothread + info->offset; |
55 | 34 | ||
56 | notifier_list_notify(&blk->remove_bs_notifiers, blk); | 35 | visit_type_int64(v, name, field, errp); |
57 | - if (blk->public.throttle_group_member.throttle_state) { | 36 | } |
58 | - tt = &blk->public.throttle_group_member.throttle_timers; | 37 | |
59 | + if (tgm->throttle_state) { | 38 | static bool iothread_set_param(Object *obj, Visitor *v, |
60 | bs = blk_bs(blk); | 39 | - const char *name, void *opaque, Error **errp) |
61 | bdrv_drained_begin(bs); | 40 | + const char *name, IOThreadParamInfo *info, Error **errp) |
62 | - throttle_timers_detach_aio_context(tt); | 41 | { |
63 | + throttle_group_detach_aio_context(tgm); | 42 | IOThread *iothread = IOTHREAD(obj); |
64 | + throttle_group_attach_aio_context(tgm, qemu_get_aio_context()); | 43 | - IOThreadParamInfo *info = opaque; |
65 | bdrv_drained_end(bs); | 44 | int64_t *field = (void *)iothread + info->offset; |
45 | int64_t value; | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v, | ||
48 | static void iothread_get_poll_param(Object *obj, Visitor *v, | ||
49 | const char *name, void *opaque, Error **errp) | ||
50 | { | ||
51 | + IOThreadParamInfo *info = opaque; | ||
52 | |||
53 | - iothread_get_param(obj, v, name, opaque, errp); | ||
54 | + iothread_get_param(obj, v, name, info, errp); | ||
55 | } | ||
56 | |||
57 | static void iothread_set_poll_param(Object *obj, Visitor *v, | ||
58 | const char *name, void *opaque, Error **errp) | ||
59 | { | ||
60 | IOThread *iothread = IOTHREAD(obj); | ||
61 | + IOThreadParamInfo *info = opaque; | ||
62 | |||
63 | - if (!iothread_set_param(obj, v, name, opaque, errp)) { | ||
64 | + if (!iothread_set_param(obj, v, name, info, errp)) { | ||
65 | return; | ||
66 | } | 66 | } |
67 | 67 | ||
68 | @@ -XXX,XX +XXX,XX @@ void blk_remove_bs(BlockBackend *blk) | 68 | @@ -XXX,XX +XXX,XX @@ static void iothread_set_poll_param(Object *obj, Visitor *v, |
69 | */ | 69 | static void iothread_get_aio_param(Object *obj, Visitor *v, |
70 | int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp) | 70 | const char *name, void *opaque, Error **errp) |
71 | { | 71 | { |
72 | + ThrottleGroupMember *tgm = &blk->public.throttle_group_member; | 72 | + IOThreadParamInfo *info = opaque; |
73 | blk->root = bdrv_root_attach_child(bs, "root", &child_root, | 73 | |
74 | blk->perm, blk->shared_perm, blk, errp); | 74 | - iothread_get_param(obj, v, name, opaque, errp); |
75 | if (blk->root == NULL) { | 75 | + iothread_get_param(obj, v, name, info, errp); |
76 | @@ -XXX,XX +XXX,XX @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp) | 76 | } |
77 | bdrv_ref(bs); | 77 | |
78 | 78 | static void iothread_set_aio_param(Object *obj, Visitor *v, | |
79 | notifier_list_notify(&blk->insert_bs_notifiers, blk); | 79 | const char *name, void *opaque, Error **errp) |
80 | - if (blk->public.throttle_group_member.throttle_state) { | 80 | { |
81 | - throttle_timers_attach_aio_context( | 81 | IOThread *iothread = IOTHREAD(obj); |
82 | - &blk->public.throttle_group_member.throttle_timers, | 82 | + IOThreadParamInfo *info = opaque; |
83 | - bdrv_get_aio_context(bs)); | 83 | |
84 | + if (tgm->throttle_state) { | 84 | - if (!iothread_set_param(obj, v, name, opaque, errp)) { |
85 | + throttle_group_detach_aio_context(tgm); | 85 | + if (!iothread_set_param(obj, v, name, info, errp)) { |
86 | + throttle_group_attach_aio_context(tgm, bdrv_get_aio_context(bs)); | 86 | return; |
87 | } | 87 | } |
88 | 88 | ||
89 | return 0; | ||
90 | -- | 89 | -- |
91 | 2.13.6 | 90 | 2.31.1 |
92 | 91 | ||
93 | 92 | diff view generated by jsdifflib |