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 <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396499
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2018-01-26 01:01:40 +01:00 committed by Jim Harris
parent 5926647156
commit face9eb258

View File

@ -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");