1
The following changes since commit f90ea7ba7c5ae7010ee0ce062207ae42530f57d6:
1
The following changes since commit ca61fa4b803e5d0abaf6f1ceb690f23bb78a4def:
2
2
3
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20171012' into staging (2017-10-12 17:06:50 +0100)
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 b867eaa17b3940760f51134e409cb0580dd3dde3:
9
for you to fetch changes up to 1cc7eada97914f090125e588497986f6f7900514:
10
10
11
block/throttle.c: add bdrv_co_drain_begin/end callbacks (2017-10-13 12:38:41 +0100)
11
iothread: use IOThreadParamInfo in iothread_[set|get]_param() (2021-10-07 15:29:50 +0100)
12
13
----------------------------------------------------------------
14
Pull request
12
15
13
----------------------------------------------------------------
16
----------------------------------------------------------------
14
17
15
----------------------------------------------------------------
18
Stefano Garzarella (2):
19
iothread: rename PollParamInfo to IOThreadParamInfo
20
iothread: use IOThreadParamInfo in iothread_[set|get]_param()
16
21
17
Manos Pitsidianakis (3):
22
iothread.c | 28 +++++++++++++++-------------
18
block: add bdrv_co_drain_end callback
23
1 file changed, 15 insertions(+), 13 deletions(-)
19
block: rename bdrv_co_drain to bdrv_co_drain_begin
20
block/throttle.c: add bdrv_co_drain_begin/end callbacks
21
22
include/block/block_int.h | 13 ++++++++++---
23
block/io.c | 48 +++++++++++++++++++++++++++++++++--------------
24
block/qed.c | 6 +++---
25
block/throttle.c | 18 ++++++++++++++++++
26
4 files changed, 65 insertions(+), 20 deletions(-)
27
24
28
--
25
--
29
2.13.6
26
2.31.1
30
27
31
28
29
diff view generated by jsdifflib
1
From: Manos Pitsidianakis <el13635@mail.ntua.gr>
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
2
3
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
3
Commit 1793ad0247 ("iothread: add aio-max-batch parameter") added
4
Reviewed-by: Fam Zheng <famz@redhat.com>
4
a new parameter (aio-max-batch) to IOThread and used PollParamInfo
5
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
5
structure to handle it.
6
7
Since it is not a parameter of the polling mechanism, we rename the
8
structure to a more generic IOThreadParamInfo.
9
10
Suggested-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Message-id: 20210727145936.147032-2-sgarzare@redhat.com
6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7
---
15
---
8
block/throttle.c | 18 ++++++++++++++++++
16
iothread.c | 14 +++++++-------
9
1 file changed, 18 insertions(+)
17
1 file changed, 7 insertions(+), 7 deletions(-)
10
18
11
diff --git a/block/throttle.c b/block/throttle.c
19
diff --git a/iothread.c b/iothread.c
12
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
13
--- a/block/throttle.c
21
--- a/iothread.c
14
+++ b/block/throttle.c
22
+++ b/iothread.c
15
@@ -XXX,XX +XXX,XX @@ static bool throttle_recurse_is_first_non_filter(BlockDriverState *bs,
23
@@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp)
16
return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate);
24
typedef struct {
17
}
25
const char *name;
18
26
ptrdiff_t offset; /* field's byte offset in IOThread struct */
19
+static void coroutine_fn throttle_co_drain_begin(BlockDriverState *bs)
27
-} PollParamInfo;
20
+{
28
+} IOThreadParamInfo;
21
+ ThrottleGroupMember *tgm = bs->opaque;
29
22
+ if (atomic_fetch_inc(&tgm->io_limits_disabled) == 0) {
30
-static PollParamInfo poll_max_ns_info = {
23
+ throttle_group_restart_tgm(tgm);
31
+static IOThreadParamInfo poll_max_ns_info = {
24
+ }
32
"poll-max-ns", offsetof(IOThread, poll_max_ns),
25
+}
26
+
27
+static void coroutine_fn throttle_co_drain_end(BlockDriverState *bs)
28
+{
29
+ ThrottleGroupMember *tgm = bs->opaque;
30
+ assert(tgm->io_limits_disabled);
31
+ atomic_dec(&tgm->io_limits_disabled);
32
+}
33
+
34
static BlockDriver bdrv_throttle = {
35
.format_name = "throttle",
36
.protocol_name = "throttle",
37
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_throttle = {
38
.bdrv_reopen_abort = throttle_reopen_abort,
39
.bdrv_co_get_block_status = bdrv_co_get_block_status_from_file,
40
41
+ .bdrv_co_drain_begin = throttle_co_drain_begin,
42
+ .bdrv_co_drain_end = throttle_co_drain_end,
43
+
44
.is_filter = true,
45
};
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;
46
64
47
--
65
--
48
2.13.6
66
2.31.1
49
67
50
68
diff view generated by jsdifflib
1
From: Manos Pitsidianakis <el13635@mail.ntua.gr>
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
2
3
BlockDriverState has a bdrv_co_drain() callback but no equivalent for
3
Commit 0445409d74 ("iothread: generalize
4
the end of the drain. The throttle driver (block/throttle.c) needs a way
4
iothread_set_param/iothread_get_param") moved common code to set and
5
to mark the end of the drain in order to toggle io_limits_disabled
5
get IOThread parameters in two new functions.
6
correctly, thus bdrv_co_drain_end is needed.
7
6
8
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
7
These functions are called inside callbacks, so we don't need to use an
9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
opaque pointer. Let's replace `void *opaque` parameter with
10
Reviewed-by: Fam Zheng <famz@redhat.com>
9
`IOThreadParamInfo *info`.
10
11
Suggested-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Message-id: 20210727145936.147032-3-sgarzare@redhat.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
16
---
13
include/block/block_int.h | 11 +++++++++--
17
iothread.c | 18 ++++++++++--------
14
block/io.c | 48 +++++++++++++++++++++++++++++++++--------------
18
1 file changed, 10 insertions(+), 8 deletions(-)
15
2 files changed, 43 insertions(+), 16 deletions(-)
16
19
17
diff --git a/include/block/block_int.h b/include/block/block_int.h
20
diff --git a/iothread.c b/iothread.c
18
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
19
--- a/include/block/block_int.h
22
--- a/iothread.c
20
+++ b/include/block/block_int.h
23
+++ b/iothread.c
21
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
24
@@ -XXX,XX +XXX,XX @@ static IOThreadParamInfo aio_max_batch_info = {
22
int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo);
25
};
23
26
24
/**
27
static void iothread_get_param(Object *obj, Visitor *v,
25
- * Drain and stop any internal sources of requests in the driver, and
28
- const char *name, void *opaque, Error **errp)
26
- * remain so until next I/O callback (e.g. bdrv_co_writev) is called.
29
+ const char *name, IOThreadParamInfo *info, Error **errp)
27
+ * bdrv_co_drain is called if implemented in the beginning of a
30
{
28
+ * drain operation to drain and stop any internal sources of requests in
31
IOThread *iothread = IOTHREAD(obj);
29
+ * the driver.
32
- IOThreadParamInfo *info = opaque;
30
+ * bdrv_co_drain_end is called if implemented at the end of the drain.
33
int64_t *field = (void *)iothread + info->offset;
31
+ *
34
32
+ * They should be used by the driver to e.g. manage scheduled I/O
35
visit_type_int64(v, name, field, errp);
33
+ * requests, or toggle an internal state. After the end of the drain new
34
+ * requests will continue normally.
35
*/
36
void coroutine_fn (*bdrv_co_drain)(BlockDriverState *bs);
37
+ void coroutine_fn (*bdrv_co_drain_end)(BlockDriverState *bs);
38
39
void (*bdrv_add_child)(BlockDriverState *parent, BlockDriverState *child,
40
Error **errp);
41
diff --git a/block/io.c b/block/io.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/block/io.c
44
+++ b/block/io.c
45
@@ -XXX,XX +XXX,XX @@ typedef struct {
46
Coroutine *co;
47
BlockDriverState *bs;
48
bool done;
49
+ bool begin;
50
} BdrvCoDrainData;
51
52
static void coroutine_fn bdrv_drain_invoke_entry(void *opaque)
53
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_drain_invoke_entry(void *opaque)
54
BdrvCoDrainData *data = opaque;
55
BlockDriverState *bs = data->bs;
56
57
- bs->drv->bdrv_co_drain(bs);
58
+ if (data->begin) {
59
+ bs->drv->bdrv_co_drain(bs);
60
+ } else {
61
+ bs->drv->bdrv_co_drain_end(bs);
62
+ }
63
64
/* Set data->done before reading bs->wakeup. */
65
atomic_mb_set(&data->done, true);
66
bdrv_wakeup(bs);
67
}
36
}
68
37
69
-static void bdrv_drain_invoke(BlockDriverState *bs)
38
static bool iothread_set_param(Object *obj, Visitor *v,
70
+static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
39
- const char *name, void *opaque, Error **errp)
40
+ const char *name, IOThreadParamInfo *info, Error **errp)
71
{
41
{
72
- BdrvCoDrainData data = { .bs = bs, .done = false };
42
IOThread *iothread = IOTHREAD(obj);
73
+ BdrvCoDrainData data = { .bs = bs, .done = false, .begin = begin};
43
- IOThreadParamInfo *info = opaque;
74
44
int64_t *field = (void *)iothread + info->offset;
75
- if (!bs->drv || !bs->drv->bdrv_co_drain) {
45
int64_t value;
76
+ if (!bs->drv || (begin && !bs->drv->bdrv_co_drain) ||
46
77
+ (!begin && !bs->drv->bdrv_co_drain_end)) {
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)) {
78
return;
65
return;
79
}
66
}
80
67
81
@@ -XXX,XX +XXX,XX @@ static void bdrv_drain_invoke(BlockDriverState *bs)
68
@@ -XXX,XX +XXX,XX @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
82
BDRV_POLL_WHILE(bs, !data.done);
69
static void iothread_get_aio_param(Object *obj, Visitor *v,
70
const char *name, void *opaque, Error **errp)
71
{
72
+ IOThreadParamInfo *info = opaque;
73
74
- iothread_get_param(obj, v, name, opaque, errp);
75
+ iothread_get_param(obj, v, name, info, errp);
83
}
76
}
84
77
85
-static bool bdrv_drain_recurse(BlockDriverState *bs)
78
static void iothread_set_aio_param(Object *obj, Visitor *v,
86
+static bool bdrv_drain_recurse(BlockDriverState *bs, bool begin)
79
const char *name, void *opaque, Error **errp)
87
{
80
{
88
BdrvChild *child, *tmp;
81
IOThread *iothread = IOTHREAD(obj);
89
bool waited;
82
+ IOThreadParamInfo *info = opaque;
90
83
91
- waited = BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0);
84
- if (!iothread_set_param(obj, v, name, opaque, errp)) {
92
-
85
+ if (!iothread_set_param(obj, v, name, info, errp)) {
93
/* Ensure any pending metadata writes are submitted to bs->file. */
94
- bdrv_drain_invoke(bs);
95
+ bdrv_drain_invoke(bs, begin);
96
+
97
+ /* Wait for drained requests to finish */
98
+ waited = BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0);
99
100
QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
101
BlockDriverState *bs = child->bs;
102
@@ -XXX,XX +XXX,XX @@ static bool bdrv_drain_recurse(BlockDriverState *bs)
103
*/
104
bdrv_ref(bs);
105
}
106
- waited |= bdrv_drain_recurse(bs);
107
+ waited |= bdrv_drain_recurse(bs, begin);
108
if (in_main_loop) {
109
bdrv_unref(bs);
110
}
111
@@ -XXX,XX +XXX,XX @@ static void bdrv_co_drain_bh_cb(void *opaque)
112
BlockDriverState *bs = data->bs;
113
114
bdrv_dec_in_flight(bs);
115
- bdrv_drained_begin(bs);
116
+ if (data->begin) {
117
+ bdrv_drained_begin(bs);
118
+ } else {
119
+ bdrv_drained_end(bs);
120
+ }
121
+
122
data->done = true;
123
aio_co_wake(co);
124
}
125
126
-static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs)
127
+static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
128
+ bool begin)
129
{
130
BdrvCoDrainData data;
131
132
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs)
133
.co = qemu_coroutine_self(),
134
.bs = bs,
135
.done = false,
136
+ .begin = begin,
137
};
138
bdrv_inc_in_flight(bs);
139
aio_bh_schedule_oneshot(bdrv_get_aio_context(bs),
140
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs)
141
void bdrv_drained_begin(BlockDriverState *bs)
142
{
143
if (qemu_in_coroutine()) {
144
- bdrv_co_yield_to_drain(bs);
145
+ bdrv_co_yield_to_drain(bs, true);
146
return;
86
return;
147
}
87
}
148
88
149
@@ -XXX,XX +XXX,XX @@ void bdrv_drained_begin(BlockDriverState *bs)
150
bdrv_parent_drained_begin(bs);
151
}
152
153
- bdrv_drain_recurse(bs);
154
+ bdrv_drain_recurse(bs, true);
155
}
156
157
void bdrv_drained_end(BlockDriverState *bs)
158
{
159
+ if (qemu_in_coroutine()) {
160
+ bdrv_co_yield_to_drain(bs, false);
161
+ return;
162
+ }
163
assert(bs->quiesce_counter > 0);
164
if (atomic_fetch_dec(&bs->quiesce_counter) > 1) {
165
return;
166
}
167
168
bdrv_parent_drained_end(bs);
169
+ bdrv_drain_recurse(bs, false);
170
aio_enable_external(bdrv_get_aio_context(bs));
171
}
172
173
@@ -XXX,XX +XXX,XX @@ void bdrv_drain_all_begin(void)
174
aio_context_acquire(aio_context);
175
for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
176
if (aio_context == bdrv_get_aio_context(bs)) {
177
- waited |= bdrv_drain_recurse(bs);
178
+ waited |= bdrv_drain_recurse(bs, true);
179
}
180
}
181
aio_context_release(aio_context);
182
@@ -XXX,XX +XXX,XX @@ void bdrv_drain_all_end(void)
183
aio_context_acquire(aio_context);
184
aio_enable_external(aio_context);
185
bdrv_parent_drained_end(bs);
186
+ bdrv_drain_recurse(bs, false);
187
aio_context_release(aio_context);
188
}
189
190
--
89
--
191
2.13.6
90
2.31.1
192
91
193
92
diff view generated by jsdifflib
Deleted patch
1
From: Manos Pitsidianakis <el13635@mail.ntua.gr>
2
1
3
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
Reviewed-by: Fam Zheng <famz@redhat.com>
5
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
---
9
include/block/block_int.h | 4 ++--
10
block/io.c | 4 ++--
11
block/qed.c | 6 +++---
12
3 files changed, 7 insertions(+), 7 deletions(-)
13
14
diff --git a/include/block/block_int.h b/include/block/block_int.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/block/block_int.h
17
+++ b/include/block/block_int.h
18
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
19
int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo);
20
21
/**
22
- * bdrv_co_drain is called if implemented in the beginning of a
23
+ * bdrv_co_drain_begin is called if implemented in the beginning of a
24
* drain operation to drain and stop any internal sources of requests in
25
* the driver.
26
* bdrv_co_drain_end is called if implemented at the end of the drain.
27
@@ -XXX,XX +XXX,XX @@ struct BlockDriver {
28
* requests, or toggle an internal state. After the end of the drain new
29
* requests will continue normally.
30
*/
31
- void coroutine_fn (*bdrv_co_drain)(BlockDriverState *bs);
32
+ void coroutine_fn (*bdrv_co_drain_begin)(BlockDriverState *bs);
33
void coroutine_fn (*bdrv_co_drain_end)(BlockDriverState *bs);
34
35
void (*bdrv_add_child)(BlockDriverState *parent, BlockDriverState *child,
36
diff --git a/block/io.c b/block/io.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/block/io.c
39
+++ b/block/io.c
40
@@ -XXX,XX +XXX,XX @@ static void coroutine_fn bdrv_drain_invoke_entry(void *opaque)
41
BlockDriverState *bs = data->bs;
42
43
if (data->begin) {
44
- bs->drv->bdrv_co_drain(bs);
45
+ bs->drv->bdrv_co_drain_begin(bs);
46
} else {
47
bs->drv->bdrv_co_drain_end(bs);
48
}
49
@@ -XXX,XX +XXX,XX @@ static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
50
{
51
BdrvCoDrainData data = { .bs = bs, .done = false, .begin = begin};
52
53
- if (!bs->drv || (begin && !bs->drv->bdrv_co_drain) ||
54
+ if (!bs->drv || (begin && !bs->drv->bdrv_co_drain_begin) ||
55
(!begin && !bs->drv->bdrv_co_drain_end)) {
56
return;
57
}
58
diff --git a/block/qed.c b/block/qed.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/block/qed.c
61
+++ b/block/qed.c
62
@@ -XXX,XX +XXX,XX @@ static bool qed_plug_allocating_write_reqs(BDRVQEDState *s)
63
assert(!s->allocating_write_reqs_plugged);
64
if (s->allocating_acb != NULL) {
65
/* Another allocating write came concurrently. This cannot happen
66
- * from bdrv_qed_co_drain, but it can happen when the timer runs.
67
+ * from bdrv_qed_co_drain_begin, but it can happen when the timer runs.
68
*/
69
qemu_co_mutex_unlock(&s->table_lock);
70
return false;
71
@@ -XXX,XX +XXX,XX @@ static void bdrv_qed_attach_aio_context(BlockDriverState *bs,
72
}
73
}
74
75
-static void coroutine_fn bdrv_qed_co_drain(BlockDriverState *bs)
76
+static void coroutine_fn bdrv_qed_co_drain_begin(BlockDriverState *bs)
77
{
78
BDRVQEDState *s = bs->opaque;
79
80
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_qed = {
81
.bdrv_check = bdrv_qed_check,
82
.bdrv_detach_aio_context = bdrv_qed_detach_aio_context,
83
.bdrv_attach_aio_context = bdrv_qed_attach_aio_context,
84
- .bdrv_co_drain = bdrv_qed_co_drain,
85
+ .bdrv_co_drain_begin = bdrv_qed_co_drain_begin,
86
};
87
88
static void bdrv_qed_init(void)
89
--
90
2.13.6
91
92
diff view generated by jsdifflib