From face9eb2586fd1b55a58f92ea554c6f5d9462ede Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Fri, 26 Jan 2018 01:01:40 +0100 Subject: [PATCH] virtio: add mb() before checking notify flag The kernel vhost target enables notifying after processing each interrupt in a following manner. * unset NO_NOTIFY flag * mb() * check avail ring for slipped requests And we do the following after issuing each I/O. * update avail ring * check NO_NOTIFY If NO_NOTIFY check is reordered and read first, we might read old `true` value, and avail ring might be updated after the kernel has already done its check. This easily leads to deadlock. Change-Id: I6bb4490775dfed6fb2987e97c39b713054ae26ad Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/396499 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- lib/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/virtio/virtio.c b/lib/virtio/virtio.c index 93f123240..d7eddf5f0 100644 --- a/lib/virtio/virtio.c +++ b/lib/virtio/virtio.c @@ -464,6 +464,7 @@ virtqueue_req_flush(struct virtqueue *vq) virtio_wmb(); vq->vq_ring.avail->idx = vq->vq_avail_idx; + virtio_mb(); if (spdk_unlikely(!(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY))) { virtio_dev_backend_ops(vq->vdev)->notify_queue(vq->vdev, vq); SPDK_DEBUGLOG(SPDK_LOG_VIRTIO_DEV, "Notified backend after xmit\n");