aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/tcm_vhost.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index afb530887936..96d3b47c82cd 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -83,9 +83,16 @@ struct vhost_scsi_inflight {
83 83
84struct vhost_scsi_virtqueue { 84struct vhost_scsi_virtqueue {
85 struct vhost_virtqueue vq; 85 struct vhost_virtqueue vq;
86 /* Track inflight reqs, protected by vq->mutex */ 86 /*
87 * Reference counting for inflight reqs, used for flush operation. At
88 * each time, one reference tracks new commands submitted, while we
89 * wait for another one to reach 0.
90 */
87 struct vhost_scsi_inflight inflights[2]; 91 struct vhost_scsi_inflight inflights[2];
88 /* Indicate current inflight in use, protected by vq->mutex */ 92 /*
93 * Indicate current inflight in use, protected by vq->mutex.
94 * Writers must also take dev mutex and flush under it.
95 */
89 int inflight_idx; 96 int inflight_idx;
90}; 97};
91 98
@@ -1015,6 +1022,7 @@ static void vhost_scsi_flush_vq(struct vhost_scsi *vs, int index)
1015 vhost_poll_flush(&vs->vqs[index].vq.poll); 1022 vhost_poll_flush(&vs->vqs[index].vq.poll);
1016} 1023}
1017 1024
1025/* Callers must hold dev mutex */
1018static void vhost_scsi_flush(struct vhost_scsi *vs) 1026static void vhost_scsi_flush(struct vhost_scsi *vs)
1019{ 1027{
1020 struct vhost_scsi_inflight *old_inflight[VHOST_SCSI_MAX_VQ]; 1028 struct vhost_scsi_inflight *old_inflight[VHOST_SCSI_MAX_VQ];