Skip to content

Commit

Permalink
virtio-scsi: don't process IO on fenced dataplane
Browse files Browse the repository at this point in the history
If virtio_scsi_dataplane_start fails, there is a small window when it drops the
aio lock (in aio_wait_bh_oneshot) and the dataplane's AIO handler can
still run during that window.

This is done after the dataplane was marked as fenced, thus we use this flag
to avoid it doing any IO.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20201217150040.906961-2-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Maxim Levitsky authored and bonzini committed Feb 25, 2021
1 parent 166854f commit 6f1a5c3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions hw/scsi/virtio-scsi-dataplane.c
Expand Up @@ -52,38 +52,44 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp)
static bool virtio_scsi_data_plane_handle_cmd(VirtIODevice *vdev,
VirtQueue *vq)
{
bool progress;
bool progress = false;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);

virtio_scsi_acquire(s);
assert(s->ctx && s->dataplane_started);
progress = virtio_scsi_handle_cmd_vq(s, vq);
if (!s->dataplane_fenced) {
assert(s->ctx && s->dataplane_started);
progress = virtio_scsi_handle_cmd_vq(s, vq);
}
virtio_scsi_release(s);
return progress;
}

static bool virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,
VirtQueue *vq)
{
bool progress;
bool progress = false;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);

virtio_scsi_acquire(s);
assert(s->ctx && s->dataplane_started);
progress = virtio_scsi_handle_ctrl_vq(s, vq);
if (!s->dataplane_fenced) {
assert(s->ctx && s->dataplane_started);
progress = virtio_scsi_handle_ctrl_vq(s, vq);
}
virtio_scsi_release(s);
return progress;
}

static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
VirtQueue *vq)
{
bool progress;
bool progress = false;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);

virtio_scsi_acquire(s);
assert(s->ctx && s->dataplane_started);
progress = virtio_scsi_handle_event_vq(s, vq);
if (!s->dataplane_fenced) {
assert(s->ctx && s->dataplane_started);
progress = virtio_scsi_handle_event_vq(s, vq);
}
virtio_scsi_release(s);
return progress;
}
Expand Down

0 comments on commit 6f1a5c3

Please sign in to comment.