* [PATCH 0/2] block: Fix crash in blockdev-reopen with iothreads
@ 2022-02-03 14:05 Kevin Wolf
2022-02-03 14:05 ` [PATCH 1/2] block: Lock AioContext for drain_end in blockdev-reopen Kevin Wolf
2022-02-03 14:05 ` [PATCH 2/2] iotests: Test blockdev-reopen with iothreads and throttling Kevin Wolf
0 siblings, 2 replies; 5+ messages in thread
From: Kevin Wolf @ 2022-02-03 14:05 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, hreitz, vsementsov, qinwang, qemu-devel
Kevin Wolf (2):
block: Lock AioContext for drain_end in blockdev-reopen
iotests: Test blockdev-reopen with iothreads and throttling
blockdev.c | 11 ++++++++++-
tests/qemu-iotests/245 | 36 +++++++++++++++++++++++++++++++++---
tests/qemu-iotests/245.out | 4 ++--
3 files changed, 45 insertions(+), 6 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] block: Lock AioContext for drain_end in blockdev-reopen
2022-02-03 14:05 [PATCH 0/2] block: Fix crash in blockdev-reopen with iothreads Kevin Wolf
@ 2022-02-03 14:05 ` Kevin Wolf
2022-02-03 16:37 ` Hanna Reitz
2022-02-03 14:05 ` [PATCH 2/2] iotests: Test blockdev-reopen with iothreads and throttling Kevin Wolf
1 sibling, 1 reply; 5+ messages in thread
From: Kevin Wolf @ 2022-02-03 14:05 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, hreitz, vsementsov, qinwang, qemu-devel
bdrv_subtree_drained_end() requires the caller to hold the AioContext
lock for the drained node. Not doing this for nodes outside of the main
AioContext leads to crashes when AIO_WAIT_WHILE() needs to wait and
tries to temporarily release the lock.
Fixes: 3908b7a8994fa5ef7a89aa58cd5a02fc58141592
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2046659
Reported-by: Qing Wang <qinwang@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
blockdev.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 8197165bb5..42e098b458 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3530,6 +3530,7 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
{
BlockReopenQueue *queue = NULL;
GSList *drained = NULL;
+ GSList *p;
/* Add each one of the BDS that we want to reopen to the queue */
for (; reopen_list != NULL; reopen_list = reopen_list->next) {
@@ -3579,7 +3580,15 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
fail:
bdrv_reopen_queue_free(queue);
- g_slist_free_full(drained, (GDestroyNotify) bdrv_subtree_drained_end);
+ for (p = drained; p; p = p->next) {
+ BlockDriverState *bs = p->data;
+ AioContext *ctx = bdrv_get_aio_context(bs);
+
+ aio_context_acquire(ctx);
+ bdrv_subtree_drained_end(bs);
+ aio_context_release(ctx);
+ }
+ g_slist_free(drained);
}
void qmp_blockdev_del(const char *node_name, Error **errp)
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] iotests: Test blockdev-reopen with iothreads and throttling
2022-02-03 14:05 [PATCH 0/2] block: Fix crash in blockdev-reopen with iothreads Kevin Wolf
2022-02-03 14:05 ` [PATCH 1/2] block: Lock AioContext for drain_end in blockdev-reopen Kevin Wolf
@ 2022-02-03 14:05 ` Kevin Wolf
2022-02-03 16:45 ` Hanna Reitz
1 sibling, 1 reply; 5+ messages in thread
From: Kevin Wolf @ 2022-02-03 14:05 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, hreitz, vsementsov, qinwang, qemu-devel
The 'throttle' block driver implements .bdrv_co_drain_end, so
blockdev-reopen will have to wait for it to complete in the polling
loop at the end of qmp_blockdev_reopen(). This makes AIO_WAIT_WHILE()
release the AioContext lock, which causes a crash if the lock hasn't
correctly been taken.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/245 | 36 +++++++++++++++++++++++++++++++++---
tests/qemu-iotests/245.out | 4 ++--
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
index 24ac43f70e..8cbed7821b 100755
--- a/tests/qemu-iotests/245
+++ b/tests/qemu-iotests/245
@@ -1138,12 +1138,13 @@ class TestBlockdevReopen(iotests.QMPTestCase):
self.assertEqual(self.get_node('hd1'), None)
self.assert_qmp(self.get_node('hd2'), 'ro', True)
- def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None):
- opts = hd_opts(0)
+ def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None,
+ opts_a = None, opts_b = None):
+ opts = opts_a or hd_opts(0)
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
self.assert_qmp(result, 'return', {})
- opts2 = hd_opts(2)
+ opts2 = opts_b or hd_opts(2)
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts2)
self.assert_qmp(result, 'return', {})
@@ -1194,6 +1195,35 @@ class TestBlockdevReopen(iotests.QMPTestCase):
def test_iothreads_switch_overlay(self):
self.run_test_iothreads('', 'iothread0')
+ def test_iothreads_with_throttling(self):
+ # Create a throttle-group object
+ opts = { 'qom-type': 'throttle-group', 'id': 'group0',
+ 'limits': { 'iops-total': 1000 } }
+ result = self.vm.qmp('object-add', conv_keys = False, **opts)
+ self.assert_qmp(result, 'return', {})
+
+ # Options with a throttle filter between format and protocol
+ opts = [
+ {
+ 'driver': iotests.imgfmt,
+ 'node-name': f'hd{idx}',
+ 'file' : {
+ 'node-name': f'hd{idx}-throttle',
+ 'driver': 'throttle',
+ 'throttle-group': 'group0',
+ 'file': {
+ 'driver': 'file',
+ 'node-name': f'hd{idx}-file',
+ 'filename': hd_path[idx],
+ },
+ },
+ }
+ for idx in (0, 2)
+ ]
+
+ self.run_test_iothreads('iothread0', 'iothread0', None,
+ opts[0], opts[1])
+
if __name__ == '__main__':
iotests.activate_logging()
iotests.main(supported_fmts=["qcow2"],
diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out
index 4eced19294..a4e04a3266 100644
--- a/tests/qemu-iotests/245.out
+++ b/tests/qemu-iotests/245.out
@@ -17,8 +17,8 @@ read 1/1 bytes at offset 262152
read 1/1 bytes at offset 262160
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-...............
+................
----------------------------------------------------------------------
-Ran 25 tests
+Ran 26 tests
OK
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] block: Lock AioContext for drain_end in blockdev-reopen
2022-02-03 14:05 ` [PATCH 1/2] block: Lock AioContext for drain_end in blockdev-reopen Kevin Wolf
@ 2022-02-03 16:37 ` Hanna Reitz
0 siblings, 0 replies; 5+ messages in thread
From: Hanna Reitz @ 2022-02-03 16:37 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: vsementsov, qinwang, qemu-devel
On 03.02.22 15:05, Kevin Wolf wrote:
> bdrv_subtree_drained_end() requires the caller to hold the AioContext
> lock for the drained node. Not doing this for nodes outside of the main
> AioContext leads to crashes when AIO_WAIT_WHILE() needs to wait and
> tries to temporarily release the lock.
>
> Fixes: 3908b7a8994fa5ef7a89aa58cd5a02fc58141592
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2046659
> Reported-by: Qing Wang <qinwang@redhat.com>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> blockdev.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] iotests: Test blockdev-reopen with iothreads and throttling
2022-02-03 14:05 ` [PATCH 2/2] iotests: Test blockdev-reopen with iothreads and throttling Kevin Wolf
@ 2022-02-03 16:45 ` Hanna Reitz
0 siblings, 0 replies; 5+ messages in thread
From: Hanna Reitz @ 2022-02-03 16:45 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: vsementsov, qinwang, qemu-devel
On 03.02.22 15:05, Kevin Wolf wrote:
> The 'throttle' block driver implements .bdrv_co_drain_end, so
> blockdev-reopen will have to wait for it to complete in the polling
> loop at the end of qmp_blockdev_reopen(). This makes AIO_WAIT_WHILE()
> release the AioContext lock, which causes a crash if the lock hasn't
> correctly been taken.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> tests/qemu-iotests/245 | 36 +++++++++++++++++++++++++++++++++---
> tests/qemu-iotests/245.out | 4 ++--
> 2 files changed, 35 insertions(+), 5 deletions(-)
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-03 16:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 14:05 [PATCH 0/2] block: Fix crash in blockdev-reopen with iothreads Kevin Wolf
2022-02-03 14:05 ` [PATCH 1/2] block: Lock AioContext for drain_end in blockdev-reopen Kevin Wolf
2022-02-03 16:37 ` Hanna Reitz
2022-02-03 14:05 ` [PATCH 2/2] iotests: Test blockdev-reopen with iothreads and throttling Kevin Wolf
2022-02-03 16:45 ` Hanna Reitz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.