119 lines
4.7 KiB
Diff
119 lines
4.7 KiB
Diff
|
From bc284d49a00a1a716b380c2245aa0b897a259a5d Mon Sep 17 00:00:00 2001
|
||
|
From: Sergio Lopez Pascual <slp@redhat.com>
|
||
|
Date: Thu, 11 Feb 2021 14:42:04 -0300
|
||
|
Subject: [PATCH 2/6] block: Honor blk_set_aio_context() context requirements
|
||
|
|
||
|
RH-Author: Sergio Lopez Pascual <slp@redhat.com>
|
||
|
Message-id: <20210211144208.58930-2-slp@redhat.com>
|
||
|
Patchwork-id: 101049
|
||
|
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/5] block: Honor blk_set_aio_context() context requirements
|
||
|
Bugzilla: 1918966 1918968
|
||
|
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
||
|
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
||
|
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
||
|
|
||
|
The documentation for bdrv_set_aio_context_ignore() states this:
|
||
|
|
||
|
* The caller must own the AioContext lock for the old AioContext of bs, but it
|
||
|
* must not own the AioContext lock for new_context (unless new_context is the
|
||
|
* same as the current context of bs).
|
||
|
|
||
|
As blk_set_aio_context() makes use of this function, this rule also
|
||
|
applies to it.
|
||
|
|
||
|
Fix all occurrences where this rule wasn't honored.
|
||
|
|
||
|
Suggested-by: Kevin Wolf <kwolf@redhat.com>
|
||
|
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
||
|
Message-Id: <20201214170519.223781-2-slp@redhat.com>
|
||
|
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
||
|
Signed-off-by: Eric Blake <eblake@redhat.com>
|
||
|
(cherry picked from commit c7040ff64ec93ee925a81d3547db925fe7d1f1c0)
|
||
|
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
||
|
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
||
|
---
|
||
|
hw/block/dataplane/virtio-blk.c | 4 ++++
|
||
|
hw/block/dataplane/xen-block.c | 7 ++++++-
|
||
|
hw/scsi/virtio-scsi.c | 6 ++++--
|
||
|
3 files changed, 14 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
|
||
|
index 37499c5564..e9050c8987 100644
|
||
|
--- a/hw/block/dataplane/virtio-blk.c
|
||
|
+++ b/hw/block/dataplane/virtio-blk.c
|
||
|
@@ -172,6 +172,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
|
||
|
VirtIOBlockDataPlane *s = vblk->dataplane;
|
||
|
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vblk)));
|
||
|
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
||
|
+ AioContext *old_context;
|
||
|
unsigned i;
|
||
|
unsigned nvqs = s->conf->num_queues;
|
||
|
Error *local_err = NULL;
|
||
|
@@ -214,7 +215,10 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev)
|
||
|
vblk->dataplane_started = true;
|
||
|
trace_virtio_blk_data_plane_start(s);
|
||
|
|
||
|
+ old_context = blk_get_aio_context(s->conf->conf.blk);
|
||
|
+ aio_context_acquire(old_context);
|
||
|
r = blk_set_aio_context(s->conf->conf.blk, s->ctx, &local_err);
|
||
|
+ aio_context_release(old_context);
|
||
|
if (r < 0) {
|
||
|
error_report_err(local_err);
|
||
|
goto fail_guest_notifiers;
|
||
|
diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
|
||
|
index 71c337c7b7..3675f8deaf 100644
|
||
|
--- a/hw/block/dataplane/xen-block.c
|
||
|
+++ b/hw/block/dataplane/xen-block.c
|
||
|
@@ -725,6 +725,7 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
|
||
|
{
|
||
|
ERRP_GUARD();
|
||
|
XenDevice *xendev = dataplane->xendev;
|
||
|
+ AioContext *old_context;
|
||
|
unsigned int ring_size;
|
||
|
unsigned int i;
|
||
|
|
||
|
@@ -808,10 +809,14 @@ void xen_block_dataplane_start(XenBlockDataPlane *dataplane,
|
||
|
goto stop;
|
||
|
}
|
||
|
|
||
|
- aio_context_acquire(dataplane->ctx);
|
||
|
+ old_context = blk_get_aio_context(dataplane->blk);
|
||
|
+ aio_context_acquire(old_context);
|
||
|
/* If other users keep the BlockBackend in the iothread, that's ok */
|
||
|
blk_set_aio_context(dataplane->blk, dataplane->ctx, NULL);
|
||
|
+ aio_context_release(old_context);
|
||
|
+
|
||
|
/* Only reason for failure is a NULL channel */
|
||
|
+ aio_context_acquire(dataplane->ctx);
|
||
|
xen_device_set_event_channel_context(xendev, dataplane->event_channel,
|
||
|
dataplane->ctx, &error_abort);
|
||
|
aio_context_release(dataplane->ctx);
|
||
|
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
|
||
|
index 82c025146d..66bdda5473 100644
|
||
|
--- a/hw/scsi/virtio-scsi.c
|
||
|
+++ b/hw/scsi/virtio-scsi.c
|
||
|
@@ -821,6 +821,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||
|
VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);
|
||
|
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
||
|
SCSIDevice *sd = SCSI_DEVICE(dev);
|
||
|
+ AioContext *old_context;
|
||
|
int ret;
|
||
|
|
||
|
/* XXX: Remove this check once block backend is capable of handling
|
||
|
@@ -836,9 +837,10 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||
|
if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
|
||
|
return;
|
||
|
}
|
||
|
- virtio_scsi_acquire(s);
|
||
|
+ old_context = blk_get_aio_context(sd->conf.blk);
|
||
|
+ aio_context_acquire(old_context);
|
||
|
ret = blk_set_aio_context(sd->conf.blk, s->ctx, errp);
|
||
|
- virtio_scsi_release(s);
|
||
|
+ aio_context_release(old_context);
|
||
|
if (ret < 0) {
|
||
|
return;
|
||
|
}
|
||
|
--
|
||
|
2.27.0
|
||
|
|