summaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2013-04-28 15:38:52 +0300
committerMichael S. Tsirkin <mst@redhat.com>2013-05-01 10:02:52 +0300
commit3dfbff328f0491b7049673cf7fd568d26a14fc4d (patch)
treeb9cfadecbf32092cf04f17946dbc8d11d6a5d9fc /drivers/vhost
parent2839400f8fe28ce216eeeba3fb97bdf90977f7ad (diff)
downloadlinux-3dfbff328f0491b7049673cf7fd568d26a14fc4d.tar.bz2
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 {
struct vhost_scsi_virtqueue {
struct vhost_virtqueue vq;
- /* Track inflight reqs, protected by vq->mutex */
+ /*
+ * Reference counting for inflight reqs, used for flush operation. At
+ * each time, one reference tracks new commands submitted, while we
+ * wait for another one to reach 0.
+ */
struct vhost_scsi_inflight inflights[2];
- /* Indicate current inflight in use, protected by vq->mutex */
+ /*
+ * Indicate current inflight in use, protected by vq->mutex.
+ * Writers must also take dev mutex and flush under it.
+ */
int inflight_idx;
};
@@ -1015,6 +1022,7 @@ static void vhost_scsi_flush_vq(struct vhost_scsi *vs, int index)
vhost_poll_flush(&vs->vqs[index].vq.poll);
}
+/* Callers must hold dev mutex */
static void vhost_scsi_flush(struct vhost_scsi *vs)
{
struct vhost_scsi_inflight *old_inflight[VHOST_SCSI_MAX_VQ];