aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2013-04-28 08:38:52 -0400
committerMichael S. Tsirkin <mst@redhat.com>2013-05-01 03:02:52 -0400
commit3dfbff328f0491b7049673cf7fd568d26a14fc4d (patch)
treeb9cfadecbf32092cf04f17946dbc8d11d6a5d9fc /drivers/vhost
parent2839400f8fe28ce216eeeba3fb97bdf90977f7ad (diff)
tcm_vhost: document inflight ref-counting use
Add more comments so we remember not to break it next time we change things. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
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];